How to install Nginx_nginx under Aliyun CentOS

Source: Internet
Author: User
Tags install openssl openssl openssl library centos aliyun

Nginx ("Engine X") is a lightweight HTTP and reverse proxy server. Compared with Apache and LIGHTTPD, it has advantages of less memory, stronger concurrency and higher stability. its most common use is to provide a reverse proxy service.

Under Linux we need to download Nginx source code packages and compile them manually, instead of installing them with package management tools such as Yum and aptitude. Because we need to configure the Nginx at compile time, we have to compile it manually, which will also depend on some tools and library files.

first, you need to install the C language's compilation environment, because Nginx is written in C language. Typically, most Linux installs GCC by default, and if not, it can be installed as follows.

Install Make:

Yum-y install gcc automake autoconf libtool make

Install g++:

Yum Install gcc gcc-c++

Pcre Library:

Nginx requires Pcre (Perl compatible Regular Expression), because nginx regular expression syntax is used by both rewrite modules and HTTP core modules. Its download address is http://www.pcre.org/, we can also install by Yum.

Yum Install Pcre Pcre-devel

As shown above, the prompts are installed.

Zlib Library:

The Zlib library provides a compression algorithm that nginx many places using the gzip algorithm. The download address is http://www.zlib.net/, or it can be installed through Yum.

Yum Install zlib Zlib-devel

If the above is not installed or not the latest package.

Openssl:

Nginx If the server provides a secure page, you need to use the OpenSSL library. The download address is http://www.openssl.org/, or it can be installed through Yum.

Yum Install OpenSSL Openssl-devel

Download Nginx:

Nginx Source packages can be downloaded from the official website http://nginx.org/en/download.html, the latest stable version is 1.10.1, and there is a development version to choose from. The relevant commands are as follows:

wget https://nginx.org/download/nginx-1.10.1.tar.gz
Tar zxf nginx-1.10.1.tar.gz
CD NGINX-1.10.1/

Install Nginx:

Configuration is required prior to installation, which is a common step in installing software under Linux. Initial installation can use the Configure script directly, if need to set the switch option to open the required function module, here is not expanded. The relevant commands are as follows:

./configure
Make
Make install

Run Nginx:

Nginx will be installed by default in the/usr/local/nginx directory, we CD to the/usr/local/nginx/sbin/directory, there is a nginx binary executable file. Run directly to start Nginx. After running successfully, open the browser to access the IP of this machine, the following screen is successful.

Nginx Related commands:

Nginx-h-------------------------> Help command

Nginx-s Stop-------------------------> Stop daemon immediately (term signal)

Nginx-s quit-------------------------> Gentle stop daemon (quit signal)

Nginx-s reopen-------------------------> Reopen log files

Nginx-s Reload-------------------------> Reload configuration file

NGINX-T-------------------------> Test configuration file is legal

Killall Nginx-------------------------> forcibly terminate nginx process

Because any nginx command checks the configuration file for legality, the command does not execute if the profile is illegal, and the killall command avoids the inability to stop the Nginx service.

The Nginx configuration file has its own unique syntax and is not expanded here.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.