Experimental environment:centos 6.6 "This node IP is 172.16.3.101" configured yum source "can be the Yum source point to Sohu or Ali Mirror site, can also be their own CD-ROM" compiled installation configuration nginx1.6# It is best to install the following packages before installation [[Email protected] httpd-2.2.29]# yum grouplist | grep -i ' Develop ' Additional Development Development tools server platform development desktop platform development# Installation method as follows:yum groupinstall ' additional development ' ' development tools ' ' Server platform development ' ' desktop platform development ' # Get nginx1.6 Binary source format installation package can go to the following link to download the source installation package, I use the 1.6,http://nginx.org/en/download.html# decompression tar xf nginx-1.6.2.tar.gzcd nginx-1.6.2# because Nginx needs nginx system user to start, so here need to create system user nginxuseradd -r nginx# Installation Trilogy # ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf -- user=nginx --group=nginx --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 --with-http_ssl_module --with-http_stub_ Status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_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/fastcgi--prefix# nginx installation directory--conf-path# Nginx configuration file path--user # Specifies the system user--group # to start Nginx and specifies the system group to start the Nginx--error-log-path# Error log file path--http-log-path # access log path--pid-path # pid file path--lock-path # Lock file path--with-http_ssl_module# enable SSL module--with-http_stub_status_module# enable Stub_status_ Module Modules--with-http_gzip_static_module # Enable Gzip_static_module module--with-http_flv_module # Enable streaming media module--with-http_mp4_module # enable MP4 streaming Media module--http-client-body-temp-path # Client Request packet body temporary file path --http-proxy-temp-path# message reverse proxy temporary file path--http-fastcgi-temp-path# Message fastcgi Temporary file path makemake install # Add PATH environment variable vim /etc/profile.d/nginx.sh# Add the following statement to the inside Export path=/usr/local/nginx/sbin: $PATH # and then source a bit . /etc/profile.d/nginx.sh# Check the Nginx configuration file for syntax [[email protected] nginx-1.6.2]# nginx -tnginx: the Configuration file /etc/nginx/nginx.conf syntax is oknginx: [emerg] mkdir () "/var/tmp/nginx/client" failed (2: no such file or directory) Nginx: configuration file /etc/nginx/nginx.conf test failed# the syntax for its configuration file from the above is OK but, Some directories are not created automatically when you compile the installation configuration nginx, you need to manually create their directories # create a directory mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi}# Check again [[Email protected] nginx-1.6.2]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful# can see its syntax ok# start nginxnginx# See if Port 80 is on ss -tnl# or you can see the nginx process details Ps aux | grep nginx provides sysv init script: # new file for Nginx/etc/rc.d/ init.d/nginx.confvim /etc/rc.d/init.d/nginx.conf# Add the following content to the inside #!/bin/sh## nginx - this script starts and stops the nginx daemon## chkconfig: - 85 15 # description: nginx is an http (S) server, http (S) reverse # proxy and IMAP/POP3 proxy server# processname: nginx# config: /etc/nginx/nginx.conf# config: /etc/sysconfig/nginx# piDfile: /var/run/nginx.pid # source function library. /etc/rc.d/init.d/functions # source networking configuration. /etc/sysconfig/network # check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx= "/usr/local/nginx/ Sbin/nginx "prog=$ (basename $nginx) nginx_conf_file="/usr/local/nginx/nginx.conf " [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/ Subsys/nginx make_dirs () { # make required directories user= ' nginx -v 2>&1 | grep "configure arguments:" | sed ' s/[^*]*--user=\ ([^ ]*\). */\1/g ' -' options= ' $nginx -v 2>&1 | grep ' configure arguments: ' for opt in $options; do if [ ' echo $opt | grep '. *-temp-path ' ]; then value= ' echo $opt | cut -d "=" -f 2 ' if [ ! -d "$value" ]; then # echo "Creating" $value mkdir -p $value && chown -R $user $value fi fi done} start () { [ -x $nginx ] | | exit 5 [ -f $NGINX_conf_file ] | | exit 6 make_dirs echo -n $ "Starting $ prog: " daemon $nginx -c $NGINX _conf_file retval=$? echo [ $retval -eq 0 ] & & touch $lockfile return $retval} stop () { echo -n $ "stopping $prog: " killproc $prog - quit retval=$? echo [ $retval - eq 0 ] && rm -f $lockfile return $retval} restart () { configtest | | return $? stop sleep 1 Start} reload () { configtest | | return $? echo -n $ "reloading $prog: " killproc $nginx -hup retval=$? 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 "$" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q | | exit 0 $1 ;; &nBsp; restart|configtest) $1 ;; reload) rh_status_q | | exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q | | exit 0 ;; *) echo $ "Usage: $0 { Start|stop|status|restart|condrestart|try-restArt|reload|force-reload|configtest} " exit 2esac# note here , navigate to the following line nginx_conf_file= "/usr/local/nginx/nginx.conf" # modify it as follows: mainly to modify the configuration file path nginx_conf_file= "/etc/nginx/ Nginx.conf "# then give it Execute permissions chmod u+x /etc/nginx/nginx.conf# add to Chkconfig list [email protected ] nginx]# chkconfig --list nginxservice nginx supports chkconfig, but is not referenced in any runlevel (run ' chkconfig --add Nginx ') [[email protected] nginx]# chkconfig --add nginx# start Nginx service service nginx start# can see that port 80 has already opened the ss -tnl# test, which is now entered in the remote browser:http://172.16.3.101# If you see the welcome message of Nginx, the installation is successful (^_^), otherwise, it is unsuccessful. Set syntax highlighting for nginx configuration files and code Auto Indent syntax highlighting is really good. vim /etc/nginx/nginx.conf# you can see the file contents without syntax highlighting at this time # Get Nginx.vim file http://www.vim.org/scripts/script.php?script_id=1886 because the official website is not easy to login, I have put it in the attachment, the need for students can download # Create Directory ~/.vim/syntax/, then put the Nginx.vim in it mkdir ~/.vim/syntaxmv nginx.vim ~/.vim/systaxvim ~/.vim/filetype.vim# Add the following content to it au bufread,bufnewfile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == ' | setfiletype nginx | endif # where/etc/nginx is the Nginx configuration file directory # Save Exit # At this point to open the/etc/nginx/nginx.conf file, you can see the contents of the syntax is highlighted # can also format the/etc/nginx/nginx.conf file automatically indent vim /etc /nginx/nginx.conf# then enter GG, then enter =, and then enter g# through the above operation can see, the code indentation becomes very canonical elinks simple usage:# install its installation package yum -y install elinks# the software is a text-mode browser # can be accessed by the following ways elinks http://127.0.0.1/ # does not return directly to # following this way, you can output the access results to the screen directly [[email protected] ~]# elinks -dump http://localhost/ Welcome to nginx! if you see this page, the nginx web server is successfully installed and working. further configuration is Required. for online documentation and support please refer  TO [1]NGINX.ORG.   COMMERCIAL SUPPORT IS AVAILABLE AT [2] Nginx.com. thank you for using nginx. References visible links 1. http://nginx.org/ 2. http://nginx.com/
This article is from the "You Devil" blog, please be sure to keep this source http://599184429.blog.51cto.com/5147223/1596582
Compile and install the configuration nginx1.6 and some of its basic configuration, etc.