Install and install Nginx under Linux 6

Source: Internet
Author: User
Tags imap openssl library

Nginx is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP server. In the case of high connection concurrency, Nginx is a good alternative to Apache server: Nginx in the United States is a virtual hosting business owners often choose one of the software platform. Capable of supporting up to 50,000 concurrent connections, with minimal memory overhead. This is also an important reason for nginx to be popular. This article demonstrates the installation of Nginx based on Linux 6, for your reference.

First, installation environment

# cat /etc/issue6.3onan \m# nginx -vversion: nginx/1.8.0

Second, configure the installation environment

###为简化安装及配置,此处关闭了防火墙,生产环境建议开启# service iptables stop# chkconfig iptables off# vi /etc/selinux/config SELINUX=disabled###创建用户及组#groupadd -r nginx#useradd -s /sbin/nologin -g nginx -r nginx###安装环境依赖包 http://nginx.org/en/linux_packages.html# yum install pcre-devel zlib-devel openssl openssl-devel gcc gcc-c++

Third, compile and install Nginx

# cd/tmp/# TAR-XVF nginx-1.8.0.tar.gz# cd/nginx-1.8.0#./configure \--prefix=/etc/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 \--pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-mail \--with-mail_ssl_module \--with-file-aio \--with-http_spdy_module \--with-ipv6Configuration Summary + using System PCRE Library + using System OpenSSL library + md5:using OpenSSL library + SHA1:  Using OpenSSL library + using System zlib library nginx Path prefix: "/etc/nginx" nginx binary file: "/usr/sbin/nginx" Nginx configuration prefix: "/etc/nginx" Nginx configuration file: "/etc/nginx/nginx.conf" nginx pid file: "/var/run/ng  Inx.pid "Nginx error log file:"/var/log/nginx/error.log "Nginx http access log file:"/var/log/nginx/access.log "Nginx HTTP client request body Temporary files: "/var/cache/nginx/client_temp" nginx http proxy temporary files: "/var/cache/n Ginx/proxy_temp "Nginx http fastcgi temporary files:"/var/cache/nginx/fastcgi_temp "Nginx http uwsgi temporary files:" /var/cache/nginx/uwsgi_temp "Nginx http scgi temporary files:"/var/cache/nginx/scgi_temp "# # #如果apache httpd service startup, It is recommended to stop or change the port number # service httpd stop# mkdir-p/var/cache/nginx/{client_temp,proxy_temp,fastcgi_temp,uwsgi_temp,scgi_temp }# make && make install## #启动nginx#/usr/sbin/nginx-c/etc/nginx/nginx.conf# ps-ef|grep nginx|grep-v greproot 33412 1 0 10:18?        00:00:00 nginx:master process/usr/sbin/nginx-c/etc/nginx/nginx.confnginx 33413 33412 0 10:18? 00:00:00 nginx:worker process[root@orasrv1 cache]# netstat-nltp|grep 80tcp 0 0 0.0.0.0:80 0  .0.0.0:* LISTEN 33412/nginx [Root@orasrv1 cache]#

Iv. Configuring Nginx for system service

Vi/etc/init.d/nginx#!/bin/bash# nginx Startup script for the Nginx HTTP Server# Chkconfig:- about# Description:nginx is an HTTP (s) server, HTTP (s) reverse \# Proxy and IMAP/POP3 proxy server# Author:leshami# Blog:http://blog.csdn.net/leshami# Processname:nginx# Pidfile:/var/run/nginx.pid# config:/etc/nginx/nginx.conf#path for Nginx binaryNginxd=/usr/sbin/nginx#path for Nginx configurationNginx_c/nginx/nginx.conf#path for Nginx pidNginx_pid=/var/run/nginx.pidretval=0prog="Nginx"# Source function library.. /etc/rc.d/init.d/functions# Source Networking configuration.. /etc/sysconfig/network# Check that networking are up.[${networking}="No"] &&Exit0[-X$nginxd] ||Exit0# Start Nginx daemons functions.Start() {if[- e$nginx _pid]; ThenEcho"Nginx already running ..."Exit1fiEcho-N $"Starting $prog:"Daemon$nginxd-C${nginx_config}Retval=$?Echo[$RETVAL=0] && Touch/var/lock/subsys/nginxreturn$RETVAL}# Stop Nginx daemons functions.Stop() {Echo-N $"Stopping $prog:"Killproc$nginxdRetval=$?Echo[$RETVAL=0] && RM- F/var/lock/subsys/nginx/var/run/nginx.pid}# Reload Nginx service functions.Reload() {Echo-N $"Reloading $prog:"#kill-hup ' cat ${nginx_pid} 'Killproc$nginxd-hup retval=$?Echo}# See how we were called. Case"$"inchStart) Start; stop) stop;; reload) reload;; restart) stop start;; Status) status$progRetval=$? ;; *)Echo$"Usage: $prog {start|stop|restart|reload|status|help}"Exit1EsacExit$RETVAL# chmod U+x/etc/init.d/nginx# service Nginx startStarting nginx: [OK]# ps-ef|grep Nginx |grep-v grepRoot3353410Ten: -?xx:xx:xxNginx:master process/usr/sbin/nginx-c/etc/nginx/nginx.confnginx33535335340Ten: -?xx:xx:xxNginx:worker process# service Nginx Stopstopping nginx: [OK]# chkconfig--add nginx# chkconfig Nginx on

Five, the installation process of common failures

./configure:error: theHTTP Rewrite module requires thePCRE Library. You can either disable theModule byusing--without-http_rewrite_moduleOptionorInstall thePCRE Library into thesystem,orBuild thePCRE librarystatically from theSource withNginx byusing--with-pcre= 
    
     option. 
    ./configure:error: theHTTP gzip module requires theZlib Library. You can either disable theModule byusing--without-http_gzip_moduleOptionorInstall theZlib Library into thesystem,orBuild theZlib librarystatically from theSource withNginx byusing--with-zlib= 
    
     option. 
    # # # 2 Error, please install the corresponding dependency package, see the second part of this article: Configure the installation Environment#/usr/sbin/nginxNginx: [Emerg] Getpwnam ("Nginx") failed# # # needs to create Nginx user groups and users#/usr/sbin/nginxNginx: [Emerg] mkdir ()"/var/cache/nginx/client_temp"Failed (2: No SuchfileorDirectory)# # # needs to create the corresponding directory

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the installation and installation of Linux 6 installed Nginx, including the content, I hope that the PHP tutorial interested in a friend helpful.

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