Before preparing the Debian-style Tengine deb package, I tried the tengine dynamic loading module function. I think there may be a lot of opportunities for deployment, nginx was not used before because every time a new function needs to be added, it needs to be re-compiled. Although nginx is better in performance than apache, it is difficult to deploy nginx on hundreds of machines, different departments have different web requirements and different modules. Even if all built-in modules are compiled, some good third-party modules are still encountered, now that tengine supports Dynamic Loading modules, there is hope that one or two compilations are acceptable. It is better to use package management to deploy tengine in a large number. Under www.2cto.com, create a tengine deb package based on the debian 6 system. The tengine package style is similar to that of a debian web server package. To compile all modules that support dynamic loading, the following packages are required: 1apt-get install libxml22apt-get install libxslt1.13apt-get install libxslt1-dev4apt-get install libgd2-xpm libgd2-xpm-dev5apt-get install libgeoip1 libgeoip-dev6apt-get install libssl-dev7apt-get install libpcre3 libpcre3-dev8apt-get install libssl. so.0.9.8 first, create an environment directory tengine under the/tmp directory to create the deb package. Do not create other directories first. The final overall structure is as follows: www.2cto.com 01 ── tengine02 ├ ── the DEBIAN directory stores some control information about the package file 03 ── Etc04 │ ├ ── init. d. Store/etc/init. d/nginx file 05 │ ── logrotate. d. Save nginx log rotation configuration file 06 │ ── nginx07 │ ── conf to store nginx configuration file 08 │ ── modules to store Dynamically Loaded modules 09 │ ── sbin to store dso_tool 10 ── usr11 │ └ ── sbin stores the nginx binary file 12 ── var13 ── lib14 │ ── nginx15 ── log16 │ └ ── nginx stores the nginx log 17 ── www stores the web site download the tengine source code package: tengine-1.4.2.tar.gz, compile and install, the compilation parameters are as follows 1. /configure -- prefix =/etc/nginx -- sbin-path =/usr/sbin -- Error-log-path =/var/log/nginx/error. log -- conf-path =/etc/nginx/conf/nginx. conf -- pid-path =/var/run -- with-http_addition_module = shared -- with-http_xslt_module = shared -- with-http_geoip_module = shared -- with-http_image_filter_module = shared -- with-http_sub_module = shared -- with-http_flv_module = shared -- with-http_slice_module = shared -- with-http_mp4_module = shared -- = shared -- with-http_concat_module = shared -- -Http_random_index_module = shared -- with-http_map_module = shared -- with-http_split_clients_module = shared -- with-http_charset_filter_module = shared -- with-http_access_module = shared -- with-http_userid_filter_module = shared -- with-http_footer_filter_module = shared -- with-http_upstream_least_conn_module = shared -- with-http_upstream_ip_hash_module = shared -- with-http_user_agent_module = shared with-http_memca Ched_module = shared -- with-http_referer_module = shared -- with-http_limit_conn_module = shared -- with-http_limit_req_module = shared -- with-http_scgi_module = shared -- with-http_secure_link_module = shared -- with-http_autoindex_module = shared -- with-http_sysguard_module = shared -- with-http_rewrite_module = shared -- with-http_fastcgi_module = shared -- with-http_empty_gif_module = shared -- with-http_browser_module = sha Red -- with-http_uwsgi_module = shared -- prefix =/etc/nginx this directory stores other files except nginx binary files -- sbin-path =/usr/sbin this directory has compiled nginx binary files all dependent packages have been installed before, so no problem occurs. Just make & make install. After installation, the directory structure in/etc/nginx is as follows: www.2cto.com 01nginx02 ├ ── conf03 │ ── browsers04 │ └ ── several configuration files... 05 ── html06 │ ├ ── 50x.html 07 │ ── index.html 08 ── logs09 ── modules10 │ ── ngx_http_access_module.so11 │ ├ ── ngx_http_addition_filter_module. So12 │ ── ngx_http_uwsgi_module.so13 │ ── several modules... 14 ── sbin15 ── dso_tool began to move the system wide... www.2cto.com 1mv/etc/nginx/conf/tmp/tengine/etc/nginx/2mv/etc/nginx/html/*/tmp/tengine/var/www/3mv/etc/nginx /modules/tmp/tengine/etc/nginx/4mv/etc/nginx/sbin/tmp/tengine/etc/nginx/5mv/usr/sbin/nginx/tmp/tengine/usr /sbin/start to complete other directories in/tmp/tengine. The content of logrotate. d/nginx is as follows. For nginx log training, use 01/var/log/nginx/*. log {02 daily03 missingok04 rotate 5205 compress06 worker empty08 create 640 root adm09 sharedscripts10 postrotate11 [! -F/var/run/nginx. pid] | kill-USR1 'cat/var/run/nginx. pid '12 endscript13} init. d/nginx content is as follows. init starts nginx with www.2cto.com 01 PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin02DAEMON =/usr/sbin/nginx03NAME = nginx04DESC = nginx05test-x $ DAEMON | exit 006if [-f/etc/default/nginx]; then07. /etc/default/nginx08fi09set-e10./lib/lsb/init-functions11test_nginx_config () {12 if $ DAEMON- T $ DAEMON_OPTS>/dev/null 2> & 113 then14 return 015 else16 $ DAEMON-t $ DAEMON_OPTS17 return $? 18 fi19} 20 case "$1" in21 start) 22 echo-n "Starting $ DESC: "23 test_nginx_config24 start-stop-daemon -- start -- quiet -- pidfile/var/run/$ NAME. pid \ 25 -- exec $ DAEMON -- $ DAEMON_OPTS | true26 echo "$ NAME. "27; 28 stop) 29 echo-n" Stopping $ DESC: "30 start-stop-daemon -- stop -- quiet -- pidfile/var/run/$ NAME. pid \ 31 -- exec $ DAEMON | true32 echo "$ NAME. "33; 34 restart | force-reload) 35 echo-n" Restart Ing $ DESC: "36 start-stop-daemon -- stop -- quiet -- pidfile \ 37/var/run/$ NAME. pid -- exec $ DAEMON | true38 sleep 139 test_nginx_config40 start-stop-daemon -- start -- quiet -- pidfile \ 41/var/run/$ NAME. pid -- exec $ DAEMON -- $ DAEMON_OPTS | true42 echo "$ NAME. "43; 44 reload) 45 echo-n" Reloading $ DESC configuration: "46 test_nginx_config47 start-stop-daemon -- stop -- signal HUP -- quiet -- pidfile/var/ Run/$ NAME. pid \ 48 -- exec $ DAEMON | true49 echo "$ NAME. "50; 51 configtest) 52 echo-n" Testing $ DESC configuration: "53 if test_nginx_config54 then55 echo" $ NAME. "56 else57 exit $? 58 fi59; 60 status) 61 status_of_proc-p/var/run/$ NAME. pid "$ DAEMON" nginx & exit 0 | exit $? 62; 63 *) 64 echo "Usage: $ NAME {start | stop | restart | reload | force-reload | status | configtest}"> & 265 exit 166 ;; 67esac68exit 0 nginx/conf/nginx. the conf content is as follows, because the web site directory and log directory have changed, so it should be minor: 01worker_processes 1; 02error_log/var/logs/nginx/error. log; 03pid/var/run/nginx. pid; 04 events {05 worker_connections 1024; 06} 07 http {08 include mime. types; 09 default_type application/octet-stream; 10 log_format main '$ remo Te_addr-$ remote_user [$ time_local] "$ request" '11' $ status $ body_bytes_sent "$ http_referer" '12' "$ http_user_agent" "$ http_x_forwarded_for "'; 13 access_log/var/logs/nginx/access. log main; 14 sendfile on; 15 keepalive_timeout 65; 16 server {17 listen 80; 18 server_name localhost; 19 location/{20 root/var/www; 21 index index.html index.htm; 22} 23 error_page 500 502 503 504/var/www/50x.html; 24 locati On =/50x.html {25 root/var/www; 26} 27} 28} the remaining DEBIAN directory is not configured. The structure is as follows: 1 DEBIAN/2 ── control3 ├ ── postinst4 ├ ── postrm5 ├ ── preinst6 control ── prerm control: Provides the associated information of the software package for the software package manager to display the information of the software package, the dependency used for pre-installation verification. is a required file postrm: run after the package is detached from the system. Dpkg indicates whether the script package has been uninstalled or cleared. This script is also executed when the software package is uninstalled due to a conflict or upgrade. Preinst: run the command before installing or upgrading the software package. Prerm: the script is executed before the package is detached. Postinst: the script is executed as part of the configuration process after being unwrapped. For example, listening for local IP addresses and changing ports. In this article, I don't need to make any adjustments, so I didn't set this file. The content of DEBIAN/control is as follows. Because the dependency packages have been installed before, I removed the dependency setting 1 Package: nginx2Version: 1.2.53Architecture: amd644Maintainer in the control file: jose Parrella <bureado@debian.org> 5 Provides: httpd6Section: httpd7Priority: optional8Homepage: http: // nginx. net9Description: xxxxxxxx DEBIAN/prerm file content: 01 #! /Bin/sh02set-e03case "$1" in04 remove | remove-in-favor | deconfigure-in-favor) 05 if [-x/etc/init. d/nginx]; then06 if [-x/usr/sbin/invoke-rc.d]; then07 invoke-rc.d nginx stop08 else 09/etc/init. d/nginx stop10 fi11 fi12; 13 upgrade | failed-upgrade) 14; 15 *) 16 echo "prerm called with unknown argument \ '$ 1'"> & 217 exit 118; 19esac20exit 0 DEBIAN/postrm file content: 01 #! /Bin/sh02set-e03case "$1" in04 05 purge) 06 rm-rf/var/lib/nginx/var/log/nginx/etc/nginx07 ;; 08 remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear) 09; 10 *) 11 echo "postrm called with unknown argument \ '$ 1'"> & 212 exit 113esac14 # Automatically added by dh_installinit15if ["$1" = "purge"]; then16 update-rc.d nginx remove>/dev/null17fi18 # End automatically added section19exit 0 DEBIAN/preinst file content: 01 #! /Bin/sh02set-e03if [! -D/var/lib/nginx]; then04 mkdir-p/var/lib/nginx05fi06 07if [! -D/etc/nginx]; then08 mkdir-p/etc/nginx/conf09 mkdir-p/etc/nginx/modules10 mkdir-p/etc/nginx/sbin11fi12 13if [! -D/var/log/nginx]; then14 mkdir-p/var/log/nginx15 touch/var/log/nginx/error. log16fi17 18 exit 0 all files have been OK, the rest is packed with 1 dpkg-B tengine/tengine_1.4.2-1 + squeeze_amd64.deb test such:
Load the ngx_http_autoindex_module.so module and add the following configuration to the configuration file: 1dso {2 load ngx_http_autoindex_module.so; 3} restart nginx. The differences between nginx and nginx are as follows: www.2cto.com
Access the nginx default Interface to uninstall the tengine package 1apt-get -- purge remove nginx