`

[web architect]1. nginx on ubuntu

 
阅读更多

快速简易版

sudo apt-key add nginx_signing.key (见附件)

sudo apt-get install nginx

ls /usr/share/nginx/www/

50x.html  index.html

 

专业定制版

1.Download

1.1 Download nginx source

eric@ubuntu:~$ sudo wget http://nginx.org/download/nginx-1.3.11.tar.gz -P /opt/library
--2013-01-19 19:07:16--  http://nginx.org/download/nginx-1.3.11.tar.gz
Resolving nginx.org (nginx.org)... 206.251.255.63
Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 744064 (727K) [application/octet-stream]
Saving to: `/opt/library/nginx-1.3.11.tar.gz'

100%[================================================================================>] 744,064     39.6K/s   in 24s

2013-01-19 19:07:41 (30.0 KB/s) - `/opt/library/nginx-1.3.11.tar.gz' saved [744064/744064]

eric@ubuntu:~$ ls /opt/library/
nginx-1.3.11.tar.gz

 

1.2. Download pcre(Perl Compatible Regular Expressions/Perl兼容正则表达式库)

eric@ubuntu:~$ sudo wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.bz2 -P /opt/library/
--2013-01-19 19:15:08--  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.bz2
           => `/opt/library/pcre-8.21.tar.bz2'
Resolving ftp.csx.cam.ac.uk (ftp.csx.cam.ac.uk)... 131.111.8.80
Connecting to ftp.csx.cam.ac.uk (ftp.csx.cam.ac.uk)|131.111.8.80|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/software/programming/pcre ... done.
==> SIZE pcre-8.21.tar.bz2 ... 1174037
==> PASV ... done.    ==> RETR pcre-8.21.tar.bz2 ... done.
Length: 1174037 (1.1M) (unauthoritative)

100%[================================================================================>] 1,174,037    133K/s   in 10s

2013-01-19 19:15:24 (112 KB/s) - `/opt/library/pcre-8.21.tar.bz2' saved [1174037]

eric@ubuntu:~$ ls /opt/library/
nginx-1.3.11.tar.gz  pcre-8.21.tar.bz2

 

1.3. Download nginx-http-concat

eric@ubuntu:~$ sudo wget https://github.com/taobao/nginx-http-concat/archive/master.zip  -P /opt/library/
--2013-01-19 19:21:41--  https://github.com/taobao/nginx-http-concat/archive/master.zip
Resolving github.com (github.com)... 207.97.227.239
Connecting to github.com (github.com)|207.97.227.239|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://nodeload.github.com/taobao/nginx-http-concat/zip/master [following]
--2013-01-19 19:21:42--  https://nodeload.github.com/taobao/nginx-http-concat/zip/master
Resolving nodeload.github.com (nodeload.github.com)... 207.97.227.252
Connecting to nodeload.github.com (nodeload.github.com)|207.97.227.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7457 (7.3K) [application/zip]
Saving to: `/opt/library/master.zip'

100%[================================================================================>] 7,457       28.2K/s   in 0.3s

2013-01-19 19:21:44 (28.2 KB/s) - `/opt/library/master.zip' saved [7457/7457]

 

1.4. Download zlib

eric@ubuntu:~$ sudo wget https://github.com/feuyeux/meridians/raw/master/3rd-library/zlib-1.2.7.tar.bz2 -P /opt/library/
--2013-01-19 22:08:15--  https://github.com/feuyeux/meridians/raw/master/3rd-library/zlib-1.2.7.tar.bz2
Resolving github.com (github.com)... 207.97.227.239
Connecting to github.com (github.com)|207.97.227.239|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.github.com/feuyeux/meridians/master/3rd-library/zlib-1.2.7.tar.bz2 [following]
--2013-01-19 22:08:17--  https://raw.github.com/feuyeux/meridians/master/3rd-library/zlib-1.2.7.tar.bz2
Resolving raw.github.com (raw.github.com)... 207.97.227.243
Connecting to raw.github.com (raw.github.com)|207.97.227.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 505085 (493K) [application/x-bzip2]
Saving to: `/opt/library/zlib-1.2.7.tar.bz2'

100%[============================================================>] 505,085      146K/s   in 3.4s

