centos 8.3.0安装nginx

1. 安装PCRE最新版,现在是8.44

cd /usr/local/src &&
wget http://downloads.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz &&
tar -zxvf pcre-8.44.tar.gz &&
cd pcre-8.44 &&
./configure &&
make &&
make install &&
pcre-config --version

2. 安装Zlib库

cd /usr/local/src &&
wget http://zlib.net/zlib-1.2.11.tar.gz &&
tar -zxvf zlib-1.2.11.tar.gz &&
cd zlib-1.2.11 &&
./configure &&
make &&
make install

3. 安装OpenSSL

cd /usr/local/src &&
wget https://www.openssl.org/source/openssl-1.0.2t.tar.gz &&
tar -zxvf openssl-1.0.2t.tar.gz

4. 安装Nginx

cd /usr/local/src &&
wget http://nginx.org/download/nginx-1.18.0.tar.gz &&
tar -zxvf nginx-1.18.0.tar.gz &&
cd nginx-1.18.0 &&
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.44 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.0.2t &&
make &&
make install

安装完成后,Nginx被安装到/usr/local/nginx

5. 检查80端口

netstat -ano|grep 80

如80端口被占用,kill相应进程。

6. 检查防火墙

开放80端口

firewall-cmd --permanent --zone=public --add-port=80/tcp
其中permanent表示永久生效,public表示作用域,80/tcp表示端口和类型

关闭80端口(此处不要关闭)

firewall-cmd --permanent --zone=public --remove-port=80/tcp

查看firewall防火墙状态:systemctl status firewalld
打开防火墙: systemctl start firewalld
关闭防火墙:systemctl stop firewalld
重启防火墙: firewall-cmd --relaod 或者: systemctl reload firewalld
开机自启动防火墙: systemctl enable firewalld
禁止开机启动防火墙: systemctl disable firewalld
查看已打开的端口:firewall-cmd --list-ports

7.验证

7.1 打开浏览器,输入:localhost,出现欢迎页面。

7.2 在终端输入:curl http://localhost,返回页面文本。

猜你喜欢

转载自blog.csdn.net/tswang6503/article/details/112899788