说明:尝试使用CentOs8.5安装nginx1.9.9失败,make的时候报错了,后面降低版本为CentOs7.5安装成功了,参考文章:【精选】centos7安装nginx-1.9.9_linx centos nginx 1.9.9版本 nginx error log file: "/-CSDN博客
一、安装nginx编译所需环境
yum install -y gcc-c++ # 编译使用yum install -y pcre pcre-devel # pcre库yum install -y zlib zlib-devel # 文件解压缩yum install -y openssl openssl-devel # 配置https服务需要
二、安装nginx
mkdir -p /home/localcd /home/localwget http://nginx.org/download/nginx-1.15.9.tar.gztar -zxvf nginx-1.15.9.tar.gzcd nginx-1.15.9/./configure --prefix=/usr/local/nginx/ --with-http_ssl_module --with-http_stub_status_modulemake&&make installcd /usr/local/nginx/sbin./nginx # 启动systemctl stop firewalld # 关闭防火墙PATH=$PATH:/usr/local/nginx/sbinecho "PATH=$PATH:/usr/local/nginx/sbin" >>/root/.bashrc# 设置开机启动echo "/usr/local/nginx/sbin/nginx">>/etc/rc.localchmod +x /etc/rc.d/rc.localnetstat -anplut |grep nginx # 查看端口ps aux | grep nginx # 查看进程
三、浏览器输入http://192.168.6.73访问
四、重启/关闭
cd /usr/local/nginx/sbin./nginx -s reload # 重启nginx./nginx -s quit # 关闭nginx
五、卸载nginx
ps aux | grep nginx
kill 994 # 根据进程ID杀进程find / -name nginx # 查找nginx相关文件
rm -rf /usr/local/nginx # 删除编译文件rm -rf /home/local/nginx-1.15.9 # 删除源文件# 删除开机启动配置rm -rf /etc/init.d/nginx