Home >Operation and Maintenance >Nginx >How to install nginx in CentOS7 environment
Note: Users need to have root permissions
First step, add Nginx repository
To add CentOS 7 EPEL repository, please open a terminal and use the following command:
sudo yum install epel-release
Step 2, install Nginx
Now that the Nginx repository has been installed on your server, use the following yum command to install Nginx:
sudo yum install nginx
After answering yes to the prompt, Nginx will complete the installation on the server.
The third step is to start Nginx
Nginx will not start by itself. To run Nginx, enter:
sudo systemctl start nginx
If you are running a firewall, run the following command to allow HTTP and HTTPS communication:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
You will see the default CentOS 7 Nginx web page, This is for informational and testing purposes. It should look like this:
#If you see this page, then your web server is now installed correctly.
If you want to enable Nginx when the system starts. Please enter the following command:
sudo systemctl enable nginx
Congratulations! Nginx is now installed and running!
Recommended tutorial: nginx usage tutorial
The above is the detailed content of How to install nginx in CentOS7 environment. For more information, please follow other related articles on the PHP Chinese website!