1.配置文件
# 设置进程数
worker_processes 4;
# 设置启动用户,一般情况下设置为当前用户,要不然会出现权限不足
user root;
events {
worker_connections 1024;
}
http {
# 设置虚拟主机1
server {
listen 8001;
server_name 172.16.122.177;
access_log /root/nginx/server/data0/access.log;
error_log /root/nginx/server/data0/error.log;
location / {
root /root/nginx/server/data0;
index index.html index.htm;
}
}
# 设置虚拟主机2
server {
listen 8002;
server_name 172.16.122.177;
access_log /root/nginx/server/data1/access.log;
error_log /root/nginx/server/data1/error.log;
location / {
root /root/nginx/server/data1;
index index.html index.htm;
}
}
# 设置虚拟主机3
server {
listen 8003;
server_name 172.16.122.177;
access_log /root/nginx/server/data2/access.log;
error_log /root/nginx/server/data2/error.log;
location / {
root /root/nginx/server/data2;
index index.html index.htm;
}
}
}
2.启动nginx
nginx -s stop && nginx -c nginx_virtual_hosts.conf
3.访问页面
8001 端口
8002端口
标签:index,log,虚拟主机,配置,server,access,nginx,root From: https://www.cnblogs.com/ccblblog/p/179654778003端口