【Nginx】nginx虚拟机设置
        【摘要】 
                    
                        
                    
                    一般情况下,我们的一台机器都不会仅仅部署一个项目,那么这个时候需要我们设置虚拟机来映射多个地址的解析。 
假设我们目前有一个已经设置好的nginx服务器,通过php-fpm提供服务。 
找到配置文件地址 ...
    
    
    
    一般情况下,我们的一台机器都不会仅仅部署一个项目,那么这个时候需要我们设置虚拟机来映射多个地址的解析。
假设我们目前有一个已经设置好的nginx服务器,通过php-fpm提供服务。
找到配置文件地址
有的时候我们不知道配置文件在哪里,而不同版本的Linux发行版的差距又很大,那么这个时候,就需要去找配置文件的位置
[root@iZ28405a6nlZ ~]# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
- 1
 - 2
 
这样就找到了配置文件的位置/etc/nginx
设置配置文件
进去配置文件夹,发现里面有个conf.d的文件夹,这里面的配置文件,每次重启都会被加载进去,在这个里面创建你的域名.conf的文件,例如www.localhost.com.conf
下面是我写的例子,每个服务器的配置都会差别,不要随便拿过来用
server {
    listen       80;
    server_name www.index.com;
    index index.html index.htm index.php;
    root  /usr/share/nginx/html/xxx;
    location / {  
        try_files $uri $uri/ /index.php?$args;  
        if (!-e $request_filename){  
        rewrite ^/(.*) /index.php last;  
        }  
        root   /usr/share/nginx/html/markweb;  
        index  index.php  index.html  index.htm;  
    }   
    location ~ \.php$ {
        root           /usr/share/nginx/html/xxx;
        include  fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/markweb$fastcgi_script_name;
       # include        fastcgi_params;
    }
    log_format www.index.com '$remote_addr - $remote_user [$time_local] $request'
    '$status $body_bytes_sent $http_referer '
    '$http_user_agent $http_x_forwarded_for';
    access_log  /var/log/www.index.com.log www.index.com;
}
重启之后设置对应的域名解析就可以咯~
文章来源: coderfix.blog.csdn.net,作者:小雨青年,版权归原作者所有,如需转载,请联系作者。
原文链接:coderfix.blog.csdn.net/article/details/48444659
        【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
            cloudbbs@huaweicloud.com
        
        
        
        
        
        
        - 点赞
 - 收藏
 - 关注作者
 
            
           
评论(0)