一、文件说明
pcre支持nginx伪静态
openssl(nginx扩展)
zlib(nginx扩展)
软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字
二、安装编译工具及库文件
将centos.repo文件放入到/etc/yum.repos.d/目录下
[root@ wanzhuangit]# yum install -y apr* autoconf automake bison bzip2 bzip2*cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetypefreetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibckernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devellibpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devellibtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfrncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gdpolicycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
三、安装步骤
1、安装pcre
[root@v19 nginx_package]# mkdir -p/usr/local/pcre
[root@v19 nginx_package]# tar zxvfpcre-8.36.tar.gz -C /usr/local/src/
[root@v19 nginx_package]# cd /usr/local/src
[root@v19 src]# cd pcre-8.36/
[root@v19 pcre-8.36]# ./configure--prefix=/usr/local/pcre
[root@v19 pcre-8.36]# make
[root@v19 pcre-8.36]# make install
2、安装openssl
[root@v19 nginx_package]# mkdir/usr/local/openssl
[root@v19 nginx_package]# tarzxvf openssl-1.0.1h.tar.gz -C /usr/local/src/
[root@v19 nginx_package]# cd/usr/local/src/openssl-1.0.1h/
[root@v19 openssl-1.0.1h]#./config --prefix=/usr/local/openssl
[root@v19 openssl-1.0.1h]# make
[root@v19 openssl-1.0.1h]# makeinstall
编辑 /etc/profile文件添加一些内容
export PATH=$PATH:/usr/local/openssl/bin
file:///C:/Users/xiaozhu/AppData/Local/Temp/msohtmlclip1/01/clip_image002.jpg
[root@v19 openssl-1.0.1h]#source /etc/profile
3、安装zlib
[root@v19 nginx_package]# mkdir/usr/local/zlib
[root@v19 nginx_package]# tarzxvf zlib-1.2.8.tar.gz -C /usr/local/src/
[root@v19 nginx_package]# cd/usr/local/src/zlib-1.2.8/
[root@v19 zlib-1.2.8]# ./configure--prefix=/usr/local/zlib
[root@v19 zlib-1.2.8]# make
[root@v19 zlib-1.2.8]# make install
4、安装Nginx
[root@v19 nginx_package]# groupadd www
[root@v19 nginx_package]# useradd -g wwwwww -s /bin/false
[root@v19 nginx_package]# tar zxvfnginx-1.6.0.tar.gz -C /usr/local/src
[root@v19 nginx_package]# cd/usr/local/src/
[root@v19 nginx-1.6.0]# ./configure--prefix=/usr/local/nginx --without-http_memcached_module --user=www--group=www --with-http_stub_status_module --with-http_ssl_module--with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h--with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36
注意:--with-openssl=/usr/local/src/openssl-1.0.1h--with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则会报错
[root@v19 nginx-1.6.0]# make
[root@v19 nginx-1.6.0]# make install
[root@v19 nginx-1.6.0]#/usr/local/nginx/sbin/nginx #启动Nginx
设置nginx开机启动
vi /etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
############################################################
#!/bin/sh
#
# nginx - this scriptstarts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx isan HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3proxy server
# processname: nginx
# config:/etc/nginx/nginx.conf
# config:/usr/local/nginx/conf/nginx.conf
# pidfile:/usr/local/nginx/logs/nginx.pid
# Source functionlibrary.
./etc/rc.d/init.d/functions
# Source networkingconfiguration.
. /etc/sysconfig/network
# Check that networkingis up.
[ "$NETWORKING"= "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make requireddirectories
user=`$nginx -V2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^]*\).*/\1/g' -`
if [ -z "`grep $user/etc/passwd`" ]; then
useradd -M -s/bin/nologin $user
fi
options=`$nginx -V2>&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/null2>&1
}
case "$1" 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 2
esac
############################################################
[root@v19 nginx-1.6.0]# chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
[root@v19 nginx-1.6.0]# chkconfig nginx on #设置开机启动
[root@v19 nginx-1.6.0]#/etc/rc.d/init.d/nginx restart #重启
file:///C:/Users/xiaozhu/AppData/Local/Temp/msohtmlclip1/01/clip_image004.jpg