Nginx配置虚拟主机
Posted dgjnszf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx配置虚拟主机相关的知识,希望对你有一定的参考价值。
以hostname区分不同的网站,一个server{ }配置块就是一个网站。
# 省略一些配置
......
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; server { listen 80; server_name www.ccke.org; # 网站A
location / { root html; index index.php index.html; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name www.nmka.com; # 网站B
location / { root html; index index.html; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
# 省略一些配置
...... }
以上是关于Nginx配置虚拟主机的主要内容,如果未能解决你的问题,请参考以下文章
Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段