自訂Nginx配置不成功,為何?

來源:互聯網
上載者:User
原先我在apache中的配置如下:

RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]

作用:如果URL所指向的檔案在伺服器目錄中不存在,則將URL全指向index.php中。

結構我是按文檔中自訂Nginx配置中描述所建,Nginx我不太會用了個配置轉換工具得到在Nginx中的配置:

# nginx configurationlocation / {    if (!-e $request_filename){        rewrite ^(.*)$ /index.php break;    }}

但放到雲景的PHP空間的conf/nginx_server.inc檔案中後空間就無法開啟了,想問下為啥!

回複內容:

原先我在apache中的配置如下:

RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]

作用:如果URL所指向的檔案在伺服器目錄中不存在,則將URL全指向index.php中。

結構我是按文檔中自訂Nginx配置中描述所建,Nginx我不太會用了個配置轉換工具得到在Nginx中的配置:

# nginx configurationlocation / {    if (!-e $request_filename){        rewrite ^(.*)$ /index.php break;    }}

但放到雲景的PHP空間的conf/nginx_server.inc檔案中後空間就無法開啟了,想問下為啥!

這個問題算是解決了,最終我還是在slimphp項目的readme中找到瞭解決方法,如下:

location / {    try_files $uri $uri/ /index.php?$args;    root /opt/src/app;}

再對PHP也做了點設定:

location ~ \.php$ {    root /opt/src/app;    fastcgi_pass 127.0.0.1:8080;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /opt/src/app/$fastcgi_script_name;    include /opt/apps/nginx/conf/fastcgi_params;}

http://cloudscape.sohu.com/doc/operation/app-conf.shtml
參考文檔中的標題6,自訂Nginx配置部分

nginx的自訂配置可能與您的項目整體配置有衝突,可以登入到容器上查看相關配置,修改下配置試試看。

  • 聯繫我們

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