1, installation of Nginx and related components 1.1 openssl installation # problems make[2]: *** [md5-x86_64.o] error 1make[2]: leaving directory '/root/lamp/openssl-0.9.8e/crypto/md5 ' make[1]: *** [subdirs] error 1make[1]: Leaving directory '/root/lamp/openssl-0.9.8e/crypto ' make: *** [build_ crypto] error 1# download higher version can solve the above problem, here I was openssl-1.0.1a.tar.gz1.2 pcre installation # problem: Make[1]: *** [/usr/local/pcre//Makefile] Error 127configure configuration via./configure --prefix=/ usr/local/nginx --with-pcre=/usr/local/pcre/ --with-openssl=/usr/local/openssl/ -- with-http_ssl_module --with-http_flv_module --with-http_gzip_static_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/ --user=nginx --group=nginxmake error [[ Email protected] nginx-1.0.5]# makemake -f objs/makefilemake[1]: entering directory '/root/nginx/nginx-1.0.5 ' cd /usr/local/pcre/ && if [ -f makefile ]; then make distclean; fi && cc= "gcc" CFLAGS= "-O2 -fomit-frame-pointer -pipe " ./configure --disable-shared/ bin/sh: line 2: ./configure: no such file or directorymake[1]: ** * [/usr/local/pcre//makefile] error 127make[1]: leaving directory '/root/nginx/ nginx-1.0.5 ' make: *** [build] error 2# analysis [[email protected] nginx-1.0.5]# ./configure --help | grep ' \--with-pcre ' --with-pcre force  pcre library usage --with-pcre=dir set path to pcre library sources --with-pcre-opt=OPTIONS set additional options for PCRE buildingsource ???????? # solution [[email protected] nginx-1.0.5]# ./configure --prefix=/usr/local/nginx -- With-pcre=. /pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_ module --with-http_gzip_static_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/ -- user=nginx --group=nginx[[email protected] nginx-1.0.5]# makemake -f objs/ makefilemake[1]: entering directory '/root/nginx/nginx-1.0.5 ' cd /pcre-8.12/ && if [ -f makefile ]; then make distclean; fi && cc= "gcc" cflags= "-o2 -fomit-frame-pointer -pipe " \ ./configure --disable-sharedchecking for a bsd-compatible install... /usr/ BIN/INSTALL -C CHECKING WHETHER BUILD ENVIRONMENT IS SANE... MAKE[1]: *** [. /pcre-8.12//makefile] # ok Summary:--with-pcre=dir is to set the source directory instead of compiling the installed directory. 1.3 zlib Installation
2 nginx installation 2.1 First add the user Nginx, to implement the Nginx service process to run: # groupadd -r nginx# useradd -r -g nginx nginx2.2 then start compiling and installing: # ./configure --prefix=/usr/local/nginx --error-log-path=/data/applogs/nginx/error.log --http-log-path=/data/ applogs/nginx/access.log --pid-path=/var/run/nginx/nginx.pid -- lock-path=/var/lock/nginx.lock --user=nginx --group=nginx - -with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/usr/local/ nginx/client/ --http-proxy-temp-path=/usr/local/nginx/proxy/ -- Http-fastcgi-temp-path=/usr/local/nginx/fcgi/ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/lOcal/nginx/scgi --with-pcre --with-openssl=openssl Source Directory -- Withpcre=pcre Source directory --withzlib=zlib Source directory # make && make install# Description: # 1, Nginx can use Tmalloc (fast, multi-threaded malloc library and excellent performance analysis tools) to speed up memory allocation, using this feature requires the installation of Gperftools in advance, Then add the--with-google_perftools_module option in the build Nginx. # 2, if you want to use the Nginx Perl module, can be achieved by adding the--with-http_perl_module option for the Configure script, but this module is still in the experimental use phase, may be in operation unexpected, therefore, The way it is implemented is no longer described here. If you want to use the CGI function based on Nginx, can also be based on fcgi to achieve, the implementation of the method, please refer to the online documentation. 2.3, for Nginx to provide Sysv init script: New file/etc/rc.d/init.d/nginx, the content is as follows:#!/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& NBsP; ' 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 &nbSp; 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 ;; 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 then gives execute permission for this script: # chmod +x /etc/rc.d/init.d/nginx added to the service management list, And let it boot automatically: # chkconfig --add nginx# chkconfig nginx on and then you can start the service and test the:# Service nginx start
linux-offline installation Nginx