<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大鳥的學(xué)習(xí)樂園
    路漫漫其修遠(yuǎn)兮,吾將上下而求索
    posts - 26,comments - 27,trackbacks - 0

    h1. Nginx編譯,安裝配置

     

    * Nginx

    Apache知道吧,Nginx和他一也是webserver,不他比Apache快,據(jù)快很多很多,尤其是在高負(fù)荷的候。

    BTW,玩意是某俄國大牛一個人寫的......

     

    * 編譯

    ./configure --prefix=/usr/local/nginx

    make && make install

     

    * 配置虛主機(jī)

    /usr/local/nginx/conf/nginx.conf 內(nèi)容如下

    <pre>

    user www;

    worker_processes  1;

    events {

        worker_connections  1024;

    }

     

    http {

        include       mime.types;

        default_type  application/octet-stream;

        sendfile        on;

        #tcp_nopush     on;

     

        #keepalive_timeout  0;

        keepalive_timeout  65;

     

        #gzip  on;

     

        # [Add by lemon] Include vhost config

        include /usr/local/nginx/conf/vhost/www_site1_com.conf;

        include /usr/local/nginx/conf/vhost/www_site2_com.conf;

    </pre>

    /usr/local/nginx/conf/vhost/www_site1_com.conf 內(nèi)容如下

    <pre>

    server {

        listen 192.168.188.132:80;

        client_max_body_size 100M;

        server_name  www.site1.com;

        #charset gb2312;

        index index.html index.htm index.php;

        root   /home/www/site1;         #你的站點(diǎn)路徑

     

        #錄瀏覽這樣當(dāng)沒有找到index文件,就也已瀏覽中的文件

     

        autoindex  on;

     

        if (-d $request_filename) {

        rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

        }

     

        error_page  404              /404.html;

        location = /40x.html {

        root  /home/www/site1;       #你的站點(diǎn)路徑

        charset    on;

        }

     

        # redirect server error pages to the  static page /50x.html

     

        #

     

        error_page   500 502 503 504  /50x.html;

     

        location = /50x.html {

        root   /home/www/site1;      #你的站點(diǎn)路徑

        charset    on;

        }

     

        #將客端的轉(zhuǎn)fastcgi

     

        location ~ .*\.(php|php5|php4|shtml|xhtml|phtml)?$ {

     

        fastcgi_pass   127.0.0.1:9000;

     

        include /usr/local/nginx/conf/fastcgi_params;

     

        }

     

        #網(wǎng)站的多,更改少,將它瀏覽器本地15

     

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

     

        {

     

        expires      15d;

     

        }

     

        #網(wǎng)站會加很多JSCSS,將它瀏覽器本地1

     

        location ~ .*\.(js|css)?$

        {

        expires      1d;

        }

     

        location /(WEB-INF)/ {

        deny all;

        }

     

        #設(shè)定日志格式

     

        log_format  site1_access  '$remote_addr - $remote_user [$time_local] "$request" '

     

        '$status $body_bytes_sent "$http_referer" '

     

        ' "$http_user_agent" $http_x_forwarded_for';

     

        #設(shè)定本虛主機(jī)的訪問日志

     

        access_log  /home/www/site1/logs/nginx/access.log  site1_access;   #日志的路徑,個虛機(jī)一個,不能相同

     

        #防止nginxweb務(wù),server_name問題.點(diǎn)擊這看原文

        server_name_in_redirect  off;

    }

    </pre>

    /usr/local/nginx/conf/vhost/www_site2_com.conf www_site1_com.conf 基本一,只需把site1site2即可。

     

    * Nginx+PHP

    Nginx 只是一個http務(wù)器,本身不能php但它可以通fastcgi調(diào)php

    php內(nèi)置了一個fastcgi server 需要通php-fpm來啟個在編譯php需要指定參數(shù),以cgi模式編譯

    所以,Nginx只要配置把php求交fastcgi server的部分即可,剩下的事情交 fastcig server去做。

    <pre>

    location ~ \.php$ {

                root           html;

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_param SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;

                include        fastcgi_params;

            }

    </pre>

    /usr/local/nginx/html/Nginx認(rèn)DocumentRoot

     

    * 主機(jī)與IP訪問共存

    "配置虛主機(jī)"中介的方式配置虛主機(jī)以后,會發(fā)現(xiàn)如果用http://<ip>:<port>/xxx的方式無法訪問DocumentRoot/usr/local/nginx/html)下的應(yīng)用。

    解決方法:

    /usr/local/nginx/conf/vhost/下建立一個新的配置文件 localhost.conf(可以copy其他的vhost配置文件),要改的地方如下

    vim /usr/local/nginx/conf/vhost/ localhost.conf

    <pre>

    ……

    server_name  localhost;

    ……

    root   /usr/local/nginx/html;

    ……

    </pre>

    如果需要支持PHP

    <pre>

    location ~ .*\.(php|php5|php4|shtml|xhtml|phtml)?$ {

     

    fastcgi_pass   127.0.0.1:9000;

     

    fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;

     

    include /usr/local/nginx/conf/fastcgi_params;

     

    }

    ……

    </pre>

    posted on 2012-01-18 21:45 大鳥 閱讀(497) 評論(0)  編輯  收藏 所屬分類: linux
    主站蜘蛛池模板: 四虎永久精品免费观看| 成年人网站在线免费观看| 四虎在线成人免费网站| 一级女人18毛片免费| 国产高清免费的视频| 亚洲精品和日本精品| 亚洲av综合色区| 亚洲国产精品人久久电影| 久久精品国产亚洲av瑜伽| 久久www免费人成精品香蕉| 亚洲一区二区在线免费观看| 国产成人精品久久免费动漫| 女人18一级毛片免费观看| 亚洲国产精品尤物yw在线| 亚洲AV无码1区2区久久| 亚洲国产日韩在线一区| 在线观看亚洲精品专区| 国产拍拍拍无码视频免费| 欧美好看的免费电影在线观看| 亚洲电影日韩精品| 亚洲美女精品视频| 美女视频黄a视频全免费网站色 | a级片免费在线观看| 国产大片线上免费观看| 国产亚洲自拍一区| 亚洲中字慕日产2021| 永久免费精品影视网站| 亚洲黄色免费观看| 亚洲av无码乱码在线观看野外| 亚洲天堂在线播放| 免费播放国产性色生活片| 精品免费久久久久久久| 亚洲av无码成人精品区在线播放| 久久精品国产亚洲av影院| 鲁死你资源站亚洲av| 91精品国产免费| 亚洲成a人片在线观看老师| 亚洲国产超清无码专区| 一级毛片不卡免费看老司机| 日韩av无码成人无码免费| 亚洲AV无码乱码在线观看裸奔|