- /etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
- 程序文件在/usr/sbin/nginx
- 日志放在了/var/log/nginx中
- 并已经在/etc/init.d/下创建了启动脚本nginx
- 虚拟主机的目录设置在了/var/www
备注:进入/etc/nginx/ 中
看到 nginx.conf,
upstream advertiser_server {
server 127.0.0.1:8080 max_fails=1 fail_timeout=15s weight=5; # 两个tomcat 可以配权重
server 127.0.0.1:8081 max_fails=1 fail_timeout=15s weight=5;
}
server {
listen 80; # 监听80 端口
server_name payapi.test.com advapi.test.com; # 域名
charset utf-8;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://advertiser_server; # 上面的upstream
}
}
基于域名的虚拟主机
server {
listen 80;
server_name api.kellychen.hh; #域名
charset utf-8;
location / {
index index.html; #html网页存放的目录
root /var/www/html;
}
}
基于ip的虚拟主机
server {
#监听的ip和端口
listen 192.168.8.43:80;
#主机名
server_name 192.168.8.43;
charset utf-8;
location / {
index index.html;
#html网页存放的目录
root /var/www/html;
}
}
二, nginx 常用命令