nginx 虚拟机配置
基于域名的虚拟主机
server {
listen 80;
server_name www.1000phone01.com; #域名
root /usr/share/nginx/web1; # 路径(在该路径设置页面)
access_log /var/log/www.1000phone01.com.log main;
error_log # 日志路径
/var/log/www.1000phone01.com.error.log;
location / {
index index.html; # 访问页面
}
}
vim /etc/hosts
10.0.122.156 www.111.com
nginx -t
systemctl reload nginx
基于 ip 的虚拟主机
ifconfig eth0:1 192.168.95.200
/etc/nginx/conf.d/xxx.conf
server {
listen 192.168.122.110:80;
server_name www.app1.com;
root /usr/share/nginx/app1;
access_log /var/log/app1.com.log main;
error_log
/var/log/app1.com.error.log;
location / {
index index.html;
}
}
基于端口的虚拟主机
server {
listen 8080; # 不可重复
server_name www.port2.com;
root /usr/share/nginx/port2;
access_log /var/log/www.port2.com.log main;
error_log
/var/log/port2.com.error.log;
location / {
index index.html;
}
}
网友评论