install nginx on centos 8.3.0

1. Install the latest version of PCRE, which is now 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. Install Zlib library

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. Install 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. Install 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

After the installation is complete, Nginx is installed to /usr/local/nginx

5. Check port 80

netstat -ano | grep 80

If port 80 is occupied, kill the corresponding process.

6. Check the firewall

Open port 80

firewall-cmd --permanent --zone=public --add-port=80/tcp
where permanent means permanent effect, public means scope, 80/tcp means port and type

Close port 80 (do not close here)

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

Check the firewall status: systemctl status firewalld
Turn on the firewall: systemctl start firewalld
Turn off the firewall: systemctl stop firewalld
Restart the firewall: firewall-cmd --relaod or: systemctl reload firewalld
Start the firewall automatically when booting: systemctl enable firewalld
Disable the firewall from booting: systemctl disable firewalld
View the opened ports: firewall-cmd --list-ports

7. Verification

7.1 Open the browser, enter: localhost, the welcome page appears.

7.2 Enter in the terminal: curl http://localhost, return the page text.

 

Guess you like

Origin blog.csdn.net/tswang6503/article/details/112899788