nginx 安装
安装nginx
-
下载地址
wget http://nginx.org/download/nginx-1.17.7.tar.gz
-
安装依赖
yum install -y pcre pcre-devel openssl openssl-devel gcc
-
创建nginx启动用户
#假设用户为nginx useradd nginx -s /sbin/nologin -M
-
nginx-1.16.1.tar.gz拷贝到/usr/local/src目录下,解压
tar zxf nginx-1.16.1.tar.gz
-
编译安装
cd nginx-1.6.1 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make && make install
添加开机启动
- 创建文件
/usr/lib/systemd/system/nginx.service
- nginx.service中内容
/usr/lib/systemd/system
[root@VM-0-6-centos system]# cat nginx.service
[Unit]
Description=nginx
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 stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 服务加入开机启动
systemctl enable nginx.service