文章目錄
  1. 1. Add Nginx Repository with Yum
  2. 2. Install Nginx with Yum
  3. 3. Start Ngnix
  4. 4. How To Find Your Server’s Public IP Address
  5. 5. Automatically start up at boot
  6. 6. Server Root and Configuration
    1. 6.1. Default Server Root
    2. 6.2. Nginx Global Configuration
  7. 7. Reference

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
2
3
$ ifconfig | grep 'inet' | grep 'netmask' | grep 'broadcast' | grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 {print $2}'
# or
$ 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

  1. https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
文章目錄
  1. 1. Add Nginx Repository with Yum
  2. 2. Install Nginx with Yum
  3. 3. Start Ngnix
  4. 4. How To Find Your Server’s Public IP Address
  5. 5. Automatically start up at boot
  6. 6. Server Root and Configuration
    1. 6.1. Default Server Root
    2. 6.2. Nginx Global Configuration
  7. 7. Reference