How to install and configure an Nginx server on CentOS?

The steps for installing and configuring Nginx server in CentOS are as follows:

  1. Update the system: First, make sure the system is updated to the latest version by using the following command.
sudo yum update
  1. Install Nginx: Use the following command to install Nginx:
sudo yum install nginx
  1. To start the Nginx service: After installation, use the following command to start the Nginx service:
sudo systemctl start nginx
  1. To enable Nginx to start automatically upon booting, use the following command:
sudo systemctl enable nginx
  1. Set up the firewall: If the firewall is enabled, open port 80 to allow HTTP traffic to pass through.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
  1. Setting up Nginx: The Nginx configuration file is located at /etc/nginx/nginx.conf and can be modified as needed. Common configurations include changing the listening port and setting up virtual hosts.
  2. Test Nginx: Open a browser and visit the server’s IP address or domain name. If you see the Nginx welcome page, it means that Nginx has been successfully installed and configured.

You can install and configure an Nginx server in CentOS by following the steps above.

Leave a Reply 0

Your email address will not be published. Required fields are marked *