cd /usr/local/src wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz tar zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure –prefix=/usr/local/pcre make make install 二、下载proxy_cache插件
cd /usr/local/src wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz tar zxvf ngx_cache_purge-2.3.tar.gz 三、安装tengine
yum install openssl openssl-devel -y
cd /usr/local/src wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz tar zxvf tengine-2.1.0.tar.gz cd tengine-2.1.0 ./configure –add-module=/usr/local/src/ngx_cache_purge-2.3 –prefix=/usr/local/nginx –with-http_stub_status_module –with-pcre=/usr/local/src/pcre-8.37 make make install
/usr/local/nginx/sbin/nginx #启动nginx chown nobody.nobody -R /usr/local/nginx/html chmod 700 -R /usr/local/nginx/html
如果编译的问题的话,看看是不是下面的原因:
./configure: error: the HTTP SSL module requires OpenSSL library 原因:安装http_ssl_module模块需要openssl library 解决:yum install openssl-devel ./configure: error: the HTTP rewrite module requires the PCRE library. 原因:安装http_rewrite_module模块需要先安装PCRE开发包 解决:yum install pcre-devel
注意:
–with-pcre=/usr/local/src/pcre-8.37指向的是源码包解压的路径,而不是安装的路径,否则会报错。
–add-module=/usr/local/src/ngx_cache_purge-2.3 是指加载缓存的插件模块
四、设置Tengine开机启动
vi /etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
#!/bin/bash # Tengine Startup script# processname: nginx # chkconfig: – 85 15 # description: nginx is a World Wide Web server. It is used to serve # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # 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 $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "tengine already running…." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid } reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL
保存退出
chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限 chkconfig –level 012345 nginx on #设置开机启动 /etc/rc.d/init.d/nginx restart 五、配置Tengine 将nginx初始配置文件备份,我们要重新创建配置文件.
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
创建nginx用户nginx
groupadd nginx useradd -g nginx nginx
编辑主配置文件:
vi /usr/local/nginx/conf/nginx.conf
更多关于云服务器,域名注册,虚拟主机的问题,请访问西部数码官网:www.west.cn