b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

nginx怎么读 Nginx添加多个二级子域名

电脑杂谈  发布时间:2018-02-10 14:35:45  来源:网络整理

nginx windows_nginx怎么读_nginx怎么发音

nginx怎么读

首先,在自己的域名控制台中添加解析,这里以添加blog前缀为例

我用的是万网,在??解析设置??中??添加解析

添加解析

主机记录:你想要的二级域名??

记录值:你的IP地址

保存后,我们就完成了第一步把子域名解析到我们的服务器上。nginx怎么读

第二步:添加配置文件

[root@iZ2844brz0xZ ~]# cd /usr/local/nginx/conf/
[root@iZ2844brz0xZ ~]# vim nginx.conf

1

2

在??http??模块中添加如下语句

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

1

告诉这个配置文件要去包含??/sites-enabled??目录下的所有以??.conf??结尾的配置文件。:wq??保存。

此时,我们新建一个??/sites-enabled??文件夹,并在其中添加??blog.***.com.conf??文件

[root@iZ2844brz0xZ conf]# mkdir sites-enabled
[root@iZ2844brz0xZ sites-enabled]# vim blog.***.com.conf

1

2

在文件中添加

nginx windows_nginx怎么读_nginx怎么发音

server {
    listen 80;                              #端口
    server_name blog.***.com;               #绑定域名
    root /usr/local/nginx/html/blog/;       #网站根目录,建议使用绝对路径
    index index.php index.html index.htm;   #默认文件

    #添加对php的解析
    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/;
    }
}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

nginx windows_nginx怎么读_nginx怎么发音

19

20

21

22

23

24

25

内容可自行添加

在??nginx.conf??文件的??server??模块中添加以下语句

if ( $host ~* (\b(?!www\b)\w+)\.\w+\.\w+ ) {
 set $subdomain /$1;
}
location / {
 root html$subdomain;
 index index.html index.php index.htm index;
}

1

2

3

4

5

6

7

即可解析到对应文件夹

最后,重启nginx即可


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-70172-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...