Welcome to Nginx (1) Installing Nginx under Linux

Source: Internet
Author: User
Tags openssl library
Nginx relies on a few repositories, before installing it, make sure the system has GCC, SSL, PCRE and gzip software installed, and you can use the RPM-Q command to see if the software is installed.

[Root@redhat1 ~]# rpm-q Gccgcc-4.1.2-44.el5

The dependent library information is as follows:

(1). Gzip module requires zlib library (download: http://www.zlib.net/)
(2). Rewrite module requires pcre library (download: http://www.pcre.org/)
(3). The SSL feature requires the OpenSSL library (download: http://www.openssl.org/)

If you install Pcre, download pcre to the destination directory, the version chosen here is pcre-8.38, after downloading, do the following:

TAR-ZXVF pcre-8.38.tar.gz   cd pcre-8.38./configuremakemake Install

Install Nginx, execute the following command

By default, the compiled and installed Nginx already contains most of the available modules and can be used with the "./configure--help" option to set the usage of each module, for example, for Http_ssi modules that are not needed, through the--without-http_ssi_ Module "parameter, if you need the" Http_perl "module, you can install the module through the"--with-http_perl_module "parameter. Perform the following actions to install.

TAR-ZXVF nginx-1.11.1.tar.gzcd nginx-1.11.1./configure--with-pcre=. /pcre-8.38--prefix=/usr/local/nginx Makemake Install   

To detect if the installation was successful, execute the following command

[Root@redhat1 sbin]# cd/usr/local/nginx/sbin[root@redhat1 sbin]#./nginx-t
The following information appears to prove that the installation was successful
Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is oknginx:configuration file/usr/local/nginx/ Conf/nginx.conf Test is successful
Start Nginx
[Root@redhat1 sbin]#./nginx
View ports
[Root@redhat1 sbin]# NETSTAT-NTLP
The results are as follows:
Proto recv-q send-q Local address Foreign address State Pid/program name TCP 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 2993/hpiod TCP 0 0 0.0.0.0:834 0.0.0.0:* LISTEN 2772/rpc.s TATD TCP 0 0 0.0.0.0:11111 0.0.0.0:* LISTEN 3391/ricci TCP 0 0 0.0.0.0   : 111 0.0.0.0:* LISTEN 2733/portmap TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3852/nginx TCP 0 0 0.0.0.0:16851 0.0.0.0:* LISTEN 3290/modclusterd TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3024/cupsd TCP 0 0 127.0.0.1:25 0.0.0.0:* L        Isten 3057/sendmail:acce TCP 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN 2998/python TCP 0 0::: $:::* LISTEN 3013/sshd
You can also enter: http://localhost in the browser to verify that the startup was successful.

Stop Nginx

The stop operation is done by sending a signal to the nginx process.

Step 1: Query the Nginx main process number:

Ps-ef | grep nginx
Find the master process in the list of processes, whose number is the main process number.

Step 2: Send a signal

Calmly stop Nginx:kill-quit master process number

Fast Stop Nginx:kill-term main process number

Force Stop nginx:pkill-9 Nginx

Restart Nginx: Smooth restart

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

Smooth Restart command:
Kill-hup live in the title or process number file path or/usr/local/nginx/sbin/nginx-s reload

Note that after modifying the configuration file, it is best to check the correct configuration file, so as not to restart after the Nginx error affecting the stable operation of the server. Determine if the Nginx configuration is the correct command as follows:
Nginx-t-c/usr/local/nginx/conf/nginx.conf or/usr/local/nginx/sbin/nginx-t

The above describes the Welcome to Nginx (1) Linux installation Nginx, including the content of Welcome to Nginx, I hope that the PHP tutorial interested in a friend helpful.

  • 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.