Nginx在LAMP上的擴充

來源:互聯網
上載者:User

Nginx在LAMP上的擴充 在原來搭建好LAMP的基礎上安裝nginx [root@localhost nginx-1.0.15]# yum install libxslt-devel [root@localhost ~]# tar xf pcre-8.33.tar.gz -C /usr/src/ [root@localhost ~]# cd /usr/src/pcre-8.33/[root@localhost pcre-8.33]# ./configure && make && make install [root@localhost nginx-1.0.15]# wget http://nginx.org/download/nginx-1.0.15.tar.gz [root@localhost nginx-1.0.15]# ./configure --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=daemon --group=daemon --with-rtsig_module --with-select_module --with-poll_module --with-ipv6 --with-http_ssl_module --with-http_realip_module  --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_flv_module --with-http_perl_module --with-perl=/usr/bin/perl --http-log-path=/var/log/nginx/access.log --with-pcre --with-pcre=/usr/src/pcre-8.33/  --with-http_stub_status_module [root@localhost nginx-1.0.15]# make && make install [root@localhost conf]# vi /usr/local/nginx/conf/nginx.conf     user  daemon;worker_processes  1;error_log  /var/log/nginx/error.log  info;pid        /var/run/nginx/nginx.pid;events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                     '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for"';    access_log  /var/log/nginx/access.log  main;    sendfile        on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;    #gzip  on;    server {        listen       80;        server_name  localhost;        charset gb2312;        access_log  /var/log/nginx/access.log  main;        location / {            root   /www;            index  index.html index.htm;        }        error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   /www;        }               location ~ \.php$ {            root           /www;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /www$fastcgi_script_name;            include        fastcgi_params;        }          } [root@localhost nginx]# cd sbin/[root@localhost sbin]# lsnginx[root@localhost sbin]# ./nginx [root@localhost sbin]# lsof -i:80COMMAND   PID   USER   FD   TYPE DEVICE SIZE NODE NAMEnginx   14359   root    6u  IPv4  21618       TCP *:http (LISTEN)nginx   14360 daemon    6u  IPv4  21618       TCP *:http (LISTEN)[root@localhost sbin]# pwd/usr/local/nginx/sbin       PHP安裝 [root@localhost ~]# tar xf /softs/php-5.3.27.tar.bz2 -C /usr/src/ [root@localhost php-5.3.27]# ./configure --disable-ipv6 --with-libxml-dir=/usr --with-openssl=/usr --with-pcre-regex=/usr/local  --with-zlib=/usr --with-bz2=/usr --enable-calendar --with-curl=/usr --with-pcre-dir=/usr/local --enable-ftp --with-openssl-dir=/usr --with-gd=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib-dir=/usr/local --with-xpm-dir=/usr --with-freetype-dir=/usr/local --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash=/usr/local --enable-mbstring --with-mcrypt=/usr/local --with-mysql=/usr/local/mysql --with-mysql-sock=/var/run/mysqld/mysql5.socket --with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp=/usr --enable-sockets --enable-zip   && make && make install   [root@localhost cgi]# ./php-cgi -a -b 127.0.0.1:9000 -c /usr/local/lib/php.ini &[2] 9879[1]   宸叉姝?              ./php-cgi -a -b 127.0.0.1:9000 -c /usr/local/lib/php.ini [root@localhost cgi]# pwd/usr/src/php-5.3.27/sapi/cgi 訪問 127.0.0.1/index.php 現在只有一個php-cgi進程,當大量的並發請求時,這是不夠的。所以我用壓力測試軟體http_load測試一下 [root@localhost softs]# wget http://icn.me/http_load_tar_gz [root@localhost http_load-12mar2006]# make && make install [root@localhost www]# http_load -parallel 100 -seconds 10 url.txt  http://192.168.254.153/a.php: byte count wronghttp://192.168.254.153/a.php: byte count wronghttp://192.168.254.153/a.php: byte count wronghttp://192.168.254.153/a.php: byte count wronghttp://192.168.254.153/a.php: byte count wrong30431 fetches, 100 max parallel, 5.06531e+06 bytes, in 10 seconds166.452 mean bytes/connection3043.1 fetches/sec, 506531 bytes/secmsecs/connect: 0.272351 mean, 137.327 max, 0.012 minmsecs/first-response: 17.6569 mean, 3034.86 max, 0.097 min29934 bad byte countsHTTP response codes:  code 200 -- 497  code 404 -- 29934 當並發數為100時,掛掉了,所以我們需要差生多個php-cgi進程,這裡引入一個工具spqwn-fcgi [root@localhost spawn-fcgi-1.6.3]# wget http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-1.6.3.tar.gz [root@localhost spawn-fcgi-1.6.3]# tar xf spawn-fcgi-1.6.3.tar.gz [root@localhost spawn-fcgi-1.6.3]# cd spawn-fcgi-1.6.3[root@localhost spawn-fcgi-1.6.3]# ./configure && make && make install [root@localhost src]# spawn-fcgi -f /usr/local/bin/phpspawn-fcgi: no socket given (use either -p or -s)[root@localhost src]# spawn-fcgi -f /usr/local/bin/php-cgi -a 127.0.0.1 -u daemon -p 9000 -C 150spawn-fcgi: child spawned successfully: PID: 11498[root@localhost src]# ps -e | grep php | wc    151     604    4832 [root@localhost www]# http_load -parallel 100 -seconds 10 url.txt 33289 fetches, 100 max parallel, 432757 bytes, in 10 seconds13 mean bytes/connection3328.9 fetches/sec, 43275.7 bytes/secmsecs/connect: 0.0322589 mean, 0.809 max, 0.024 minmsecs/first-response: 29.9192 mean, 117.142 max, 8.778 minHTTP response codes:  code 200 -- 33289

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.