Below I am on the CentOS installation Nginx experience to do a simple record, for later check.
1. Download Nginx-release Package
For the CentOS 7 example, download the Nginx package: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Packages for other Linux distributions: http://nginx.org/en/linux_packages.html
2, to the normal user login terminal, and then import GPG signing key.
sudo rpm "http://nginx.org/keys/nginx_signing.key"
3. Install the package downloaded in 1.
sudo Yum Install /home/sue/download/nginx-release-centos-7-0.el7.ngx.noarch.rpm
where "/home/sue/download/" is the save path for the package.
4. Installing Nginx Server
sudo Yum Install Nginx
At this point, if there is no accident, the installation is complete, the next step is to configure the server.
After installing Nginx, let's take a look at where Nginx is installed.
Whereis Nginx
After executing the command, the system prompts you for the following location:
Nginx:/usr/sbin/nginx/etc/nginx/usr/share/nginx/usr/share/man/man3/nginx.3pm.gz/usr/share/man/man8/nginx.8.gz
Then it's easy for us to know where the Nginx server's configuration file is located:/etc/nginx
We then look at the configuration files that are in the directory:
Cd
ls -l
After executing the command, we can see a list of files, but for now we just need to look at the contents of the "nginx.conf" file, which is the configuration file of the Nginx server:
Cat -N nginx.conf
Note: If the Nginx installation package selected is "Nginx for CentOS 6", then the path to the configuration file may not be the path, possibly/etc/nginx/conf.d/default.conf.
As can be seen from the configuration above, the server's default listening port is 80 port, the server name (can also become the domain name) is localhost (127.0.0.1), the root directory of the server is "/usr/share/nginx/html". If the server starts up normally, then we can enter "localhost" or "127.0.0.1" directly in the address bar of the browser, we should be able to see the default homepage. Below we will start the Nginx server:
sudo nginx
If an error occurs, you will need to execute the following command after the last command has been completed:
sudo nginx-s reload
If there is no error, open the browser in the address bar to enter "127.0.0.1" can see the following default home page:
In addition, Nginx also has the following several common command line parameters:
- Quit-gracefully shuts down the server
- Stop-Force the server to shut down
- Reload-Reload the configuration file
- Reopen-Reopen log file
At this point, an nginx server that can host a static page is installed, but it does not yet host an ASP. NET Web application, and we need to do some configuration. These configurations will be explained later when I use the Mono runtime to build an ASP. NET MVC application on Nginx.
Installing the Nginx server on CentOS 7