如何源码编译安装nginx
小知识科普
nginx1.X.0,X如果是奇数(如nginx1.11,nginx.13,nginx1.17)则为开发版,如果是偶数(如nginx1.8,nginx1.12,nginx1.18)则为稳定版。
还有nginx openresty和nginx tengine2.2,这两个版本都是nginx的衍生版本,与淘宝在某种程度上都有一定联系,Openresty的优势是引入了ngx_lua模块,支持使用lua开发插件;而tengine2.2的优势是支持动态加载SO文件,不需要每次重新编译项目。
下载与解压安装包
下载安装包
下载nginx1.18.0的压缩包
wget http://nginx.org/download/nginx-1.18.0.tar.gz
解压安装包
tar -zxvf nginx-1.18.0.tar.gz
编译安装nginx
openssl依赖安装
yum install openssl openssl-devel
设置安装路径
./configure --prefix=/usr/local/soft/nginx-1.18.0 --with-http_stub_status_module --with-http_ssl_module
make编译
make && make install
验证安装
验证安装是否成功
/usr/local/soft/nginx-1.18.0/sbin/nginx -v
系统反馈如下
nginx version: nginx/1.18.0
检查nginx文件是否正常
[root@localhost nginx-1.18.0]# ./sbin/nginx -t
nginx: the configuration file /usr/local/soft/nginx-1.18.0/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/soft/nginx-1.18.0/conf/nginx.conf test is successful
启动nginx
结果发现报错了
[root@localhost nginx-1.18.0]# ./sbin/nginx -s reload
nginx: [error] invalid PID number "" in "/usr/local/soft/nginx-1.18.0/logs/nginx.pid"
解决方法
/usr/local/soft/nginx-1.18.0/sbin/nginx -c /usr/local/soft/nginx-1.18.0/conf/nginx.conf
重试启动
/usr/local/soft/nginx-1.18.0/sbin/nginx -s reload
启动成功
© 版权声明
THE END
暂无评论内容