logo
. . .

How To Install NGINX On Centos 7

Step 1: Update System Packages.
Ensure that your system packages are up-to-date
# [ sudo yum update ]

Step 2: Install NGINX.
Use the following command to install NGINX:
# [ sudo yum install nginx ]

Step 3: Start NGINX.
Once the installation is complete, start the NGINX service
# [ sudo systemctl start nginx ]

Step 4: Enable NGINX to Start on Boot.
To ensure NGINX starts automatically upon system boot:
# [ sudo systemctl enable nginx ]

Step 5: Check NGINX Status.
Verify that NGINX is running without errors.
# [ sudo systemctl status nginx ]
If NGINX is running correctly, you should see an active (running) status

Step 6: Configure Firewall.
If the firewall is enabled on your system, you may need to allow traffic on the default HTTP port (80). Use the following commands:
# [sudo firewall-cmd –permanent –add-service=http ]
# [ sudo firewall-cmd –reload ]
This allows HTTP traffic through the firewall.

Step 7: Access the Default NGINX Page.
Open a web browser and navigate to your server’s IP address or domain name. You should see the default NGINX welcome page, indicating a successful installation.
# [ http://your_server_ip ]
If you see the NGINX welcome page, then NGINX is installed and working.

Step 8: Configure NGINX
You can now start configuring NGINX for your specific needs. The main NGINX configuration file is usually located at “/etc/nginx/nginx.conf “, and the default server block configuration is in “/etc/nginx/conf.d/default.conf “. Edit these files as needed for your web application.