ngnix配置文件路径
[root@VM_0_2_centos conf]# cd /usr/local/nginx/conf
//本地
server {
listen 8888; //监听端口
server_name localhost; //域名
location / {
root /www/wwwroot/mayibang.co/public; //本地存放index.html的路径
index index.php index.html index.htm default.php default.htm default.html;//首页文件名index.html
}
}
//域名
server {
listen 80;//监听端口
server_name ww.privatementor.cn; //域名 (记得去域名设置指向本服务器)
location / {
root /opt/h5/h5; //本地存放index.html的路径
index index.html; //首页文件名index.html
}
}
}
//反向代理
server {
listen 80;
server_name ww.privatementor.cn;
location / {
root html;
proxy_pass http://127.0.0.1:3333;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
#以下是一些反向代理的配置,可选。
proxy_set_header Host $host;
client_max_body_size 12828m; #允许客户端请求的最大单文件字节数
client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 64k;
}
#include youpay.conf;
#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;
}
}
ngnix重启
[root@VM_0_2_centos conf]# cd /usr/local/nginx/conf //进入conf文件夹
[root@VM_0_2_centos conf]# ps -ef|grep nginx //查看ngnix运行状态
root 20553 492 0 14:51 pts/0 00:00:00 grep --color=auto nginx
nobody 24734 32621 0 Sep25 ? 00:00:04 nginx: worker process
root 32621 1 0 2018 ? 00:00:00 nginx: master process ./nginx //只需查看master下的端口
[root@VM_0_2_centos conf]# kill -QUIT 32621 //杀死对应的master的端口
[root@VM_0_2_centos conf]# ps -ef|grep nginx //检查是否杀死成功
root 20717 492 0 14:51 pts/0 00:00:00 grep --color=auto nginx
[root@VM_0_2_centos conf]# cd /usr/local/nginx/sbin //返回nginx文件夹重启
[root@VM_0_2_centos nginx]# ./nginx //重启
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful //出现如上描述表示成功