2013-01-19 22:08:22 (146 KB/s) - `/opt/library/zlib-1.2.7.tar.bz2' saved [505085/505085]

 

2.Install

2.1 Unzip concat module

eric@ubuntu:~$ sudo apt-get install zip
eric@ubuntu:~$ sudo unzip -lv /opt/library/master.zip
Archive:  /opt/library/master.zip
f784090d4e6bb880bc1dc7fd37cbf908d3911efa
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2012-12-03 00:13 00000000  nginx-http-concat-master/
    7660  Defl:N     3298  57% 2012-12-03 00:13 6e88a84b  nginx-http-concat-master/README.md
     185  Defl:N      105  43% 2012-12-03 00:13 284abf20  nginx-http-concat-master/config
   15318  Defl:N     3410  78% 2012-12-03 00:13 61358738  nginx-http-concat-master/ngx_http_concat_module.c
--------          -------  ---                            -------
   23163             6813  71%                            4 files
eric@ubuntu:~$ sudo unzip /opt/library/master.zip -d /opt/
Archive:  /opt/library/master.zip
f784090d4e6bb880bc1dc7fd37cbf908d3911efa
   creating: /opt/nginx-http-concat-master/
  inflating: /opt/nginx-http-concat-master/README.md
  inflating: /opt/nginx-http-concat-master/config
  inflating: /opt/nginx-http-concat-master/ngx_http_concat_module.c
eric@ubuntu:~$ ls /opt/nginx-http-concat-master/
config  ngx_http_concat_module.c  README.md

 

2.2. Install pcre

eric@ubuntu:~$ sudo tar xjpf /opt/library/pcre-8.21.tar.bz2 -C /opt
eric@ubuntu:~$ sudo chown eric:eric /opt/pcre-8.21/
eric@ubuntu:~$ sudo chown eric:eric /opt/pcre-8.21/*
eric@ubuntu:/opt/pcre-8.21$ sudo apt-get install build-essential
eric@ubuntu:/opt/pcre-8.21$ sudo ./configure --prefix=/usr/local/pcre-8.21 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
pcre-8.21 configuration summary:

    Install prefix .................. : /usr/local/pcre-8.21
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ :
    C compiler flags ................ : -O2
    C++ compiler flags .............. : -O2
    Linker flags .................... :
    Extra libraries ................. :

    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8 support ............ : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libreadline .. : no
eric@ubuntu:/opt/pcre-8.21$ sudo make
eric@ubuntu:/opt/pcre-8.21$ sudo make install

 

2.3. Install zlib

eric@ubuntu:~$ sudo tar xjpf /opt/library/zlib-1.2.7.tar.bz2 -C /opt
eric@ubuntu:/opt/zlib-1.2.7$ sudo ./configure && sudo make && sudo make install

 

2.4. Install nginx with concat module

eric@ubuntu:/~$ sudo tar xvzf /opt/library/nginx-1.3.11.tar.gz -C /opt
eric@ubuntu:~$ sudo chown eric:eric /opt/nginx-1.3.11/
eric@ubuntu:~$ sudo chown eric:eric /opt/nginx-1.3.11/*
eric@ubuntu:/opt/nginx-1.3.11$ ./configure --prefix=/usr/local/nginx --user=eric --group=eric --with-pcre=/opt/pcre-8.21 --with-zlib=/opt/zlib-1.2.7 --add-module=/opt/nginx-http-concat-master
Configuration summary
  + using PCRE library: /opt/pcre-8.21
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using zlib library: /opt/zlib-1.2.7

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
eric@ubuntu:/opt/nginx-1.3.11$ sudo make
eric@ubuntu:/opt/nginx-1.3.11$ sudo make install

 

3. Test and Configure

eric@ubuntu:/opt/nginx-1.3.11$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.3.11
built by gcc 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configure arguments: --prefix=/usr/local/nginx --user=eric --group=eric --with-pcre=/opt/pcre-8.21 --with-zlib=/opt/zlib-1.2.7 --add-module=/opt/nginx-http-concat-master

eric@ubuntu:/opt/nginx-1.3.11$ sudo /usr/local/nginx/sbin/nginx
eric@ubuntu:/opt/nginx-1.3.11$ curl http://localhost
http://192.168.0.160/
eric@ubuntu:/opt/nginx-1.3.11$ sudo nano /usr/local/nginx/conf/nginx.conf

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics