2012-08-02 33 views
0

我無法弄清楚如何使Nginx配置文件找到我的Codeigniter應用程序。在這臺服務器上服務PHP不是問題b/c,如果我把一個php文件放在我的根目錄中,我可以echo "hello world";Nginx配置文件沒有找到我的Codeigniter/PHP應用程序

這是我的Nginx配置文件,幾乎逐字從this tutorial。請注意,我操縱許多參數並且什麼都沒有的effext所以我不知道我是否需要超越這個文件來得到它的工作?:

server { 
    listen 80; 
    server_name www.mysite.com mysite.com; 
    root /var/www; 
    index index.html index.php index.htm; 
    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log; 

    location/{ 
     try_files $uri $uri/ /index.php; 
    } 

    location ~* \.php$ { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_split_path_info ^(.+\.php)(.*)$; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 

我一直沿着這條思緒萬千是一個簡單的路徑問題b/c Codeigniter有一個混亂的路由結構,但只是看不到我的配置問題。思考?

+0

您是否修改了Codeigniter的配置以使用Nginx?你的Nginx配置看起來很好。 – Abdulaziz 2012-08-02 10:42:57

+0

@AzizAG我的Codeigniter 2.1.2配置似乎標準。我有一個名爲「main」的默認控制器,通過config/config.php去掉URL中的「index.php」。我的系統,應用程序文件夾和CI index.php文件位於根目錄中。我有一個帶有通用.htaccess文件的Apache服務器,它提供了我的CI應用程序,所以我不確定是什麼問題。 – 2012-08-02 10:47:56

+0

我會給它一個沒有index.php刪除的地方,看看你是否可以得到它的工作。這至少會縮小問題的範圍。 – jpea 2012-08-02 15:49:23

回答

1

一切往上頂匹配什麼我有一個CI項目,那麼這是我的位置配置:

location ~ \.php$ { 
    include /etc/nginx/fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
} 

不知道是否通過刪除通配符*會有所幫助,或者擺脫split_info PARAM的..

+0

- @ jpea,謝謝,嗯,我剛剛複製了你的pastebin代碼(我的根目錄是/ var/www )。現在我得到了一個403 Nginx禁止的錯誤。出於絕望之後,我做了'root @ ip-xx-xxx-xx-xxx:〜#sudo chmod 777/var/www'但是這並沒有糾正403.不能說這是好還是壞? – 2012-08-02 17:08:35

+0

- @ jpea,403是特定於CI目錄/文件的,因爲從/ var/www根目錄提供了一個php文件,仍然可以正常工作。呃,真的希望我知道更好的權限... – 2012-08-02 17:35:19

相關問題