Install Nginx server and centosnginx server on CentOS 7

Source: Internet
Author: User

Install Nginx server and centosnginx server on CentOS 7

Next I will record my Nginx installation experience on CentOS for future reference.

1. Download The nginx-release package

Take CentOS 7 as an example, download nginx package: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Other Linux distributions of software packages: http://nginx.org/en/linux_packages.html

2. log on to the terminal as a common user and import the GPG signing key.

$ sudo rpm --import "http://nginx.org/keys/nginx_signing.key"

3. install the software package downloaded in 1.

$ sudo yum install /home/sue/download/nginx-release-centos-7-0.el7.ngx.noarch.rpm

"/Home/sue/download/" is the path to save the software package.

4. Install the nginx Server

$ sudo yum install nginx

So far, if there is no accident, all the installation is complete, and the next step is to configure the server.

After nginx is installed, let's see where nginx is installed.

$ whereis nginx

After executing this command, the system prompts the following location:

Nginx:/usr/sbin/nginx/etc/nginx/usr/share/man/man3/nginx.3pm.gz/usr/share/man/man8/nginx.8.gz

Then we can easily know where the configuration file of the nginx server is located:/etc/nginx

Then we can view the configuration files in the directory:

$ cd /etc/nginx 
$ ls -l

After executing this command, we can see some file lists, but currently we only need to view the content of the "nginx. conf" file, which is the configuration file of the nginx Server:

$ cat -n nginx.conf

Note: If the selected nginx installation package is "Nginx for CentOS 6", the path of the configuration file may not be this path, maybe/etc/nginx/conf. d/default. conf path.

The configuration items above show that the default listening port of the server is port 80, and the server name (which can also be a domain name) is localhost (127.0.0.1 ), the root directory of the server is "/usr/share/nginx/html ". If the server starts normally, enter "localhost" or "127.0.0.1" in the address bar of the browser. The default homepage is displayed. Start the nginx Server:

$ sudo nginx

If an error is reported, run the following command after the previous command is executed:

$ sudo nginx -s reload

If no error is reported, open the browser and enter "127.0.0.1" in the address bar to view the following default homepage:

In addition, Nginx has the following common command line parameters:

  • Quit-Shut down the server normally
  • Stop-force server shutdown
  • Reload-reload the configuration file
  • Reopen-re-open the log file

So far, an nginx server that can host static pages has been installed, but it still cannot host Asp. Net Web applications. We still need to make some configuration. I will describe these configurations when using the Mono runtime to build an Asp. Net Mvc application on nginx.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.