Compile and install nginx in Ubuntu server 9.04

Source: Internet
Author: User

 

First of all, I would like to acknowledge that this article has made a lot of reference to Kingsoft's Xiaoyao Network System Architect-Zhang banquet's nginx 0.7.x + PhP 5.2.10 (FastCGI) to build a web server that is 10 times better than Apache (version 5th) [original, thank you for your contribution to the promotion of nginx.

The reason for compiling and installing nginx in Ubuntu server 9.04 (us904) is that the official us904 source provides old versions: nginx0.6.35, and the latest official stable version of nginx is 0.7.61, the latest development version is 0.8.9 (see: http://www.nginx.org/), the following version 0.8.9 as an example for nginx compilation and installation:

First install the required software package for compiling nginx:

1. Perl 5 Compatible Regular Expression Library-development files

Sudo apt-Get install libpcre3-dev

2. SSL development libraries, header files and documentation

Sudo apt-Get install libssl-Dev

3. Make Tool

Sudo apt-Get install make

Create a user group and user for enabling nginx

Sudo groupadd WWW

Sudo useradd-G WWW

Sudo mkdir-v-P/www/htdocs/Site1

Sudo chown-r www: www/htdocs/Site1

Then download the nginx source code package.

Wget http://sysoev.ru/nginx/nginx-0.8.9.tar.gz

Start compiling and installing nginx

Tar zxvf nginx-0.8.9.tar.gz

CD nginx-0.8.9

./Configure -- user = WWW -- group = WWW -- prefix =/usr/local/webserver/nginx -- with-http_stub_status_module -- with-http_ssl_module

Sudo make

Sudo make install

Then create the nginx Service Control script program

Sudo nano/etc/init. d/nginx

Enter the following content:

#! /Bin/sh ### begin init info # provides: nginx # required-start: $ all # required-stop: $ all # default-start: 2 3 4 5 # default-stop: 0 1 6 # Short-Description: starts the nginx Web Server # description: starts nginx using start-stop-daemon ### end init infopath =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bindaemon =/usr/local/webserver/nginx/sbin/nginxname = nginxdesc = nginxtest-x $ daemon | exit 0 # include nginx defaults if availableif [-F/etc/default/nginx]; then. /etc/default/nginxfiset-e. /lib/LSB/init-functionscase "$1" instart) echo-n "Starting $ Desc: "start-stop-daemon -- start -- quiet -- pidfile/var/run/$ name. pid/-- exec $ daemon -- $ daemon_opts | true echo "$ name. "; stop) echo-n" Stopping $ Desc: "start-stop-daemon -- stop -- quiet -- pidfile/var/run/$ name. pid/-- exec $ da Emon | true echo "$ name. "; restart | force-Reload) echo-n" Restarting $ Desc: "start-stop-daemon -- stop -- quiet -- pidfile // var/run/$ name. PID -- exec $ daemon | true sleep 1 start-stop-daemon -- start -- quiet -- pidfile // var/run/$ name. PID -- exec $ daemon -- $ daemon_opts | true echo "$ name. "; RELOAD) echo-n" reloading $ DESC configuration: "start-stop-daemon -- stop -- signal hup -- quiet -- pidfile/ Var/run/$ name. pid/-- exec $ daemon | trueecho "$ name. "; Status) status_of_proc-P/var/run/$ name. PID "$ daemon" nginx & Exit 0 | exit $ ?;; *) N =/etc/init. d/$ name echo "Usage: $ n {START | stop | restart | reload | force-Reload | status}"> & 2 exit 1; esacexit 0 #! /Bin/sh ### begin init info # provides: nginx # required-start: $ all # required-stop: $ all # default-start: 2 3 4 5 # default-stop: 0 1 6 # Short-Description: starts the nginx Web Server # description: starts nginx using start-stop-daemon ### end init infopath =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bindaemon =/usr/local/webserver/nginx/sbin/nginxname = nginxdesc = nginxtest-x $ daemon | exit 0 # include nginx defaults if availableif [-F/etc/default/nginx]; then. /etc/default/nginxfiset-e. /lib/LSB/init-functionscase "$1" in START) echo-n "Starting $ Desc: "start-stop-daemon -- start -- quiet -- pidfile/var/run/$ name. pid/-- exec $ daemon -- $ daemon_opts | trueecho "$ name. "; stop) echo-n" Stopping $ Desc: "start-stop-daemon -- stop -- quiet -- pidfile/var/run/$ name. pid/-- exec $ daemon | Trueecho "$ name. "; restart | force-Reload) echo-n" Restarting $ Desc: "start-stop-daemon -- stop -- quiet -- pidfile // var/run/$ name. PID -- exec $ daemon | truesleep 1start-stop-daemon -- start -- quiet -- pidfile // var/run/$ name. PID -- exec $ daemon -- $ daemon_opts | trueecho "$ name. "; RELOAD) echo-n" reloading $ DESC configuration: "start-stop-daemon -- stop -- signal hup -- quiet -- pidfile/var/run/$ name. Pid/-- exec $ daemon | true echo "$ name. "; Status) status_of_proc-P/var/run/$ name. PID "$ daemon" nginx & Exit 0 | exit $?; *) N =/etc/init. d/$ nameecho "Usage: $ n {START | stop | restart | reload | force-Reload | status}"> & 2 exit 1 ;; esacexit 0 then you can use sudo/etc/init. d/nginx start (stop | restart | status) and other commands and parameters are used to control nginx and view the status information. As for the specific configuration of nginx, we will continue the discussion for the next time. While testing the compilation and installation, I installed nginx through sudo apt-Get install nginx on another virtual machine us904 to check the differences between the two methods, we found that nginx_0.6.35-0ubuntu1_i386.deb files mainly have the following file copy process sudo dpkg-l nginx /. /usr/sbin/nginx/usr/share/doc/nginx/changelog.gz /usr/share/doc/nginx/readme/usr/share/doc/nginx/Copyright/usr/share/doc/nginx/news.debian.gz/usr/share/doc/nginx/changelog.debian.gz /usr/share/man/usr/share/m An/Man1/usr/share/man/Man1/nginx.1.gz/etc/nginx/sites-available/default/etc/ nginx/sites-enabled/etc/nginx/CONF. d/etc/nginx/fastcgi_params/etc/nginx/Koi-UTF/etc/nginx/Koi-Win/etc/nginx/mime. types/etc/nginx. conf/etc/nginx/win-UTF/etc/init. d/etc/init. d/nginx/etc/logrotate. d/etc/logrotate. d/nginx/var/log/nginx/var/lib/nginx/var/www/var/ WWW/nginx-default/var/www/nginx-default/50x.html/var/www/nginx-default/index.html to check whether too many software packages can be installed in the production environment, directly replace the/usr/sbin/nginx file. The specific operation stability needs to be verified. PS: 1. if you do not want to enter a command with sudo, you can switch to roota as follows. sudo-s-h enter the current user password B. sudo passwd root SET Root Password su root enter Root Password 2. view the package name of a package. You can use sudo apt-cache search *** to find the package name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.