CentOS7 compiling and installing nginx-1.8.1 and compiling parameters

Source: Internet
Author: User

Web server Nginx

LNMP is a well-known set of Web site server architecture environments, which is a high-performance, lightweight, stable, and extensible Web Site Server architecture environment that is combined by linux+nginx+mysql+php (sometimes referred to as MySQL Mariadb).

Nginx ("Engine X") as a Web server software, is a lightweight, high-performance HTTP and reverse proxy server, load balancer server, and e-mail imap/pop3/smtp server. Nginx performance is stable, feature-rich, simple operation, high efficiency, strong concurrency, processing static files faster and consumes less system resources.


Version of Nginx

Nginx version is divided into the main version and stable version, the main version of the update faster, from the official online to see About one months update 1-2 times, the latest main version has been updated to nginx-1.9.10, and the official announcement of the latest stable version is Nginx-1.8.1,and this article to 1.8.1 Example shows the installation and configuration process on the CentOS7. Nginx official website http://nginx.org/.


Nginx Dependent Program

1. Zlib: Used to support gzip module

2. Pcre: for supporting rewrite module

3. OpenSSL: Used to support SSL function

Installing Zlib, Pcre, OpenSSL packages with Yum

[email protected] ~]# Yum install zlib pcre pcre-devel OpenSSL openssl-devel


Installation of Nginx-1.8.1

Step1: Create Nginx User

Create an Nginx running user

[[email protected] ~]# useradd-s/sbin/nologin nginx[[email protected] ~]# ID nginxuid=1000 (nginx) gid=1001 (nginx) groups =1001 (Nginx)


Step2:nginx Compilation parameters

--user specify the user to which the initiator belongs

--group Specifying groups

--prefix Specifying the installation path

--sbin-path set the path name of the Nginx binary file

--conf-path specifying the configuration file path

--error-log-path Error log file path

--http-log-path specifying access log file path

--http-client-body-temp-path setting the temporary file path for storing HTTP client request principals

--http-proxy-temp-path setting the path to store HTTP proxy temporary files

--http-fastcgi-temp-path setting the path to a temporary file that stores HTTP fastcgi

--pid-path Setting the Nginx.pid file path

--lock-path Setting the Nginx.lock file path

--WITH-OPENSSL Enable SSL

--with-pcre Enable regular expressions

--with-http_stub_status_module installing modules that can monitor nginx status

--with-http_ssl_module Enable SSL Support

--with-http_gzip_static_module Enable gzip compression


[Email protected] nginx-1.8.1]#/configure--user=nginx--group=nginx--prefix=/opt/nginx--sbin-path=/usr/sbin/ Nginx--conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log--http-log-path=/var/log/nginx/ Access.log--http-client-body-temp-path=/tmp/nginx/client_body--http-proxy-temp-path=/tmp/nginx/proxy-- http-fastcgi-temp-path=/tmp/nginx/fastcgi--pid-path=/var/run/nginx.pid--lock-path=/var/lock/subsys/nginx-- With-http_stub_status_module--with-http_ssl_module--with-http_gzip_static_module--with-pcre--with-http_realip_ Module--with-http_sub_module

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7A/9D/wKiom1at9_ag4x_LAABXk3WxLb4920.png "title=" 3.png " alt= "Wkiom1at9_ag4x_laabxk3wxlb4920.png"/>

[[email protected] nginx-1.8.1]# Make[[email protected] nginx-1.8.1]# make install


Make installation complete use Nginx-v to view version and compile parameters

[[Email protected] nginx-1.8.1]# nginx -v nginx version: nginx/1.8.1built  by gcc 4.8.3 20140911  (red hat 4.8.3-9)   (GCC)  built with  OpenSSL 1.0.1e-fips 11 Feb 2013TLS SNI support enabledconfigure  Arguments: --user=nginx --group=nginx --prefix=/opt/nginx --sbin-path=/usr/sbin/nginx  --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/ Var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path= /tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid -- lock-path=/var/lock/subsys/nginx --with-http_stub_status_module --with-http_ssl_module -- With-http_gzip_static_module --with-pcre --with-http_realip_module --with-http_sub_module

View Ngin processes and port numbers

[Email protected] ~]# NETSTAT-NTLP | grep nginxtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4415/nginx:master


Step3: Command to control Nginx service

1, start: nginx

2. Stop: Nginx-s stop

3. Exit: Nginx-s quit

4. Restart: nginx-s reopen

5. Reload: Nginx-s Reload

6. Smooth start: kill-hup pid (kill-hup ' Cat/var/run/nginx.pid ')


Step4: Creating an Nginx startup script

#!/bin/bash# chkconfig: - 18 21# description: http service.# source  function library. /etc/init.d/functions# nginx settingsnginx_sbin= "/usr/sbin/nginx" nginx_conf= "/etc/nginx/nginx.conf" nginx_pid= "/var/run/nginx.pid" retval=0prog= "Nginx" #Source  networking  configuration. /etc/sysconfig/network# check networking is up[ ${ networking} =  "No"  ] && exit 0[ -x  $NGINX _sbin ] | |  exit 0start ()  {        echo -n $ "Starting   $prog:  "        touch /var/lock/subsys/nginx         daemon  $NGINX _sbin -c  $NGINX _conf         RETVAL=$?        echo         return&nbsp, $RETVAL}stop ()  {        echo -n $ "Stopping $ prog:  "        killproc -p  $NGINX _pid  $NGINX _sbin  -term        rm -rf /var/lock/subsys/nginx /var/ run/nginx.pid        retval=$?         echo        return  $RETVAL}reload () {         echo -n $ "reloading  $prog: "          killproc -p  $NGINX _pid  $NGINX _sbin -hup         RETVAL=$?        echo         return  $RETVAL}restart () {        stop      &nBsp;  start}configtest () {     $NGINX _sbin -c  $NGINX _conf -t     return 0}case  "$"  in  start)          start        ;;   stop)         stop         ;;   reload)         reload         ;;   restart)         restart         ;;   configtest)         configtest         ;;   *)         echo $ "usage: $0 {start|stop| Reload|restart|configtest} "        RETVAL=1esacexit  $RETVAL

Set boot up

[[email protected] ~]# chmod 755/etc/init.d/nginx[[email protected] ~]# chkconfig--add nginx[[email protected] ~]# CHKCO Nfig nginx on[[email protected] ~]# service Nginx stopstopping nginx (via Systemctl): [OK] [ [Email protected] ~]# service Nginx startstarting nginx (via Systemctl): [OK]



Set up firewall rules to allow external access to port 80

[Email protected] ~]# firewall-cmd--permanent--add-port=80/tcp[[email protected] ~]# firewall-cmd--reload


STEP5: Test Access

In the browser input http://Your-IP/

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7A/9D/wKioL1auDh6hO_3HAABi7VcVaEU221.png "title=" 6.png " alt= "Wkiol1audh6ho_3haabi7vcvaeu221.png"/>






CentOS7 compile and install nginx-1.8.1 and compile parameters

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.