源码安装nginx
这里装nginx的三个依赖,分别是pcre、openssl、zlib
其中编译pcre需要:
yum install gcc gcc-c++ pcre-devel
下载源码包
官网下载最新版即可: http://www.pcre.org/ http://www.openssl.orghttp://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
然后就是:
makemake install
执行
优六系统(全称:优六企服系统)是在Util6MIS基础上组合CMS等插件及子系统的综合信息化管理系统。 Util6MIS(软著全称:优六信息化管理框架系统)是一款免费的通用信息化快速开发框架,该框架可快速集成各类系统开发。 系统后台采用.NET6 + Layui作为UI支撑,操作界面简洁,项目结构清晰,功能模块化设计,支撑框架轻量高效,代码层级分离,注释完整,可快速重构,提高开发效率。
按照上面的安装方法,nginx装在/data/nginx
./data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf#因为它需要指定配置文件才能运行,执行这条配置文件没有返回,建议使用脚本控制
脚本如下
#!/bin/sh# config: /usr/local/nginx/conf/nginx.confnginx_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" ] && exit0[ -x $nginx_path/sbin/nginx ] || exit0RETVAL=0
prog="nginx"start() {
# Start daemons.if [ -e$nginx_pid-a ! -z $nginx_pid ];thenecho"nginx already running...."exit1fiif [ -e$nginx_path/conf/nginx.conf ];thenecho -n $"Starting $prog: "$nginx_path/sbin/nginx -c $nginx_path/conf/nginx.conf &
RETVAL=$?
[ $RETVAL-eq0 ] && {
touch /var/lock/subsys/$prog
success $"$prog"
}
echoelse
RETVAL=1fireturn$RETVAL
}
# Stop daemons.stop() {
echo -n $"Stopping $prog: "
killproc -d10$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}"exit1esacexit$RETVAL如果脚本名字叫nginx.sh
那么可以:
./nginx.sh status|stop|start....
代理的配置
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>以上就介绍了nginx反向代理(及优化),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。









