【集錦】nginx【php,location,alias,504】

來源:互聯網
上載者:User
【匯總】nginx【php,location,alias,504】

?? 安裝

#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/ { … }
〖=〗 表示精確匹配,如果找到,立即停止搜尋並立即處理此請求。〖~〗 表示區分大小寫匹配〖~*〗 表示不區分大小寫匹配〖^~〗 表示只匹配字串,不查詢Regex。〖@〗 指定一個命名的location,一般只用於內部重新導向請求。

?? 配置執行個體

location  = / {  # 只匹配對 / 目錄的查詢.  [ config A ]}location  / {  # 匹配以 / 開始的查詢,即所有查詢都匹配。  [ config B ]}location ^~ /images/ {  # 匹配以 /images/ 開始的查詢,不再檢查Regex。  [ 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;

?? 註:本機測試並不顯著,有時間附上配置說明

?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.