CentOS 6.5 Source code installation Nginx1.6.3

Source: Internet
Author: User
Tags curl openssl file permissions
First, software configuration informationCentOS 6.5 nginx-1.6.3.tar.gz Second, the necessary software preparationCheck the installation Pcre,openssl,gzip command as follows:
Yum install zlib zlib-devel pcre pcre-devel OpenSSL openssl-devel
Third, create nginx users and Groups
[Root@localhost src]# groupadd nginx
[root@localhost src]# useradd-r-G nginx-s/sbin/nologin-m-Nginx
Four, download decompression
Nginx can be downloaded from the website: http://nginx.org/
can also be directly downloaded by command, my current directory is/usr/local/src:
[Root@localhost src]# wget http://nginx.org/download/nginx-1.6.3.tar.gz
Extract:
[Root@localhost src]# tar zxvf nginx-1.6.3.tar.gz 
[root@localhost src]# CD nginx-1.6.3
Five, start installation
[Root@localhost src]# cd nginx-1.6.3 [root@localhost nginx-1.6.3]#./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-pat h=/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-h Ttp_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_modul e \--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-file-aio \--with-http_spdy_module \--with-ipv6 \--with-pcre [root@localhost nginx-1.6.3]# make [root@localhost nginx-1.6.3]# make install
Six, start stopStart command:
[Root@localhost nginx-1.6.3]#/usr/sbin/nginx
Test to read Web information directly with the Curl command:
[root@localhost sbin]# curl-s http://localhost | grep nginx.com
Close command:
[Root@localhost nginx-1.6.3]#/usr/sbin/nginx-s Stop
Reload, when you modify the configuration, this command does not have to be restarted to take effect:
[Root@localhost nginx-1.6.3]#/usr/sbin/nginx-s Reload
Vii. Configure Nginx for system services
Add the following file:
Vi/etc/init.d/nginx
#!/bin/sh # # Nginx Startup script for Nginx # chkconfig:-# processname:nginx # config:/etc/nginx/nginx . conf # config:/etc/sysconfig/nginx # pidfile:/var/run/nginx.pid # Description:nginx is a HTTP and reverse proxy serve R # ### BEGIN INIT INFO # provides:nginx # required-start: $local _fs $remote _fs $network # required-stop: $local _fs $remo

Te_fs $network # Default-start:2 3 4 5 # default-stop:0 1 6 # Short-description:start and Stop nginx ### end INIT INFO
# Source function library. . /etc/rc.d/init.d/functions if [-L $]; Then initscript= '/bin/readlink-f $ ' else initscript=$0 fi sysconfig= '/bin/basename $initscript ' if [-f/etc/s ysconfig/$sysconfig]; Then. /etc/sysconfig/$sysconfig fi Nginx=${nginx-/usr/sbin/nginx} prog= '/bin/basename $nginx ' conffile=${conffile-/etc/ nginx/nginx.conf} Lockfile=${lockfile-/var/lock/subsys/nginx} Pidfile=${pidfile-/var/run/nginx.pid} SLEEPMSEC=${ SLEEPMSEC-200000} upgradewaitloops=${upgradewaitloops-5} REtval=0 start () {echo-n $ "starting $prog:" Daemon--pidfile=${pidfile} ${nginx}-C ${conffile} retval=$?
    echo [$RETVAL = 0] && Touch ${lockfile} return $RETVAL} stop () {echo-n $ "stopping $prog:"
    Killproc-p ${pidfile} ${prog} retval=$? echo [$RETVAL = 0] && rm-f ${lockfile} ${pidfile} reload () {echo-n $ "reloading $prog:" Killpr
    Oc-p ${pidfile} ${prog}-hup retval=$? echo} upgrade () {Oldbinpidfile=${pidfile}.oldbin Configtest-q | | Return echo-n $ "Starting new master $PR OG: "Killproc-p ${pidfile} ${prog}-USR2 echo for i in '/usr/bin/seq $UPGRADEWAITLOOPS '; Do/bin/usleep $SLEEPMSEC if [f ${oldbinpidfile}-a-f ${pidfile}];
            Then echo-n $ "graceful shutdown of old $prog: Killproc-p ${oldbinpidfile} ${prog}-quit
            Retval=$? echo return FI-done echo $ "Upgrade failed!"Retval=1} configtest () {if [" $# "-ne 0];
            Then case "$" in-q) flag=$1;;
        *)
                ;;
    Esac shift fi ${nginx}-t-c ${conffile} $FLAG retval=$?
Return $RETVAL} rh_status () {status-p ${pidfile} ${nginx}} # We are were.
    Case "$" in start Rh_status >/dev/null 2>&1 && exit 0 start;;
    stop) stop;;
        Status) Rh_status retval=$?
    ;; Restart) configtest-q | |
    Exit $RETVAL stop start;; Upgrade) rh_status >/dev/null 2>&1 | |
    Exit 0 upgrade;; Condrestart|try-restart) if Rh_status >/dev/null 2>&1;
    Then stop start fi;;
    Force-reload|reload) reload;;
    Configtest) configtest;; *) ECHo $ "Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}"
 "Retval=2 Esac exit $RETVAL
To modify file permissions:
chmod +x/etc/init.d/nginx

View Nginx Services:
Chkconfig--list Nginx
If the following text shows success: Nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If the following text appears: Service Nginx supports Chkconfig, but is isn't referenced in any runlevel (run ' chkconfig--add nginx ')
Execute the following command:
Chkconfig--add Nginx





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.