First, Nginx Introduction and installation

Source: Internet
Author: User
Tags openssl library server website syslog

First, Nginx Introduction:

Nginx is a free, open source, high performance and lightweight HTTP server and reverse proxy server. Nginx is known for its high-performance, stable, feature-rich, simple configuration and low system resource utilization. Nginx beyond the performance and stability of Apache, so that the domestic use of Nginx as a Web server website is also more and more.

Note: Nginx and Apache have advantages and disadvantages, in general, static and reverse proxy, the first choice nginx.

Second, install Nginx:

1. System Platform CentOS 6.5:

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/6F/FE/ Wkiom1wvmd3hrlblaabdn3oabio686.jpg "" 246 "height="/>

2. Install the dependent package or you cannot compile the installation:

Yum groupinstall-y "Development tools" "Server Platform Development" "Desktop Platform Development" Yum Install-y pcre-d Evel

1) to create user Nginx and group Nginx, to implement the user Nginx run Nginx:

[[email protected] ~]# groupadd-r nginx    #nginx需要调用1000以下的端口, requires system users [[email protected] ~]# useradd-r-G nginx nginx[[e Mail protected] ~]# ID nginxuid=496 (nginx) gid=493 (nginx) groups=493

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/6F/FB/ Wkiol1wvmihxlvr-aabzutjockc570.jpg "" 359 "height="/>

2) Unzip the installation package, install files can download the installation files in www.nginx.org:

[[email protected] ~]# lsanaconda-ks.cfg install.log nginx-1.9.3.tar.gz temp.text While.pyharlequin.vim Install.log.syslog readme.md tet[[email protected] ~]# tar xf nginx-1.9.3.tar.gz [[email protected] ~]# lsanaconda-ks.cfg install.log nginx-1.9.3 readme.md tetharlequin.vim install.log.syslog nginx-1. 9.3.tar.gz Temp.text while.py[[email protected] ~]# cd nginx-1.9.3[[email protected] nginx-1.9.3]# MKDIR-PV /var/tmp/nginx/clientmkdir:created directory '/var/tmp/nginx ' mkdir:created directory '/var/tmp/nginx/client ' [[ Email protected] nginx-1.9.3]#/configure >--prefix=/usr/local/nginx \ >--sbin-path=/usr/local/nginx/s Bin/nginx >--conf-path=/etc/nginx/nginx.conf >--error-log-path=/var/log/nginx/error.log >--http-log-path =/var/log/nginx/access.log >--pid-path=/var/run/nginx/nginx.pid >--lock-path=/var/lock/nginx.lock >--us Er=nginx >--group=nginx >  --with-http_ssl_module >--with-http_flv_module >--with-http_stub_status_module >--with-http_gzip_stati C_module >--http-client-body-temp-path=/var/tmp/nginx/client/>--http-proxy-temp-path=/var/tmp/nginx/proxy />--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/>--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi >--HTTP-SC gi-temp-path=/var/tmp/nginx/scgi >--with-pcre

Options

Description

--prefix=<path>

Specifies the Nginx installation path, which by default is in/usr/local/nginx

--sbin-path=<path>

Specifies the Nginx executable installation path, which is installed by default in <prefix>/sbin/nginx

--conf-path=<path>

Specifies the default nginx.conf path, which is the default in <prefix>/conf/

--error-log-path=<path>

Specify the default error log path if Error_log is not specified under Nginx.conf

--http-log-path=<path>

Specify the default error log path if Http_log is not specified under Nginx.conf

--pid-path=<path>

