tengine 源碼安裝、啟動(dòng)服務(wù)




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、進(jìn)入 tengine 目錄


5、其中綠色的 configure 為可執(zhí)行文件,他的作用是檢查 tengine 文件完整性及預(yù)編譯

./configure

--prefix=/usr/tengine-2.2.0/ \? ? ? ? ? ? ? ? ? ? ? 安裝路徑

--error-log-path=/var/log/nginx/error.log \? ? ? ? ? ? ? 錯(cuò)誤日志輸出路徑

--http-log-path=/var/log/nginx/access.log \? ? ? ? ? ? http請(qǐng)求日志輸出路徑

--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)容說明檢查通過

這不可能會(huì)出現(xiàn)錯(cuò)誤,這是因?yàn)?tengine 需要依賴,安裝好依賴就沒問題了。

6、安裝

執(zhí)行 make && make install :安裝在預(yù)編譯是設(shè)定的目錄下


? ?安裝完成,查看安裝路徑下的文件


說明安裝完成。

7、設(shè)置 tengine 啟動(dòng)服務(wù),啟動(dòng)服務(wù)文件路徑:

/etc/init.d/

這里有個(gè) network 可執(zhí)行文件,這是 network 的啟動(dòng)服務(wù),我們參考這個(gè)來寫 tengine 的啟動(dòng)文件

#!/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 的啟動(dòng)執(zhí)行路徑

prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/tengine-2.2.0/conf/nginx.conf"? #tengine 的啟動(dòng)配置路徑

#[ -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

添加啟動(dòng)項(xiàng)?

chkconfig --add tengine

查看 tengine 啟動(dòng)項(xiàng)?

chkconfig --list tengine


開啟?

chkconfig tengine on


這是開機(jī)的時(shí)候就自動(dòng)啟動(dòng) tengine 了。

8、以上是 tengine? 的配置,但是在瀏覽器中還是無法訪問,原因是 centos? 的防火墻或者是80端口沒有開啟,關(guān)閉防火墻開啟80端口

防火墻設(shè)置引用地址:?http://www.cnblogs.com/silent2012/archive/2015/07/28/4682770.html

Cenots 7.0 默認(rèn)使用的是firewall作為防火墻,使用iptables必須重新設(shè)置一下

1)直接關(guān)閉防火墻

systemctl stop firewalld.service? #停止 firewall

systemctl disable firewalld.service? #禁止 firewall? 開機(jī)啟動(dòng)

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è)置防火墻開機(jī)啟動(dòng)

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;

}

說明:依次檢測(cè)匹配到第一條規(guī)則

重啟 nginx 使配置生效:

service nginx restart



11、用戶認(rèn)證訪問

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、配置防火墻,開啟80端口、3306端口 CentOS 7.0默認(rèn)使用的是firewall作為防火墻,這里改為i...
    ArleyDu閱讀 2,189評(píng)論 0 0
  • 昨晚阿里云不知搞得啥活動(dòng),就入手了一臺(tái)香港的云服務(wù)器,買了三年,價(jià)格也是很便宜,今天就給它搭建了一個(gè)lnmp環(huán)境,...
    nooops閱讀 777評(píng)論 0 0
  • 系統(tǒng)環(huán)境 所需軟件官方下載地址: 一、 安裝開發(fā)包環(huán)境: 二、 關(guān)閉iptables和Selinux(生產(chǎn)...
    莫名其妙的一生閱讀 1,418評(píng)論 0 4
  • Nginx是一個(gè)高性能的HTTP和反向代理服務(wù)器,其特點(diǎn)是占有內(nèi)存少,并發(fā)能力強(qiáng),事實(shí)上nginx的并發(fā)能力確實(shí)在...
    TyiMan閱讀 2,384評(píng)論 0 5
  • 1.安裝依賴 [root@web src]# yum install pcre zlibopenssl -y 2....
    think_lonely閱讀 642評(píng)論 0 1

友情鏈接更多精彩內(nèi)容