nginx配置腾讯云二级域名

一、第一步登录腾讯云控制台进行二级域名信息填写

二、点击添加记录,填写信息

 主机记录字段填写自己想使用的二级域名名称,记录类型和线路类型使用系统默认的即可,记录值填写自己服务器外网ip,点击保存即可。

三、接下来就是配置nginx

我的nginx是源码编译安装的,安装在/usr/local/nginx/下

配置文件在/usr/local/nginx/conf/nginx.conf

修改配置文件nginx.conf

二级域名配置单独使用文件进行配置

 所以进入相应的位置并新建一个名称为.conf结尾的文件

 

 每个二级域名都要写在server里面

server{
listen 80;
server_name abc.flyfly520.club;#腾讯云后台自己新建的二级域名
#index index.html index.htm index.php;
#root html/test/public;
#if ($host != abc.flyfly520.club) { return 301 $scheme://abc.flyfly520.club$request_uri; }
location / {
root html/test/public;#二级域名根目录
proxy_set_header Host $host:$server_port;
index index.html index.html index.php;

if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}


location ~ \.php(.*)$ {
root html/test/public/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html/test;
}
}

四、重启nginx服务

浏览器输入网址测试

补充说明:添加了test作为名称的二级域名一直不能使用,不知道什么原因,有哪位大佬知道欢迎留言评论。

猜你喜欢

转载自www.cnblogs.com/flyfly123/p/12104664.html