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
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.
Verify the NGINX is installed successfully.
$ nginx -v
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.
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.
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.
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.
Then revise the index.html. Sudo is needed as it needs permission of the root.
Now it shows the customized page.
Step 5 Removal of NGINX Web Server.
$ sudo dnf remove nginx (in the example below, yum was used instead)
Reference:
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.
IT manager at Southern Cross Education Institute and Higher Education
2 年Linux kudo
Passionate IT Professional | AWS & VMWare Certified | Cloud Optimization
2 年Great documentation! Good job Weiping Zhang