Nginx安裝-Tengine(阿裏baba的)
阿新 • • 發佈:2017-10-05
ati 輸入 local gre log /var/ syn 得到 highlight
簡介
Tengine是由淘寶網發起的Web服務器項目。它在Nginx的基礎上,針對大訪問量網站的需求,添加了很多高級功能和特性。Tengine的性能和穩定性已經在大型的網站如淘寶網,天貓網等得到了很好的檢驗。它的最終目標是打造一個高效、穩定、安全、易用的Web平臺。
Tengine完全兼容Nginx,因此可以參照Nginx的方式來配置Tengine。
一、獲取安裝包
wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
二、安裝依賴包
yum install pcre pcre-devel zlib zlib-devel open openssl-devel gcc gcc-c++
三、配置Nginx
./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/logs/nginx.pid --error-log-path=/usr/local/logs/error.log --http-log-path=/usr/local/logs/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/logs/nginx.pid --error-log-path=/usr/local/logs/error.log --http-log-path=/usr/local/logs/access.log --with-http_gzip_static_module 部分模塊配置安裝在/var/temp/nginx,所以事先要在創建/var/temp/nginx目錄
四、編譯&安裝
make;make install
五、啟動,停止,重新加載配置文件命令
1.啟動:直接運行nginx執行文件
[[email protected]]/usr/local/nginx/sbin# ./nginx [[email protected]]/usr/local/nginx/sbin# ps -aux|grep nginx Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 38247 0.0 0.1 46836 1124 ? Ss 13:40 0:00 nginx: master process ./nginx nobody 38248 0.0 0.1 47276 1768 ? S 13:40 0:00 nginx: worker process root 38251 0.0 0.0 103260 848 pts/1 S+ 13:40 0:00 grep nginx
啟動時可以使用 -c 指定配置文件
[[email protected]]/usr/local/nginx# sbin/nginx -c conf/nginx.conf [[email protected]]/usr/local/nginx# ps -aux|grep nginx Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 38450 0.0 0.1 46836 1124 ? Ss 14:02 0:00 nginx: master process sbin/nginx -c conf/nginx.conf nobody 38451 0.0 0.1 47276 1768 ? S 14:02 0:00 nginx: worker process root 38453 0.0 0.0 103260 848 pts/1 S+ 14:02 0:00 grep nginx
2.平緩停止:./nginx -s quit 待當前工作做完再停止
[[email protected]]/usr/local/nginx/sbin# ./nginx -s quit [[email protected]]/usr/local/nginx/sbin# ps -aux|grep nginx Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 38258 0.0 0.0 103260 844 pts/1 S+ 13:43 0:00 grep nginx
3.暴力停止:./nginx -s stop 或者直接 kill nginxPid nginxPid為nginx的進程號,可在nginx/logs/nginx.pid中查看
[[email protected]]/usr/local/nginx/sbin# ./nginx -s stop [[email protected]]/usr/local/nginx/sbin# ps -aux |grep nginx Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 38272 0.0 0.0 103260 848 pts/1 S+ 13:46 0:00 grep nginx [[email protected]]/usr/local/nginx/sbin# [[email protected]]/usr/local/nginx/logs# ps -aux|grep nginx Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 38287 0.0 0.1 46836 1124 ? Ss 13:47 0:00 nginx: master process ../sbin/nginx nobody 38288 0.0 0.1 47276 1768 ? S 13:47 0:00 nginx: worker process root 38294 0.0 0.0 103260 848 pts/1 S+ 13:48 0:00 grep nginx [[email protected]]/usr/local/nginx/logs# kill $(cat nginx.pid) [[email protected]]/usr/local/nginx/logs# ps -ef|grep nginx root 38298 2255 0 13:48 pts/1 00:00:00 grep nginx
4.重新加載配置
[[email protected]]/usr/local/nginx/sbin# ./nginx -s reload
六、設置開機啟動
1. vi /etc/init.d/nginx (輸入下面的代碼)
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it‘s not for everyone. # processname: nginx # 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 "nginx 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 /var/run/nginx.pid } # reload nginx service functions. 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
2. 更改執行權限
chmod a+x /etc/init.d/nginx(a+x ==> all user can execute 所有用戶可執行)
3.加入到/etc/rc.local中,實現開機自啟動
vi /etc/rc.local
任意行加入:/etc/init.d/nginx start
保存退出: wq
4.控制臺操作方法
[[email protected]]/usr/local/nginx# service nginx start 正在啟動 nginx: [確定] [[email protected]]/usr/local/nginx# service nginx restart 停止 nginx: [確定] 正在啟動 nginx: [確定] [[email protected]]/usr/local/nginx# service nginx reload 重新載入 nginx: [確定] [[email protected]]/usr/local/nginx# service nginx stop 停止 nginx: [確定]
原文鏈接:http://blog.csdn.net/KingBoyWorld/article/details/62888918
Nginx安裝-Tengine(阿裏baba的)