2012-08-07 193 views
7

今天我用Zend Framework創建了我的第一個項目,但是當我嘗試連接到我的項目時,我只看到「500內部服務器錯誤」。我在httpd.conf文件中添加一些新行:Zend Framework - 500內部服務器錯誤

NameVirtualHost *:80 
<VirtualHost *:80> 
DocumentRoot C:\AppServ\www\data1\public 
ServerName my_ip 
</VirtualHost> 

NameVirtualHost *:80 
<VirtualHost *:80> 
DocumentRoot C:\AppServ\www\data1\public 
ServerName http://my_ip 
</VirtualHost> 

這是我的htaccess文件:

RewriteEngine On 
#RewriteBase data1/public/ 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|html|pps)$ index.php [NC,L] 

order allow,deny 
allow from all 

我讀更多的主題這個問題,但現在的問題不就解決了。

這是我的error.log文件(從服務器):

[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts 
PHP Warning: PHP Startup: Unable to load dynamic library 'C:/AppServ\\php5  \\ext\\php_exif.dll' - \xd3\xea\xe0\xe7\xe0\xed\xe0\xf2\xe0 \xef\xf0\xee\xf6\xe5\xe4 \xf3\xf0\xe0 \xed\xe5 \xe5 \xed\xe0\xec\xe5\xf0\xe5\xed\xe0.\r\n in Unknown on line 0 
[Wed Aug 08 01:46:02 2012] [notice] Apache/2.2.8 (Win32) PHP/5.2.6 configured -- resuming normal operations 
[Wed Aug 08 01:46:02 2012] [notice] Server built: Jan 18 2008 00:37:19 
[Wed Aug 08 01:46:02 2012] [notice] Parent: Created child process 2392 
[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts 
[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts 
PHP Warning: PHP Startup: Unable to load dynamic library 'C:/AppServ\\php5\\ext\\php_exif.dll' - \xd3\xea\xe0\xe7\xe0\xed\xe0\xf2\xe0 \xef\xf0\xee\xf6\xe5\xe4\xf3\xf0\xe0 \xed\xe5 \xe5 \xed\xe0\xec\xe5\xf0\xe5\xed\xe0.\r\n in Unknown on line 0 
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Child process is running 
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Acquired the start mutex. 
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Starting 64 worker threads. 
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Starting thread to listen on port 80. 
[Wed Aug 08 01:46:15 2012] [alert] [client 46.40.124.225] C:/AppServ/www/data1/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration 
+0

你的服務器error.log文件說什麼?它幾乎總是有幫助的。 – FloydThreepwood 2012-08-07 22:41:35

+0

在您的php.ini文件中添加以下行:error_reporting = E_ALL; display_errors = 1.它應該告訴你這個錯誤,而不是給你一個內部服務器錯誤。確保您重新啓動服務器以使更改生效。 – Johnnyoh 2012-08-07 22:49:03

回答

16

感謝您發佈錯誤日誌。

從外觀上看,您沒有裝入mod_rewrite

找到你httpd.conf文件並找到行:

#LoadModule rewrite_module modules/mod_rewrite.so 

從行的開頭刪除#跡象。

接下來,添加一個新節httpd.conf,看起來像這樣:

<Directory "C:/AppServ/www/data1/public"> 
    Options FollowSymLinks 
    AllowOverride All 
</Directory> 

AllowOverride指令是很重要的。默認情況下,除非允許,否則不會處理.htaccess文件。該行允許在該指定目錄中的.htaccess文件。

做出這些更改後,重新啓動Apache,然後再次嘗試加載ZF頁面。

+0

非常感謝我開始我的頁面歡迎使用Zend Framework! 這是您的項目的主頁。 – 2012-08-07 23:11:44

+0

聽起來像是照顧它,以確保.htaccess工作,看看你是否可以訪問'yoursite。com/index/index'以確保它成功地將控制器和操作名稱路由到前端控制器。如果有效,那麼你的重寫規則都是正確設置的。 – drew010 2012-08-07 23:14:57

+0

是的,my_ip/index/index工作 – 2012-08-07 23:16:42

3

首先,一個更好的調試。向您的虛擬主機添加

ErrorLog "PATH_TO/zfapp-error_log" 
    CustomLog "PATH_TP/zfapp-access_log" combined 

。重新啓動Apache並重新加載您的頁面。這些文件將在指定的路徑中創建。將有一個確切的錯誤信息,這將有助於您進一步調試。

0

我剛剛有完全相同的問題,drew010的解決方案確實解決了它的問題!

然而,似乎Apache的配置結構發生變化,所以使缺少模塊的方法略有不同:

$ cd /etc/apache2/mods-enabled 
$ sudo ln -s ../mods-available/rewrite.load ./rewrite.load 

這證明你有本事去:

$ cd /etc/apache2/mods-enabled 
$ cat ./rewrite.load 
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so 

乾杯!