Step sharing to switch from Nginx to Tengine
- 2020-05-06 12:18:28
- OfStack
Switching from Nginx to Tengine is mainly due to the concat module (merging js, css) and the ability to dynamically load modules (DSO).
If you already have Nginx installed in apt-get, you can try the following steps to switch to Tengine(without uninstalling Nginx) :
Go to the official site and download your favorite version of Tengine. Here's the latest version (1.4.0),
2. Unzip:
Enter the unzipped folder:
View the current Nginx compilation parameters:
The result is as follows:
5. Compile Tengine according to the configuration of the third line above: copy the third line of code from --prefix=/etc/nginx, then add -- with-http_module after -- with-debug, and delete the code from -- add-module (otherwise it would compile but not). The full compilation script is as follows:
If an error like the following occurs in the compilation, the compilation dependency module does not exist, you may choose to install it or, if you do not need the module, remove it from the above compilation script and execute the compilation script again until the compilation is complete:
Note that the XSLT module does not exist. Search for xslt in the above compiled script and find -- with-http_xslt_module.
Note on success (where the path is related to the compiled script, so it may be slightly different) :
6. Continue compiling (make is fine, make install is not required) :
7. To objs directory compiled nginx file:
8. Stop nginx:
9. Copy the nginx files in the objs directory to /usr/sbin/nginx directory. Make sure to back up the original files before overwriting:
9. Test that nginx is working (/user/sbin directory) :
If syntax is ok appears, test is successful indicates success:
10. Restart nginx
Visit a nonexistent page on the server to see if the server is Tengine
Notice the last line :Powered by Tengine/1.4.0 indicates that we have successfully switched from Nginx to Tengine
If you already have Nginx installed in apt-get, you can try the following steps to switch to Tengine(without uninstalling Nginx) :
Go to the official site and download your favorite version of Tengine. Here's the latest version (1.4.0),
wget http://tengine.taobao.org/download/tengine-1.4.0.tar.gz
2. Unzip:
tar -xvzf tengine-1.4.0.tar.gz
Enter the unzipped folder:
cd tengine-1.4.0/
View the current Nginx compilation parameters:
nginx -V
The result is as follows:
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. Compile Tengine according to the configuration of the third line above: copy the third line of code from --prefix=/etc/nginx, then add -- with-http_module after -- with-debug, and delete the code from -- add-module (otherwise it would compile but not). The full compilation script is as follows:
./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
If an error like the following occurs in the compilation, the compilation dependency module does not exist, you may choose to install it or, if you do not need the module, remove it from the above compilation script and execute the compilation script again until the compilation is complete:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
Note that the XSLT module does not exist. Search for xslt in the above compiled script and find -- with-http_xslt_module.
Note on success (where the path is related to the compiled script, so it may be slightly different) :
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. Continue compiling (make is fine, make install is not required) :
make
7. To objs directory compiled nginx file:
cd objs/
8. Stop nginx:
service nginx stop
9. Copy the nginx files in the objs directory to /usr/sbin/nginx directory. Make sure to back up the original files before overwriting:
cp /usr/sbin/nginx /usr/sbin/nginx.bak
cp nginx /usr/sbin/
9. Test that nginx is working (/user/sbin directory) :
nginx -t
If syntax is ok appears, test is successful indicates success:
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
10. Restart nginx
service nginx start
Visit a nonexistent page on the server to see if the server is 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
Notice the last line :Powered by Tengine/1.4.0 indicates that we have successfully switched from Nginx to Tengine