lnmp取消nginx目錄PHP執行許可權

來源:互聯網
上載者:User

   首先要編輯nginx的虛擬機器主機配置,在fastcgi的location語句的前面按下面的內容添加:

  1、單個目錄去掉PHP執行許可權

  location ~ /attachments/.*.(php|php5)?$ {

  deny all;

  }

  將attachments目錄的PHP執行許可權去掉。

  2、多個目錄去掉PHP執行許可權

  location ~ /(attachments|upload)/.*.(php|php5)?$ {

  deny all;

  }

  將attachments、upload這二個目錄的PHP執行許可權去掉。

  附上一個完整的虛擬機器主機的例子供參考:

  server

  {

  listen 80;

  server_name www.45it.com;

  index index.html index.htm index.php;

  root /home/wwwroot/bbs.vpser.net;include discuz.conf;

  location ~ /(attachments|upload)/.*.(php|php5)?$ {

  deny all;

  }

  location ~ .*.(php|php5)?$

  {

  fastcgi_pass unix:/tmp/php-cgi.sock;

  fastcgi_index index.php;

  include fcgi.conf;

  }

  access_log off;

  }

  添加完執行:/usr/local/nginx/sbin/nginx -t測試組態檔案,執行:/usr/local/nginx/sbin/nginx -s reload 載入設定檔使其生效。

  註:注意順序,一定要放在 “location ~ .*.(php|php5)?$” 一行上面,不然不會生效。

相關文章

聯繫我們

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