2.編輯nginx.conf,路徑為 /usr/local/nginx/conf/nginx.conf
#修改一,引入虛擬主機(jī)的配置文件
#修改二,注釋掉server段

#user nobody;worker" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁(yè) > 營(yíng)銷資訊 > 網(wǎng)站運(yùn)營(yíng) > nginx 配置 虛擬主機(jī)

nginx 配置 虛擬主機(jī)

時(shí)間:2023-07-01 13:57:02 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)

時(shí)間:2023-07-01 13:57:02 來(lái)源:網(wǎng)站運(yùn)營(yíng)

nginx 配置 虛擬主機(jī):1.創(chuàng)建vhost文件夾,路徑為/usr/local/nginx/conf/vhost

2.編輯nginx.conf,路徑為 /usr/local/nginx/conf/nginx.conf
#修改一,引入虛擬主機(jī)的配置文件
#修改二,注釋掉server段

#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; #修改一,引入虛擬主機(jī)的配置文件 include vhost/*.conf; #修改二,注釋掉server段# server {# listen 80;# server_name www.jinggong.com;## #charset koi8-r;## #access_log logs/host.access.log main;## location / {# root /usr/local/nginx/html/jinggong/;# index index.php index.html index.htm;# try_files $uri $uri/ /index.php?$query_string;# }## #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 html;# }## # 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$ {# root /usr/local/nginx/html/jinggong/;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;# include fastcgi_params;# }## # deny access to .htaccess files, if Apache's document root# # concurs with nginx's one# ## #location ~ //.ht {# # deny all;# #}# } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}3.創(chuàng)建虛擬主機(jī)的配置文件,根據(jù)上文提到的以 *.conf 規(guī)則去創(chuàng)建文件名
#修改一,復(fù)制nginx.conf的server段為虛擬主機(jī)的配置文件
#修改二,修改虛擬主機(jī)的域名
#修改三,修改虛擬主機(jī)的訪問(wèn)路徑

下文以 /usr/local/nginx/conf/vhost/test.jinggong.cn_80.conf 為例,進(jìn)行講解:

#修改一,復(fù)制nginx.conf的server段為虛擬主機(jī)的配置文件server { listen 80; #修改二,修改虛擬主機(jī)的域名 server_name test.jinggong.cn; #修改三,修改虛擬主機(jī)的訪問(wèn)路徑 root /usr/local/nginx/html/jinggong/; #charset koi8-r; #access_log logs/host.access.log main; location / { #root /usr/local/nginx/html/jinggong/; index index.php index.html index.htm; try_files $uri $uri/ /index.php?$query_string; } #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 html; } # 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$ { #root /usr/local/nginx/html/jinggong/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ //.ht { # deny all; #} }4.至此一個(gè)虛擬主機(jī)的配置完成

關(guān)鍵詞:主機(jī),虛擬,配置

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