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

首頁 > 網(wǎng)站 > Nginx > 正文

nginx配置多個站點共用80端口的解決方法

2024-08-30 12:24:59
字體:
供稿:網(wǎng)友

只用改一個地方,在http模塊里面加入你要引用的虛擬主機(jī)配置文件目錄即可:

例如:include /usr/local/nginx/default.d/*.conf;

http {  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;  tcp_nodelay     on;  keepalive_timeout  65;  types_hash_max_size 2048;  include       /etc/nginx/mime.types;  default_type    application/octet-stream;  include /usr/local/nginx/default.d/*.conf; //就這里加一行就可以了}

2、建立虛擬主機(jī)配置目錄:

/usr/local/nginx/下面建立default.d文件夾,專門放置網(wǎng)站的配置文件。

貼一個我的配置上來:

/usr/local/nginx/default.d/mytest.conf

server {  listen    80 ;  //注意這里,要把默認(rèn)的那個default_server去掉,因為我們在下面要單獨配置域名訪問,所以這里不要留default_server,不然會報錯。  server_name mytest.com; //這里寫你想設(shè)置的域名,可以寫多個,與名之間用空格隔開  root     /mnt/share/mytest.com;  //這里是你虛擬機(jī)的根目錄,寫絕對路徑  # Load configuration files for the default server block.  location / {    index index.php index.html index.htm; //這里配置默認(rèn)訪問的頁面  }  location ~* /.php$ {  //這里配置php解析.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;  }  error_page 404 /404.html;  //默認(rèn)的錯誤頁面    location = /40x.html {  }  error_page 500 502 503 504 /50x.html;    location = /50x.html {  }}

再來一個:

server {    listen    80;    server_name www.mytest1.com;    root     /var/www/html;    index index.html index.htm index.php;    location / {      try_files $uri $uri/ /index.php?$query_string;    }    location = /favicon.ico {     log_not_found off;    }    location ~ /.php$ {      fastcgi_pass  127.0.0.1:9000;      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;      include    fastcgi_params;    }}

3、還想再建其他虛擬機(jī),一樣的,復(fù)制上面那個文件,修改我標(biāo)注的的那幾個地方即可!

4、虛擬機(jī)配置文件配置好了之后,還需要在linux下面的hosts文件下面加上以上域名,不然還是會訪問外網(wǎng)的哦。

vim /etc/hosts127.0.0.1  mytest1.com127.0.0.1  mytest.com

5、如果我們是要在windows下面訪問虛擬機(jī)里面的linux下面的網(wǎng)站,那么還要在windows下面配置hosts文件,所有的域名都指向linux服務(wù)器,例如:

192.168.0.27  mytest1.com192.168.0.27  mytest.com            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 全南县| 崇义县| 广德县| 巍山| 昭觉县| 佛山市| 满城县| 石屏县| 琼海市| 安新县| 长丰县| 茂名市| 江西省| 蓝田县| 和田市| 瓦房店市| 南川市| 偃师市| 梓潼县| 石河子市| 松桃| 汉源县| 阳高县| 文山县| 安庆市| 高雄市| 霍邱县| 南江县| 晴隆县| 屯留县| 盐源县| 荔波县| 天气| 万全县| 博客| 通江县| 香河县| 邹平县| 南通市| 尉犁县| 南昌市|