[root@wizesb-test-mng01 gcc]# cd nginx/
[root@wizesb-test-mng01 nginx]# tar zxvf nginx-1.15.7.tar.gz
[root@wizesb-test-mng01 nginx]# cd nginx-1.15.7
[root@wizesb-test-mng01 nginx]# ./configure
[root@wizesb-test-mng01 nginx]# make
[root@wizesb-test-mng01 nginx]# make install
// 测试是否安装成功
cd /usr/local/nginx
./sbin/nginx -t
// 显示结果
[root@192 nginx]# ./sbin/nginx -t
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
// 启动nginx
cd /usr/local/nginx/sbin
./nginx
//通过端口查看nginx是否开启
netstat -ntlp | grep 80
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
配置nginx开机自启动
vim /etc/rc.d/rc.local
/usr/local/nginx/sbin/nginx
将nginx加入systemctl
vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
###通过 find / -name 'nginx.pid'找到pid的位置
PIDFile=/usr/local/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq
保存退出
开启开机启动
systemctl enable nginx.service
systemctl restart nginx
pkill -9 nginx
systemctl start nginx.service
查看端口占用
ss -lntp | egrep ':80\s'
部署vue项目
cd /usr/local/nginx/conf/
vi nginx.conf