By
zhaodg
更新日期:
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.
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 2 3
| $ ifconfig | grep 'inet' | grep 'netmask' | grep 'broadcast' | grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 {print $2}'
$ ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
|
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 2
| $ ls /usr/share/nginx/html 404.html 50x.html index.html nginx-logo.png poweredby.png
|
Nginx Global Configuration
The main Nginx configuration file is located at /etc/nginx/nginx.conf
.
Reference
- https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7