nginx配置二级域名

先在阿里云解析一个二级域名  

控制台-》域名与万网-》域名  

解析-》添加解析      

nginx配置二级域名        

   填上主机记录  www          记录值  你的ip   其他默认就ok

   现在编辑nginx.conf    /usr/local/nginx/conf/nginx.conf

在http中加上一句

    include /usr/local/nginx/conf/sites/*.conf;

包含所有sites下所有以 .conf 为后缀的文件

cd /usr/local/nginx/conf

mkdir sites

cd sites 

vim www.xxx.com.conf

下面可以直接复制:

server {
    listen 80;                            
    server_name www.xxx.com;             //你解析的二级域名
    root /usr/local/nginx/html/;                     //项目目录
    index index.php index.html index.htm; 
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        /usr/local/nginx/conf/fastcgi_params;
    }
    error_page 404 /404.html;
    location /404.html {
        root /usr/local/nginx/html/;
    }
    error_page 500 502 503 504 /50x.html;
    location =/50x.html {
        root /usr/local/nginx/html/;
    }

}

重启nginx

killall nginx   

/usr/local/nginx/sbin/ngxin 

齐活