1一喘、下載 tengine 源碼文件地址:
? ? ? ??http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
2驱还、將下載包上傳到服務(wù)器目錄
? ? ? ?/usr/local/src
3、解壓 tenginx 到當(dāng)前目錄下
? ? ? tar -zxvf tengine-2.2.0.tar.gz
? ? ? 刪掉源碼文件:rm tengine-2.2.0.tar.gz
4凸克、進入 tengine 目錄
5议蟆、其中綠色的 configure 為可執(zhí)行文件,他的作用是檢查 tengine 文件完整性及預(yù)編譯
./configure
--prefix=/usr/tengine-2.2.0/ \? ? ? ? ? ? ? ? ? ? ? 安裝路徑
--error-log-path=/var/log/nginx/error.log \? ? ? ? ? ? ? 錯誤日志輸出路徑
--http-log-path=/var/log/nginx/access.log \? ? ? ? ? ? http請求日志輸出路徑
--pid-path=/var/run/nginx/nginx.pid? \? ? ? ? ? ? ? ? ? ? pid輸出路徑
--lock-path=/var/lock/nginx.lock \? ? ? ? ? ? ? ? ? ? ? ? ? ? lock輸出路徑
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
出現(xiàn)以下內(nèi)容說明檢查通過
這不可能會出現(xiàn)錯誤萎战,這是因為 tengine 需要依賴咐容,安裝好依賴就沒問題了。
6蚂维、安裝
執(zhí)行 make && make install :安裝在預(yù)編譯是設(shè)定的目錄下
? ?安裝完成戳粒,查看安裝路徑下的文件
說明安裝完成。
7鸟雏、設(shè)置 tengine 啟動服務(wù)享郊,啟動服務(wù)文件路徑:
/etc/init.d/
這里有個 network 可執(zhí)行文件,這是 network 的啟動服務(wù)孝鹊,我們參考這個來寫 tengine 的啟動文件
#!/bin/bash
#
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network ??
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/tengine-2.2.0/sbin/nginx"? #tengine 的啟動執(zhí)行路徑
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/tengine-2.2.0/conf/nginx.conf"? #tengine 的啟動配置路徑
#[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx ? ? ??
#make_dirs() {
#? # make required directories
#? user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
#? options=`$nginx -V 2>&1 | grep 'configure arguments:'`
#? for opt in $options; do
#? ? ? if [ `echo $opt | grep '.*-temp-path'` ]; then
#? ? ? ? ? value=`echo $opt | cut -d "=" -f 2`
#? ? ? ? ? if [ ! -d "$value" ]; then
#? ? ? ? ? ? ? # echo "creating" $value
#? ? ? ? ? ? ? mkdir -p $value && chown -R $user $value
#? ? ? ? ? fi
#? ? ? fi
#? done
#}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
#? ? make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
#? -HUP是nginx平滑重啟參數(shù)
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
修改路徑
nginx="/usr/tengine-2.2.0/sbin/nginx"
NGINX_CONF_FILE="/usr/tengine-2.2.0/conf/nginx.conf"
修改 tengine 的權(quán)限?
chmod 755 tengine
添加啟動項?
chkconfig --add tengine
查看 tengine 啟動項?
chkconfig --list tengine
開啟?
chkconfig tengine on
這是開機的時候就自動啟動 tengine 了炊琉。
8、以上是 tengine? 的配置又活,但是在瀏覽器中還是無法訪問苔咪,原因是 centos? 的防火墻或者是80端口沒有開啟,關(guān)閉防火墻開啟80端口
防火墻設(shè)置引用地址:?http://www.cnblogs.com/silent2012/archive/2015/07/28/4682770.html
Cenots 7.0 默認使用的是firewall作為防火墻柳骄,使用iptables必須重新設(shè)置一下
1)直接關(guān)閉防火墻
systemctl stop firewalld.service? #停止 firewall
systemctl disable firewalld.service? #禁止 firewall? 開機啟動
2)設(shè)置iptables sevice
安裝iptables-services :yum -y install iptables-services
修改防火墻配置团赏,添加 80 端口
vi /etc/sysconfig/iptables
添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
保存后退出
systemctl restart iptables.service # 重啟防火墻是配置是配置生效
systemctl enable iptables.service # 設(shè)置防火墻開機啟動
9、瀏覽器訪問 tengine
10耐薯、客戶端訪問配置
? ? ? ? 修改nginx的配置文件:
? ? ? ? vi /usr/tengine-2.2.0/conf/nginx.conf
server {
? ? ? ? ? ? ?listen? ? ? 80;
? ? ? ? ? ? server_name? localhost;
? ? ? ? ? ? #charset koi8-r;
? ? ? ? ? ? #access_log? logs/host.access.log? main;
? ? ? ? ? ?location / {
? ? ? ? ? ? ? ? ? ?allow? 192.168.148.1/24;
? ? ? ? ? ? ? ? ? ?root? html;
? ? ? ? ? ? ? ? ? index? index.html index.htm;
? ? ? ?}
}
修改 location : 添加
deny? x.x.x.x; 拒絕x.x.x.x地址訪問nginx
allow x.x.x.x;允許x.x.x.x地址訪問nginx
例子如下:
location / {
? ? ? ? ? deny 192.168.148.1; ? ? ? ? #win地址不允許訪問
? ? ? ? ? allow 192.168.148.128; ? # centos 129 地址允許訪問?
? ? ? ? ?allow? 192.168.148.1/24;
? ? ? ? ? root? html;
? ? ? ? ? index? index.html index.htm;
}
說明:依次檢測匹配到第一條規(guī)則
重啟 nginx 使配置生效:
service nginx restart
11舔清、用戶認證訪問