标签:nginx 源码 pcre libpcre-la
这里装nginx的三个依赖,分别是pcre、openssl、zlib
其中编译pcre需要:
yum install gcc gcc-c++ pcre-devel
官网下载最新版即可:
http://www.pcre.org/
http://www.openssl.org
http://www.zlib.net/
http://nginx.org
注意:这里pcre只能是是8.0+,pcre2不支持
会报错:
make[2]: *** No rule to make target `libpcre.la‘. Stop.
除了pcre我都用的最新稳定版,给个我用的pcre源码包:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
这里不用分别编译安装,直接进入解压的nginx目录下执行
假设文件都放在/home目录
./configure --prefix=/data/nginx
--with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-pcre=/home/pcre2-10.00 --with-openssl=/home/openssl-1.0.2a --with-http_ssl_module --with-zlib=/home/zlib-1.2.8
注意绿色的三个是指定源码的目录,不是安装目录,因为本方法是联合编译的,不需要提前编译安装pcre,ssl,zlib
然后就是:
make
make install
按照上面的安装方法,nginx装在/data/nginx
./data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf
#因为它需要指定配置文件才能运行,执行这条配置文件没有返回,建议使用脚本控制
脚本如下
#!/bin/sh
# config: /usr/local/nginx/conf/nginx.conf
nginx_path="/data/nginx"
nginx_pid="/data/nginx/logs/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
[ -x $nginx_path/sbin/nginx ] || exit 0
RETVAL=0
prog="nginx"
start() {
# Start daemons.
if [ -e $nginx_pid -a ! -z $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
if [ -e $nginx_path/conf/nginx.conf ];then
echo -n $"Starting $prog: "
$nginx_path/sbin/nginx -c $nginx_path/conf/nginx.conf &
RETVAL=$?
[ $RETVAL -eq 0 ] && {
touch /var/lock/subsys/$prog
success $"$prog"
}
echo
else
RETVAL=1
fi
return $RETVAL
}
# Stop daemons.
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $nigx_path/sbin/nginx
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $nginx_pid /var/lock/subsys/$prog
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reconfigure)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|reconfigure|status}"
exit 1
esac
exit $RETVAL
如果脚本名字叫nginx.sh
那么可以:
./nginx.sh status|stop|start....
标签:nginx 源码 pcre libpcre-la
原文地址:http://blog.csdn.net/tmpbook/article/details/45643023