CentOS 7系统下安装nginx-1.13的教程
程序员文章站
2022-05-21 08:16:48
1. 安装依赖
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel...
1. 安装依赖
yum install gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel
如果途中碰到问题,自行查找解决办法
2.准备安装
wget https://nginx.org/download/nginx-1.13.12.tar.gz tar -zxvf nginx-1.13.12.tar.gz cd nginx-1.13.12/ mkdir {/var/temp,/var/temp/nginx,/var/run/nginx}
./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi
make && make install
3.启动
cd /usr/local/nginx/sbin/ ./nginx
也可以指定配置文件启动
./nginx -c /usr/local/nginx/conf/nginx.conf
4.停止
方法一:kill -9 processId 方法二:cd /usr/local/nginx/sbin&&./nginx -s stop 方法三:推荐 cd /usr/local/nginx/sbin&&./nginx -s quit
5.重新加载配置
方法一:./nginx -s quit&&./nginx 方法二:./nginx -s reload
6.配置开机启动
vim /lib/systemd/system/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 quit PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl enable nginx.service
7.其他命令
1. 启动nginx systemctl start nginx.service 2. 设置开机启动 systemctl enable nginx.service 3. 取消开机启动 systemctl disable nginx.service 4. 查看服务状态 systemctl status nginx.service 5. 重启nginx systemctl restart nginx.service
完