php Zend 框架 - 500 内部服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11855067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:16:41  来源:igfitidea点击:

Zend Framework - 500 Internal Server Error

php.htaccesszend-framework

提问by Nikolai Cekov

Today I create my first project with Zend Framework but when I try to connect to my project I see only "500 Internal Server Error". I add some new rows in httpd.conf file:

今天,我使用 Zend Framework 创建了我的第一个项目,但是当我尝试连接到我的项目时,我只看到“500 内部服务器错误”。我在 httpd.conf 文件中添加了一些新行:

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>

And that is my htaccess file:

那是我的 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

I read more topics for this problem but for now problem is not solved.

我阅读了有关此问题的更多主题,但目前问题尚未解决。

That is my error.log file(from server):

那是我的 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

回答by drew010

Thanks for posting the error log.

感谢您发布错误日志。

From the looks of it, you don't have mod_rewriteloaded.

从它的外观来看,你没有mod_rewrite加载。

Find your httpd.conffile and locate the line:

找到您的httpd.conf文件并找到以下行:

#LoadModule rewrite_module modules/mod_rewrite.so

Remove the #sign from the beginning of the line.

删除行首的#符号。

Next, add a new section to httpd.confthat looks like this:

接下来,添加一个新部分httpd.conf,如下所示:

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

The AllowOverridedirective is important. By default, .htaccessfiles are not processed unless allowed. This line allows .htaccessfiles in that named directory.

AllowOverride指令是很重要的。默认情况下,.htaccess除非允许,否则不会处理文件。此行允许.htaccess该命名目录中的文件。

After making those changes, restart Apache and then try loading your ZF page again.

进行这些更改后,重新启动 Apache,然后再次尝试加载您的 ZF 页面。

回答by FloydThreepwood

First of all, a better debugging. Add

首先,更好的调试。添加

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

to your virtualhost. Restart apache and reload your page. The files will be created in the specified path. There will be an exact error message wich will help you debug further.

到您的虚拟主机。重新启动 apache 并重新加载您的页面。文件将在指定的路径中创建。将有一个确切的错误消息,这将帮助您进一步调试。

回答by alex gimenez

I just had the exact same problem and the solution by drew010 did fix it indeed!

我刚刚遇到了完全相同的问题,而 draw010 的解决方案确实解决了它!

However, it seems Apache config structure changed, so the method to enable the missing module is slightly different:

但是,Apache 配置结构似乎发生了变化,因此启用丢失模块的方法略有不同:

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

This confirms you have the right stuff going:

这确认你有正确的东西:

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

Cheers!

干杯!