安装好nginx后
//指定 nginx 使用哪个配置文件 [root@localhost sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf //加载配置文件 重启 [root@localhost sbin]# ./nginx -s reload
查找nginx的pid
[root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# netstat -anop | grep 0.0.0.0:80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 454/nginx: worker p off (0.00/0/0) tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 454/nginx: worker p off (0.00/0/0) [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# ss -nltp|grep nginx LISTEN 0 128 *:80 *:* users:(("nginx",pid=466,fd=12),("nginx",pid=455,fd=12),("nginx",pid=454,fd=12)) LISTEN 0 128 *:443 *:* users:(("nginx",pid=466,fd=13),("nginx",pid=455,fd=13),("nginx",pid=454,fd=13)) LISTEN 0 128 *:8000 *:* users:(("nginx",pid=466,fd=14),("nginx",pid=455,fd=14),("nginx",pid=454,fd=14)) [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]#
linux 查看nginx 启动路径
根据上面
[root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# netstat -anop | grep 0.0.0.0:80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 454/nginx: worker p off (0.00/0/0) tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 454/nginx: worker p off (0.00/0/0) [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# ss -nltp|grep nginx LISTEN 0 128 *:80 *:* users:(("nginx",pid=466,fd=12),("nginx",pid=455,fd=12),("nginx",pid=454,fd=12)) LISTEN 0 128 *:443 *:* users:(("nginx",pid=466,fd=13),("nginx",pid=455,fd=13),("nginx",pid=454,fd=13)) LISTEN 0 128 *:8000 *:* users:(("nginx",pid=466,fd=14),("nginx",pid=455,fd=14),("nginx",pid=454,fd=14)) [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# ll /proc/466/exe lrwxrwxrwx 1 root root 0 3月 24 15:22 /proc/466/exe -> /usr/sbin/nginx [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]# /usr/sbin/nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@iZ2ze8gmxmxwd4e3qze8q0Z conf.d]#
nginx 域名跳转端口项目
upstream cloud{ server 127.0.0.1:5212; } server { listen 80; server_name www.shitou6.work shitou6.work; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location /{ proxy_pass http://cloud/; } }