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 

齐活




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值