How To Install Nginx on CentOS 7
更新日期:
文章目錄
Add Nginx Repository with Yum
1 | $ sudo yum install epel-release |
Install Nginx with Yum
1 | $ sudo yum install nginx |
Start Ngnix
1 | $ sudo systemctl start nginx.service |
You can do a spot check right away in your web browser.
1 | http://server_domain_name_or_IP/ |
You will see the default CentOS 7 Nginx web page. If you have a success, it will look like this:

How To Find Your Server’s Public IP Address
1 | $ ifconfig | grep 'inet' | grep 'netmask' | grep 'broadcast' | grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 {print $2}' |
Automatically start up at boot
1 | $ sudo systemctl enable nginx.service |
Server Root and Configuration
Default Server Root
The default server root directory is /usr/share/nginx/html.
1 | $ ls /usr/share/nginx/html |
Nginx Global Configuration
The main Nginx configuration file is located at /etc/nginx/nginx.conf.