下載地址:html
http://tengine.taobao.org/download_cn.htmlnginx
$tar -xvzf tengine-2.1.2.tar.gzweb
$./configure
$ make
$ sudo make installbash
安裝Nginx時報錯ide
./configure: error: the HTTP rewrite module requires the PCRE library.ui
安裝pcre-devel解決問題
yum -y install pcre-develspa
./configure: error: C compiler cc is not foundrest
解決:server
yum install gcchtm
錯誤提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決辦法:
yum -y install openssl openssl-devel
總結:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
一切搞定
[root@webserver1 tengine]# /usr/local/nginx/sbin/nginx #啓動nginx
[root@webserver1 tengine]# ./sbin/nginx -s stop
[root@webserver1 tengine]# ./sbin/nginx -s reload #這個很經常使用哦,平滑更新配置。
chown nobody.nobody -R /usr/local/nginx/html
chmod 700 -R /usr/local/nginx/html
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
4、配置Tengine
將nginx初始配置文件備份,咱們要從新建立配置文件.
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak 建立nginx用戶www groupadd www useradd -g www www
其他配置詳見:
http://www.cnblogs.com/littlehb/archive/2013/04/02/2994686.html