About nginx
Nginx is a high-performance web server software. This is a more flexible and lightweight program than Apache HTTP server.
This tutorial will teach you how to install nginx and start nginx on your centos7 server.
Prerequisites
In this tutorial, you must have the root permission.
You can see how to set up the initial server setup Steps 3 and 4 in the following 7 tutorial with centos.
Step 1-add an nginx source [resource library]
The yum software library of centos7 nginx to be added. Open the SSH terminal and run the following command:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Step 2-install nginx
Now, the nginx resource library has been installed on the server. Use the following Yum command to install nginx:
sudo yum install nginx
When you reply to Y, nginx will complete the installation of Virtual Private server (VPs.
Step 3-enable nginx
Nginx does not start automatically. To run nginx, type:
sudo systemctl start nginx.service
You can access the public IP address of your server in the Web browser (see the instructions under the title ):
http://server_domain_name_or_IP/
You will see the default centos7 nginx webpage, which provides information and testing purposes. It should look like this:
650) This. width = 650; "src =" https://assets.digitalocean.com/articles/lemp_1404/nginx_default.png "alt =" centos 7 nginx default "style =" border: 0px; Height: auto; "/>
If you see this page, your web server can be correctly installed now.
Before continuing, you may want to start nginx during system boot. To do this, enter the following command:
sudo systemctl enable nginx.service
Congratulations! Nginx is now installed and running!
How to find the public IP address of your server
You can run the following command to display the public IP address of the server:
ip addr show eth0 | grep inet | awk ‘{ print $2; }‘ | sed ‘s/\/.*$//‘
Root directory and configuration of the server
If you want to start serving as your own web page or application through nginx, you will want to know where the nginx configuration file and the default server root directory are located, follow cantgis to see the following operations.
Default server root directory
The default server root directory is/usr/share/nginx/html
.
This location is the nginx that is included in the default server module configuration file. It is located in
/etc/nginx/conf.d/default.conf
.
Server module configuration
Any additional server module (called the virtual host in Apache) is created here by creating a new configuration file:
/etc/nginx/conf.d
.
When nginx is started and.conf
The final file in this directory will be loaded.
Global configuration of nginx
The main nginx configuration file is located
/etc/nginx/nginx.conf
.
You can also change the number of processes to expand the server load.
This article is from the "cantgis" blog, please be sure to keep this source http://cantgis.blog.51cto.com/5788192/1540004