折腾了一天的时间在linux安装nginx,发现系统上什么都没有,需要安装各种依赖,走了许多坑,正与填完了,在这里和大家分享一下;
一.准备安装包
gcc
gcc-c++
openssl
zlib
pcre
nginx
我的linux是CentOS7的
最新最全的安装包已经为大家准备好了:https://download.csdn.net/download/u012885136/11171078


二.安装:
第一步:安装gcc和gcc-c++
这里是rpm二进制的文件

所有的文件都放在同一个目录下,执行以下命令
rpm -Uvh *.rpm --nodeps --force
第二步安装pcre
tar -zxvf pcre-8.42.tar.gz
./configure
make
make install


安装openssl
tar -zxvf openssl-1.0.2r.tar.gz
./configure
make
make install
安装zlib
tar -zxvf zlib-1.2.11.tar.gz
./configure
make
make install

Error:在没有安装zlib的情况下安装nginx会报错

安装nginx
tar -zxvf nginx-1.15.12.tar.gz
./configure
make
make install

安装完成后执行 nginx命令
一般情况下安装完成后命令会在 /usr/local/nginx/sbin/ 下,如图

完成之后下,执行命令
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
可以到/usr/local/nginx/conf下根据需要修改配置文件nginx.config
关于nginx502的问题,可以尝试以下方法解决
1、检查配置,如果配置没有问题的话,进行第2步
2、防火墙的问题,可以关闭防火墙或者将端口加到规则中
简单粗暴:关闭防火墙
service firewalld stop
以80为例把端口开放出去
firewall-cmd --zone=public --add-port=80/tcp --permanent
谢谢,觉得好记得点赞
网友评论