【要約】nginx【php,location,alias,504】

2783 ワード

詳細
インストール
#tar -zxvf nginx-1.0.5.tar.gz
#cd nginx-1.0.5
#./configure --prefix=/usr/local/nginx
#make
#make install

 
 
開始
//   
#/usr/local/nginx/sbin/nginx

//   
#/usr/local/nginx/sbin/nginx -s reload
#/usr/local/nginx/sbin/nginx -s reopen

 
 
構成1-PHP(fastcgiインストール)
構成2-Alias
....

http {
    ....

    server {
        ....

        # http://.../a/
        location /a/ {
            alias /var/www/a/;
        }

        # http://.../a/*.php
        location ~ /a/.+\.php$ {
            rewrite    /a/(.+\.php) /$1 break;
            alias    /var/www/a/;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index    index.php;
            fastcgi_param    SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include    fastcgi_params;
        }

        # http://.../
        location / {
            alias /var/www/root/;
        }

        # http://.../*.php
        location ~* \.(php)$ {
            alias    /var/www/root/;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index    index.php;
            fastcgi_param    SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include    fastcgi_params;
        }
    }
}
 
 
aliasでrewriteを使用する必要性について:
参照先:http://www.pppei.net/blog/post/133
 
 
nginxのlocationルールについて
参照先:https://wangyan.org/blog/nginx-location.html
location [=|~|~*|^~|@] /uri/ { … }
〖=〗       ,    ,              。
〖~〗          
〖~*〗           
〖^~〗         ,        。
〖@〗        location,            。

構成インスタンス
location  = / {
  #      /      .
  [ config A ]
}
location  / {
  #     /      ,        。
  [ config B ]
}
location ^~ /images/ {
  #     /images/      ,         。
  [ config C ]
}
location ~* \.(gif|jpg|jpeg)$ {
  #    gif, jpg, or jpeg     ,      config C。
  [ config D ]
}
 
 
nginx 504 Gateway Time-outを解決するいくつかの方法
参照先:http://blog.csdn.net/tengzhaorong/article/details/5814905
fastcgi_buffers 2 256k;
fastcgi_buffer_size 128K;
fastcgi_busy_buffers_size 256K;
fastcgi_temp_file_write_size 256K;

注:本機のテストは顕著ではなく、構成説明を添付する時間がある
 
  • nginx-1.0.5.tar.gz (646.6 KB)
  • ダウンロード回数:3