garyprinting.com

Effortlessly Set Up an NGINX Web Server on CentOS 8

Written on

Installing NGINX on CentOS 8

In this guide, you will learn how to install, activate, and initiate an NGINX Web Server on CentOS 8, step by step. We will also explore how to automate this entire procedure using a straightforward Bash script.

First, it's essential to verify if there are any pending package updates for your CentOS server. You can do this by executing the following command:

sudo yum check-update

After running this command, you will be prompted to enter your password. Even the most diligent users occasionally forget their passwords or accidentally press the wrong key! Once you check for updates, proceed to install any available updates using:

sudo yum update

After executing the update command, the system will either apply the updates or indicate that no updates are available, as shown by the "Complete" message.

Next, it's time to install NGINX. Use the command below:

sudo dnf install nginx

During the installation process, the system will inform you about the number of packages being installed and ask for your confirmation. Simply type "y" to finalize the installation.

Congratulations! You have successfully installed an NGINX Web Server on CentOS 8. However, there's still some work to do to get it fully operational.

Enabling and Starting NGINX

To enable the server, use the following command:

sudo systemctl enable nginx

Now that the server is enabled, you can start it by running:

sudo systemctl start nginx

Next, you will need to adjust the firewall settings. First, it's a good idea to note your IP address, which you can retrieve with:

curl ifconfig.me

This step is crucial for testing your server later. After that, adjust your firewall settings with the command:

sudo firewall-cmd --permanent --add-service=http

Afterward, list the current firewall settings and reload the firewall using these commands:

sudo firewall-cmd --list-all

sudo firewall-cmd --reload

To check the status of your NGINX server, run:

systemctl status nginx

At this point, you’re ready to test your setup! Copy your public IP address and paste it into your web browser to see if everything is functioning correctly.

Creating a Bash Script for Automation

Now comes the exciting part: automating the entire process with a simple Bash script. Begin by opening your vi editor and creating a new file with:

sudo vi nginx.sh

Enter your password when prompted. Once inside the editor, press "i" to start typing. Input the necessary commands to automate the installation and setup process.

After entering all the commands, save and exit by pressing Esc followed by :wq.

Next, modify the file permissions with:

sudo chmod +x nginx.sh

After entering your password again, execute the script by running:

./nginx.sh

And just like that, the entire setup process is automated with a single command!

This video titled "Installing and Configuring NGINX on CentOS" provides a comprehensive walkthrough of the installation process.

In the video "How to Install and Run NGINX on CentOS 8 RHEL 8," you'll find additional insights on managing NGINX effectively.

Thank you for reading! I hope you found this guide helpful.

Jason Wood

@jwood9799

NGINX setup on CentOS 8 screenshot

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Energizing Strategies for Developers During Busy Workdays

Discover effective methods to recharge your energy during hectic workdays as a developer.

Unlocking Your Potential: Are You Fit for Cambridge Studies?

Discover if you're smart enough to study at Cambridge through an engaging math puzzle!

Mastering Callbacks with Arrow Functions: Simplifying Asynchronous JavaScript Programming

Discover how Arrow Functions enhance the use of callbacks in JavaScript, simplifying asynchronous programming with practical examples.