nginx安装

yum源安装

源码安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost nginx-1.18.0]# yum install -y zlib-devel pcre-devel
[root@localhost nginx-1.18.0]# ./configure --prefix=/usr/local/nginx
......
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@localhost nginx-1.18.0]# make && make install

设置开机自启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost nginx-1.18.0]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=ture
[Install]
WantedBy=multi-user.target
[root@localhost nginx-1.18.0]# systemctl enable nginx
[root@localhost nginx-1.18.0]# systemctl start nginx
[root@localhost nginx-1.18.0]# systemctl status nginx