服务器部署nginx
# centos7.6安装nginx
yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
tar zxf nginx-1.22.1.tar.gz -C /opt
mv /opt/nginx-1.22.1 /opt/nginx && cd /opt/nginx
mkdir -p /opt/nginx/logs
./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module
make && sudo make install
cat > /etc/systemd/system/nginx.service << EOF
[Unit]
Description=The NGINX HTTP Server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t -c /opt/nginx/conf/nginx.conf
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
ln -s /opt/nginx/sbin/nginx /usr/bin/nginx
sudo systemctl daemon-reload
sudo systemctl enable nginx.service
sudo systemctl restart nginx.service
sudo systemctl status nginx.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
编辑 (opens new window)