nginx 源码安装
1.下载源码包
# nginx.org
wget http://nginx.org/download/nginx-1.20.0.tar.gz
2.解压
tar xf nginx-1.20.0.tar.gz -C /opt/
3.编译检查
[root@pingweb03 opt]# cd nginx-1.20.0/
[root@pingweb03 nginx-1.20.0]# ./configure
# 安装所需要的包
[root@pingweb03 nginx-1.20.0]# yum install libxml2 libxml2-devel
[root@pingweb03 nginx-1.20.0]# ./configure --prefix=/usr/local/nginx-1.16.1 --user=www --group=www --without-http_gzip_module --without-http_rewrite_module
4.安装
[root@pingweb03 nginx-1.20.0]# make -j
[root@pingweb03 nginx-1.20.0]# make install
5.环境变量
[root@pingweb03 nginx-1.20.0]# cat /etc/profile.d/nginx.sh
export PATH=$PATH:/usr/local/nginx-1.20.0/sbin
# export PATH=$PATH:/usr/local/php/sbin
6.开机自启
#启动时没有办法使用system管理,需要我们自己配置
[root@web3 system]# ln /usr/local/nginx-1.20.0 /usr/local/nginx
[root@web3 system]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
[root@web3 system]# systemctl daemon-reload
#启动
[root@pingweb03 ~]# systemctl start nginx
#添加完成以后保存,使用systemctl list-unit-files --type=service查看有没有nginx-fpm.service
#如果没有就是用systemctl daemon-reload重新加载,在使用以上命令查看
#添加开机自启
[root@pingweb03 ~]# systemctl start nginx