Linux Install Nginx (graphics and text tutorial) _linux

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

Nginx is a lightweight Web server. It is characterized by a small amount of memory, concurrency is strong, in fact, Nginx's concurrency ability does in the same type of Web server performance better. The following main introduction Linux installation Nginx.

Linux system for CentOS 64-bit

Brief introduction

First, Linux installation software common methods

1, RPM (or pkg) installation, similar to the Windows Installer, is a precompiled program.

    1. Generic parameter compilation is used, configuration parameters are not optimal
    2. Less controllable, such as customized installation of program-specific components
    3. Usually there are complex dependencies between the installation package, the operation is more complex
    4. Simple installation, low probability of error

2, yum (or apt-get) installation, improved version of RPM, automatic networking download installation package, automatic management of dependencies

3, the compilation installs (the way in each kind of Linux distribution edition difference is not big)

    1. Strong controllability, config can be based on the current system environment optimization parameters, customizable components and installation parameters
    2. Easy to make mistakes, slightly more difficult

Second, Nginx compile installation

1. Check and install dependencies

Yum-y install gcc pcre pcre-devel zlib zlib-devel OpenSSL openssl-devel

2, configure

3, make && make install

The detailed steps are as follows

The first step: Download the corresponding version from the http://nginx.org/download/(or wget http://nginx.org/download/nginx-1.9.9.tar.gz directly on Linux with the command)

Step Two: Decompression TAR-ZXVF nginx-1.9.9.tar.gz

Step three: Set the configuration information./configure--prefix=/usr/local/nginx, or do not perform this step, direct default configuration

Fourth Step:

Make compilation (making is the process of writing source files in various languages into executable files and various library files)

Make install installation (made install copy these compiled executables and library files to the appropriate location)

In the configuration information, that is, in the third step, there is an error:
Error:./configure:error:the HTTP Rewrite module requires the PCRE library.

Install pcre-devel solve problems

Yum-y Install Pcre-devel

It is also possible to appear:

Error tip:./configure:error:the HTTP Cache module requires MD5 functions
From OpenSSL Library. Can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or builds the OpenSSL library statically from the source with Nginx by using
--with-http_ssl_module--with-openssl=<path> Options.

Solution:

Yum-y Install OpenSSL Openssl-devel

Start and close Nginx on Linux after installation:

Start action

/usr/local/nginx/sbin/nginx (/usr/local/nginx/sbin/nginx-t to see if the configuration information is correct)

Stop operation

The stop operation is done by sending a signal to the nginx process (what is a signal refer to a Linux article)

Step 1: Query Nginx main process number
Ps-ef | grep nginx
In the process list, look for the master process, which is numbered as the main process number.

Step 2: Send a signal
Calmly stop Nginx:
Kill-quit Main process Number
Quick Stop Nginx:
Kill-term Main process Number
Force Stop Nginx:
Pkill-9 Nginx

In addition, if the nginx.conf configured PID file storage path, the file is stored in the Nginx main process number, if not specified then placed in the Nginx logs directory. With the PID file, we do not need to first query the main process number of the nginx, but directly to the nginx send a signal, the command is as follows:
Kill-Signal type '/usr/local/nginx/logs/nginx.pid '

Smooth reboot

If you change the configuration, restart the Nginx, turn off Nginx before you open it? No, you can send a signal to the nginx, smooth reboot.

Smooth Restart command:
Kill-hup live in the title or process number file path
or use

/usr/local/nginx/sbin/nginx-s Reload

Note that after modifying the configuration file, it is best to check that the modified profile is correct so that the Nginx error affects the stable operation of the server after the reboot. Judge

The Nginx configuration is correctly ordered as follows:

Nginx-t-c/usr/local/nginx/conf/nginx.conf

Or

/usr/local/nginx/sbin/nginx-t

The following figure:
Down to configure environment variables

Add in/etc/profile:

Export Nginx_home=/usr/local/nginx
Export Path=path:path:nginx_home/sbin

Save

Perform source/etc/profile to make the configuration file effective.
Execute nginx-v, you can see the version, indicating that Nginx installation was successful

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.