2012-08-07 194 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 

干杯!