從Nginx切換到Tengine的步驟分享
更新時間:2012年11月13日 11:46:52 作者:
由淘寶網(wǎng)發(fā)起的Web服務(wù)器 Tengine 可以被看作一個更好的Nginx,或者是Nginx的超集。它在Nginx的基礎(chǔ)上,針對大訪問量網(wǎng)站的需求,添加了很多高級功能和特性
從Nginx切換到Tengine主要是因?yàn)?concat 模塊(合并js、css),以及動態(tài)加載模塊功能(DSO)。
如果已經(jīng)用apt-get方式安裝了Nginx,可以嘗試以下步驟以切換到Tengine(不需要卸載Nginx):
1. 到官方下載你喜歡的Tengine版本,這里以最新版(1.4.0)為例,
wget http://tengine.taobao.org/download/tengine-1.4.0.tar.gz
2. 解壓縮:
tar -xvzf tengine-1.4.0.tar.gz
3. 進(jìn)入解壓出來的文件夾:
cd tengine-1.4.0/
4. 查看當(dāng)前Nginx的編譯參數(shù):
nginx -V
得到結(jié)果如下:
nginx: nginx version: nginx/1.0.5
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upstream-fair
5. 根據(jù)上面第三行的配置編譯Tengine,具體做法:從--prefix=/etc/nginx開始復(fù)制第三行的代碼,然后在--with-debug后面加上--with-http_concat_module(意前后需要有空格),并刪掉從--add-module開始的代碼(否則會編譯不過),完整的編譯腳本如下:
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_concat_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module
如果編譯中出現(xiàn)類似下面的錯誤,說明編譯依賴模塊不存在,你可以選擇安裝或者如果你不需要這個模塊的話,從上面的編譯腳本中刪除后再一次執(zhí)行編譯腳本,直到編譯完成:
這里提示XSLT模塊不存在,在上面的編譯腳本中搜索xslt,找到了--with-http_xslt_module,刪除就可以了,同樣注意前后的空格。
成功后提示如下(其中的路徑是跟編譯腳本有關(guān)的,所以可能會略有不同):
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/etc/nginx"
nginx binary file: "/etc/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx dso module path: "/etc/nginx/modules"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
6. 繼續(xù)編譯(make就可以了,不需要make install):
make
7. 到objs目錄下編譯好的nginx文件:
8. 停止nginx:
9. 復(fù)制objs目錄下的nginx文件到/usr/sbin/nginx目錄,覆蓋前記得備份原來文件:
9. 測試nginx是否正常(/user/sbin目錄):
如果出現(xiàn)syntax is ok,test is successful表示成功:
10. 重新啟動nginx
service nginx start
訪問服務(wù)器上一個不存在的頁面,查看服務(wù)器是否是Tengine
403 Forbidden
You don't have permission to access the URL on this server. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
URL: http://10.20.131.181/doc
Server: ubuntu-bak
Date: 2012/10/06 17:54:53
Powered by Tengine/1.4.0
注意看最后一行:Powered by Tengine/1.4.0 表示我們已經(jīng)成功從Nginx切換到了Tengine
如果已經(jīng)用apt-get方式安裝了Nginx,可以嘗試以下步驟以切換到Tengine(不需要卸載Nginx):
1. 到官方下載你喜歡的Tengine版本,這里以最新版(1.4.0)為例,
復(fù)制代碼 代碼如下:
wget http://tengine.taobao.org/download/tengine-1.4.0.tar.gz
2. 解壓縮:
復(fù)制代碼 代碼如下:
tar -xvzf tengine-1.4.0.tar.gz
3. 進(jìn)入解壓出來的文件夾:
復(fù)制代碼 代碼如下:
cd tengine-1.4.0/
4. 查看當(dāng)前Nginx的編譯參數(shù):
復(fù)制代碼 代碼如下:
nginx -V
得到結(jié)果如下:
復(fù)制代碼 代碼如下:
nginx: nginx version: nginx/1.0.5
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upstream-fair
5. 根據(jù)上面第三行的配置編譯Tengine,具體做法:從--prefix=/etc/nginx開始復(fù)制第三行的代碼,然后在--with-debug后面加上--with-http_concat_module(意前后需要有空格),并刪掉從--add-module開始的代碼(否則會編譯不過),完整的編譯腳本如下:
復(fù)制代碼 代碼如下:
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_concat_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module
如果編譯中出現(xiàn)類似下面的錯誤,說明編譯依賴模塊不存在,你可以選擇安裝或者如果你不需要這個模塊的話,從上面的編譯腳本中刪除后再一次執(zhí)行編譯腳本,直到編譯完成:
復(fù)制代碼 代碼如下:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
libraries. You can either do not enable the module or install the libraries.
這里提示XSLT模塊不存在,在上面的編譯腳本中搜索xslt,找到了--with-http_xslt_module,刪除就可以了,同樣注意前后的空格。
成功后提示如下(其中的路徑是跟編譯腳本有關(guān)的,所以可能會略有不同):
復(fù)制代碼 代碼如下:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/etc/nginx"
nginx binary file: "/etc/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx dso module path: "/etc/nginx/modules"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
6. 繼續(xù)編譯(make就可以了,不需要make install):
復(fù)制代碼 代碼如下:
make
7. 到objs目錄下編譯好的nginx文件:
復(fù)制代碼 代碼如下:
cd objs/
8. 停止nginx:
復(fù)制代碼 代碼如下:
service nginx stop
9. 復(fù)制objs目錄下的nginx文件到/usr/sbin/nginx目錄,覆蓋前記得備份原來文件:
復(fù)制代碼 代碼如下:
cp /usr/sbin/nginx /usr/sbin/nginx.bak
cp nginx /usr/sbin/
cp nginx /usr/sbin/
9. 測試nginx是否正常(/user/sbin目錄):
復(fù)制代碼 代碼如下:
nginx -t
如果出現(xiàn)syntax is ok,test is successful表示成功:
復(fù)制代碼 代碼如下:
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
configuration file /etc/nginx/nginx.conf test is successful
10. 重新啟動nginx
復(fù)制代碼 代碼如下:
service nginx start
訪問服務(wù)器上一個不存在的頁面,查看服務(wù)器是否是Tengine
復(fù)制代碼 代碼如下:
403 Forbidden
You don't have permission to access the URL on this server. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
URL: http://10.20.131.181/doc
Server: ubuntu-bak
Date: 2012/10/06 17:54:53
Powered by Tengine/1.4.0
注意看最后一行:Powered by Tengine/1.4.0 表示我們已經(jīng)成功從Nginx切換到了Tengine
相關(guān)文章
Nginx實(shí)現(xiàn)Nacos反向代理的項(xiàng)目實(shí)踐
在日常的web網(wǎng)站部署中,經(jīng)常會用到nginx反向代理,本文主要介紹了Nginx實(shí)現(xiàn)Nacos反向代理的項(xiàng)目實(shí)踐,Nginx實(shí)現(xiàn)Nacos反向代理的項(xiàng)目實(shí)踐2022-03-03
Mac環(huán)境Nginx配置和訪問本地靜態(tài)資源的實(shí)現(xiàn)
這篇文章主要介紹了Mac環(huán)境Nginx配置和訪問本地靜態(tài)資源的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
前端加載訪問速度優(yōu)化詳細(xì)指南(Nginx)
在前端開發(fā)中,優(yōu)化頁面加載速度成為了開發(fā)者的一項(xiàng)重要任務(wù),下面這篇文章主要給大家介紹了關(guān)于前端加載訪問速度優(yōu)化(Nginx)的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-06-06
Nginx 只允許 www 域名訪問并禁止裸域名訪問的實(shí)現(xiàn)步驟
通過Nginx配置,可以設(shè)定僅允許www域名訪問,禁止或重定向裸域名,提升網(wǎng)站品牌統(tǒng)一性及用戶體驗(yàn),設(shè)置包括創(chuàng)建針對www的虛擬主機(jī),禁止裸域名訪問,并可選進(jìn)行裸域名到www的301重定向,完成后,重啟Nginx服務(wù)器使配置生效2024-10-10
教你利用Nginx 服務(wù)搭建子域環(huán)境提升二維地圖加載性能的步驟
這篇文章主要介紹了利用 Nginx 服務(wù)搭建子域環(huán)境提升二維地圖加載性能,本文分步驟通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-09-09

