Installing a NGINX Web Server on CentOS 8 Server

Installing a NGINX Web Server on CentOS 8 Server

Welcome everyone! In this post I am going to demonstrate how to install and remove a NGLNX Web Server on CentOS 8. Let’s get started!

Step 1 Update all packages on the server.

Updating the Linux server will improve the overall compatibility, fix bugs and take care of security issues. An up-to-date Linux server makes the installation of the NGINX Web Server more smooth and less likely to go wrong.

And for CentOS 8, the new default package manager?dnf?is recommended to use, which is also used here, as it supports more extensions, uses less memory and has better performance than?yum.

Please refer to:?https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-8?for details.

Check the updates available and update the CentOS 8.

$ sudo dnf check-update

$ sudo dnf update

No alt text provided for this image

Step 2 Install a NGINX Web Server

To install the NGINX package:

$ sudo dnf install nginx

Type “y” when it asks “Is this ok[y/N]” for the downloading. The installation is complete and successful when there are no errors and “Complete!” shows up.

No alt text provided for this image
No alt text provided for this image

Verify the NGINX is installed successfully.

$ nginx -v

No alt text provided for this image

Run the following commands to enable and start the server:

$ sudo systemctl enable nginx

$ sudo systemctl start nginx

To manage the NGINX Web Server, use

$ sudo systemctl reload nginx

$ sudo systemctl restart nginx

$ sudo systemctl stop nginx

$ sudo systemctl disable nginx

to reload, restart, stop, or disable the server.

No alt text provided for this image

Step 3 Update firewall settings

Update firewall settings and open TCP port 80 and 443 to allow external connections on your Nginx web server, which runs on port 80 by default.

No alt text provided for this image
No alt text provided for this image

Step 4 Grab the IP and test the NGINX web server

To get the ip address, we can use the command:

$ ip a s eth0

Below is the default test page in the NGINX Web Server.

No alt text provided for this image

To change the test page, we can navigate to

$ cd /usr/share/nginx/html

To play safe, we first want to copy the index.html for recovery if needed.

No alt text provided for this image

Then revise the index.html. Sudo is needed as it needs permission of the root.

No alt text provided for this image

Now it shows the customized page.

No alt text provided for this image

Step 5 Removal of NGINX Web Server.

$ sudo dnf remove nginx (in the example below, yum was used instead)

No alt text provided for this image

Reference:

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-8

Robert Jones

DevOps Engineer | Certified ?? AWS, Linux ?? | Terraform ??, Docker ??, Python ?? ) | Aspiring Cloud Architect | Aspiring DevOps Engineer | Aspiring Solutions Architect | Aspiring AWS Cloud Engineer

2 年

Level Up In Tech student displaying excellence.

YINGJUN TAN

IT manager at Southern Cross Education Institute and Higher Education

2 年

Linux kudo

Carl Hayes

Passionate IT Professional | AWS & VMWare Certified | Cloud Optimization

2 年

Great documentation! Good job Weiping Zhang

要查看或添加评论,请登录

Weiping Zhang的更多文章

社区洞察

其他会员也浏览了