国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > JS > 正文

Nginx 配置多站點(diǎn)vhost 的方法

2024-05-06 16:41:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

假設(shè)你想在Linux Nginx中用不同的域名訪問(wèn)不同的目錄,這時(shí)就要配置多個(gè)vhost,具體配置如下,假設(shè)網(wǎng)站根目錄設(shè)定在/var/www/

1、在/var/www/下新建兩個(gè)目錄

/var/www/ushark.net/var/www/ushark.wang

2、編輯/etc/nginx/nginx.conf

http {  include    /etc/nginx/mime.types;  default_type application/octet-stream;  log_format main '$remote_addr - $remote_user [$time_local] "$request" '           '$status $body_bytes_sent "$http_referer" '           '"$http_user_agent" "$http_x_forwarded_for"';  access_log /var/log/nginx/access.log main;  sendfile    on;  #tcp_nopush   on;  keepalive_timeout 65;  #gzip on;  include /etc/nginx/conf.d/*.conf;   #主要是加入此行,如有則忽略}

3、在/etc/nginx/conf.d下新建兩個(gè)conf文件,

/etc/nginx/conf.d/ushark.net.conf/etc/nginx/conf.d/ushark.wang.conf

4、復(fù)制如下配置信息到兩個(gè)文件中,只要修改紅色部分內(nèi)容  !!! server_name與root保持一致即目錄和域名一一對(duì)應(yīng) !!!

server {  listen    80;  server_name  www.ushark.net;  #charset koi8-r;  #access_log /var/log/nginx/host.access.log main;  root  /var/www/ushark.net/;  if (!-e $request_filename){   # rewrite可根據(jù)網(wǎng)站需要增刪      rewrite ^/(.*) /index.php last;   }   location / {    index index.php index.html index.htm;  }  #error_page 404       /404.html;  # redirect server error pages to the static page /50x.html  #  error_page  500 502 503 504 /50x.html;  location = /50x.html {    root  /var/www/ushark.net/;  }  # proxy the PHP scripts to Apache listening on 127.0.0.1:80  #  #location ~ /.php$ {  #  proxy_pass  http://127.0.0.1;  #}  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  #  location ~* /.php$ {    fastcgi_index  index.php;    fastcgi_pass  127.0.0.1:9000;    include      fastcgi_params;    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;    fastcgi_param  SCRIPT_NAME    $fastcgi_script_name;  }  # deny access to .htaccess files, if Apache's document root  # concurs with nginx's one  #  #location ~ //.ht {  #  deny all;  #}}

5、重啟Nginx

systemctl restart nginx

6、 編輯/etc/hosts  !!! 核心步驟 !!!

[root@bogon ~]# vi 127.0.0.1    localhost.localdomain localhost::1       localhost6.localdomain6 localhost6127.0.0.1    www.ushark.net127.0.0.1    www.ushark.wang

總結(jié)

以上所述是小編給大家介紹的Nginx 配置多站點(diǎn)vhost 的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JavaScript/Ajax教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 南丰县| 沙湾县| 龙山县| 西和县| 双牌县| 荆州市| 若尔盖县| 阜新市| 平安县| 塔河县| 鹤庆县| 漯河市| 平塘县| 麻城市| 盱眙县| 山阴县| 马边| 贡觉县| 岳阳市| 和顺县| 贡嘎县| 沅陵县| 古交市| 涞水县| 抚远县| 云梦县| 吴旗县| 昌邑市| 册亨县| 都昌县| 庆阳市| 慈利县| 渭南市| 绥德县| 谷城县| 洛阳市| 休宁县| 保山市| 云林县| 阆中市| 华蓥市|