Specify the Nginx.pid path if the PID directive is not specified by the nginx.conf
--lock-path=<path> Specify the Nginx.lock path
--user=<user> Specifies that the Nginx service runner is not specified and defaults to Nobady
--group=<group> Specifies that the Nginx service runner is not specified and defaults to Nobady
--with-http_ssl_module Enable Ssl,nginx to support HTTPS, but the system must have a OpenSSL library
--with-http_flv_module Enable FLV module
--with-http_stub_status_module Enable the Server Status page
--with-http_gzip_module Disabling the gzip module is enabled by default, but requires the zlib library
--http-client-body-temp-path=<path> The temporary file path that holds the HTTP client request message, does not exist by default and needs to be created in advance
--http-proxy-temp-path=<path> Enable proxy module, specify HTTP proxy temporary file path, default does not exist, need to be created in advance
--http-fastcgi-temp-path=<path> HTTP-enabled FASTCGI module that specifies the path to the temporary file for the FastCGI module, which does not exist by default and needs to be created in advance
--http-uwsgi-temp-path=<path> HTTP-enabled UWSGI module that specifies the path to the temporary file for the Uwsgi module, which does not exist by default and needs to be created in advance
-with-pcre Specify the Pcre library to be installed in advance Pcre-devel
--http-scgi-temp-path=<path> HTTP-enabled SCGI module that specifies the path to the temporary file for the scgi module, which does not exist by default and needs to be created in advance
Run make && make install
3) Create the service script: Vim/etc/rc.d/init.d/nginx, write the following script: (explain the script, some paths are written according to the Configer option above)
#!/bin/sh## nginx-this script starts and stops the Nginx daemin## chkconfig:-15# Description:nginx is a HTTP (s) s Erver, HTTP (S) Reverse # Proxy and imap/pop3 proxy server# processname:nginx# config:/etc/nginx/nginx.conf# pidfile:/va r/run/nginx/nginx.pid# Source Function Library: /etc/rc.d/init.d/functions# Source Networking configuration: /etc/sysconfig/network# Check that networking are up. ["$NETWORKING" = "no"] && exit 0nginx= "/usr/local/nginx/sbin/nginx" prog=$ (basename $nginx) nginx_conf_file= "/ Etc/nginx/nginx.conf "Lockfile=/var/lock/subsys/nginxstart () {[x $nginx] | | Exit 5[-F $NGINX _conf_file] | | exit 6echo -N $ "Starting $prog:" Daemon $nginx-C $NGINX _conf_fileretval=$?echo[$retval-eq 0] && touch $lockfilereturn $re Tval}stop () {echo-n $ "stopping $prog:" Killproc $prog-quitretval=$?echo[$retval-eq 0] && rm-f $lockfileretur n $retval}restart () {configtest | | return $?stopstart}reload () {configtest | | return $?echo-n $ "reloading $pRog: "Killproc $nginx-hupretval=$?echo}force_reload () {restart}configtest () {$nginx-T-C $NGINX _conf_file}rh_status ( {Status $prog}rh_status_q () {rh_status >/dev/null 2>&1}case "$" instart) rh_status_q && exit 0$1; Stop) rh_status_q | | Exit 0$1;; Restart|configtest) \ n; Reload) Rh_status_q | | Exit 7$1;; Force-reload) force_reload;; status) Rh_status;; Condrestart|try-restart) rh_status_q | | Exit 0;; *) echo $ "Usage: $ start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" Exit 2esac
Add permissions to script: chmod +x/etc/rc.d/init.d/nginx Add boot: chkconfig–add nginxchkconfig nginx on4) Add environment variable: # echo "path= $PATH:/usr/ Local/nginx/sbin ">>/etc/profile (Permanent entry into force) #export path= $PATH:/usr/local/nginx/sbin (currently in force)

5) test and start:

Before starting, pass the NGINX-T test

[Email protected] nginx-1.9.3]# nginx-tnginx:the configuration file/etc/nginx/nginx.conf syntax is Oknginx:configurat Ion file/etc/nginx/nginx.conf test is successful[[email protected] nginx-1.9.3]# service Nginx startstarting nginx:                                            [  OK  ]

3. Website visit Nginx, view the server IP address, the browser directly enter the corresponding IP address, nginx default port 80.

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/6F/FB/ Wkiol1wvmilqco0gaaic0hhxuhw121.jpg "" 817 "height=" 386 "/>

Note: Enter IP, not shown, please check if Iptables is on.

Close Iptables:service iptables Stop

First, Nginx Introduction and installation

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.