源码编译安装LNMP环境之Nginx篇

xiaoxiao2025-07-29  20

我的系统环境:CentOS 7.4 64位 nginx下载页面:http://nginx.org/en/download.html 1、安装编译依赖的库 $ yum install -y gcc $ yum install -y gcc-c++ $ yum install -y pcre pcre-devel $ yum install -y zlib zlib-devel $ yum install -y openssl openssl-devel 附:除了用yum安装依赖库以外,还可以通过源码来安装依赖库。 参考我的这篇文章:https://blog.csdn.net/tangxinzhuan/article/details/86498950 2、源码编译安装Nginx $ wget http://nginx.org/download/nginx-1.15.5.tar.gz $ tar zxvf nginx-1.15.5.tar.gz $ cd nginx-1.15.5/ $ ./configure --prefix=/usr/local/nginx $ make $ make install 注意:只要编译中没有出现error错误提示,可以忽略其他提示信息。 3、将nginx目录添加进linux系统的环境变量 (添加环境变量的好处,例如:/usr/local/nginx/sbin/nginx -t 可以简写成 nginx -t) 参考我的这篇博文:https://blog.csdn.net/tangxinzhuan/article/details/83348395 4、使nginx支持Php程序 参考我的这篇博文:https://blog.csdn.net/tangxinzhuan/article/details/83379884 nginx的常用命令: $ nginx -t #测试配置是否正确 $ nginx -s reload #在不停止服务的情况下,重读配置文件并生效 $ nginx -s stop #立即停止服务 $ nginx -s quit #安全的停止服务(处理完所有用户请求再停止服务) 【nginx进阶】 1、将nginx添加到service(此教程待完成) $ chmod +x /etc/init.d/nginx $ chkconfig --add /etc/init.d/nginx $ chkconfig nginx on 2、配置开机启动 # 给开机文件授可执行权限 $ chmod +x /etc/rc.d/rc.local $ vi /etc/rc.d/rc.local # 在开机文件rc.local中的末尾增加一行代码 /usr/local/bin/nginx # ESC :wq 保存退出

 

转载请注明原文地址: https://www.6miu.com/read-5033897.html

最新回复(0)