简体   繁体   English

PHP:使用 WAMP 的内部服务器错误(启动时)

[英]PHP:Internal Server Error using WAMP (at startup)

i had a problem wth php.It display error like below.我遇到了 php 的问题。它显示如下错误。 It work well in other computer, but when i tried to run it in another computer it display error like below.它在其他计算机上运行良好,但是当我尝试在另一台计算机上运行它时,它显示如下错误。 I think i had a problem with my wampserver 2.0 configuration.我想我的 wampserver 2.0 配置有问题。

Internal Server Error内部服务器错误

The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.服务器遇到内部错误或配置错误,无法完成您的请求。请联系服务器管理员,webmaster@localhost 并告知他们错误发生的时间,以及您可能执行的任何可能导致错误的操作。更多信息有关此错误的信息可能在服务器错误日志中可用。

Its due to mod_rewrite .它是由于mod_rewrite WAMP had commented this option by default.默认情况下, WAMP已评论此选项。

You need to go to WAMP icon in notification area, Apache, httpd.config您需要转到通知区域中的WAMP图标、Apache、 httpd.config

search for mod_rewrite , and uncomment it.搜索mod_rewrite ,然后取消注释。

After that RESTART WAMP AND YOU ARE DONE!之后重新启动WAMP ,您就完成了!

This is because mod_rewrite module is disabled in your Apache's configuration:这是因为您的 Apache 配置中禁用了 mod_rewrite 模块:

  1. If your website is hosted at local machine you can simply open httpd.conf in Apaches's conf folder and search for "mod_rewrite".如果您的网站托管在本地计算机上,您只需在 Apaches 的 conf 文件夹中打开 httpd.conf 并搜索“mod_rewrite”。 If mod_rewrite line is having a # in front of it, just remove this #, save file, and restart Apache.如果 mod_rewrite 行前面有 #,只需删除此 #,保存文件,然后重新启动 Apache。

  2. If your website is hosted at shared hosting server then you may not have privileges to make changes in Apache's configuration.如果您的网站托管在共享托管服务器上,那么您可能无权更改 Apache 的配置。 So you have to ask your hosting administrator to enable mod_rewrite module for you.所以你必须让你的主机管理员为你启用 mod_rewrite 模块。 This is already enabled by almost every shared hosting provider.几乎每个共享托管服务提供商都已启用此功能。

This is mod_rewrite problem, just enable mod_rewrite in your apache server or tell your website hosting company to enable it for you.这是 mod_rewrite 问题,只需在您的 apache 服务器中启用 mod_rewrite 或告诉您的网站托管公司为您启用它。 This will make your site work.这将使您的网站正常工作。

Although everyone says the same, I want to add the answer based on some information I collected from this site .虽然大家都这么说,但我还是想根据我从本站收集到的一些信息来补充一下答案。

This kind of error is happened if apache mod_rewrite feature of your server is not enabled.如果您的服务器的 apache mod_rewrite 功能未启用,则会发生这种错误。 By default WAMP server does not load this Apache Mod Rewrite module.默认情况下,WAMP 服务器不加载此 Apache Mod Rewrite 模块。 It is disabled by default.默认情况下禁用。 You have to enable a this option to load this module.您必须启用此选项才能加载此模块。 There is line in WAMP Apache configuration file about this but that is commented by default. WAMP Apache 配置文件中有关于此的行,但默认情况下已注释。 To enable this mod_rewrite feature follow this instruction.要启用此 mod_rewrite 功能,请遵循此说明。

  • Look at Wamp icon in notification area on system tray (near Clock in Windows OS)查看系统托盘通知区域中的 Wamp 图标(Windows 操作系统中的时钟附近)
  • Click on the WAMP icon单击 WAMP 图标
  • Go to Apache>httpd.config转到 Apache>httpd.config
  • A Configuration file will be opened in “Note Pad” or your default text editor.配置文件将在“记事本”或您的默认文本编辑器中打开。
  • Search the text “mod_rewrite” , you will find a line “#LoadModule rewrite_module modules/mod_rewrite.so“搜索文本“mod_rewrite”,你会发现一行“#LoadModule rewrite_module modules/mod_rewrite.so”
  • Uncomment this line by removing the Hash “#” from the beginning of the line.通过从行的开头删除哈希“#”来取消注释该行。
  • Save the file Restart WAMP Server by clicking “Restart All Services” from WAMP menu.通过单击 WAMP 菜单中的“重新启动所有服务”保存文件重新启动 WAMP 服务器。 YOU ARE DONE!你完成了!

I had this problem but the rewrite module was already enabled.我有这个问题,但重写模块已经启用。 There is a header command in the shops .htaccess file that was causing it.商店 .htaccess 文件中有一个标题命令导致它。 Enabling the headers_module in apache fixed it.在 apache 中启用 headers_module 修复了它。 Thought this might help someone.认为这可能对某人有所帮助。

For anyone finding this question, and mod_rewrite is ALREADY enabled...对于任何发现这个问题的人,并且 mod_rewrite 已经启用...

Check that WAMP hasn't put an unwanted .htaccess file in the root of the C:\ drive.检查 WAMP 是否没有在 C:\ 驱动器的根目录中放置不需要的 .htaccess 文件。

This happened to me, I think after experimenting with different settings in the httpd.conf file.这发生在我身上,我想在尝试了 httpd.conf 文件中的不同设置之后。

After I'd reverted my httpd.conf settings I started seeing the Internal Server Error.在我恢复我的 httpd.conf 设置后,我开始看到内部服务器错误。 Deleting the .htaccess file fixed the problem.删除 .htaccess 文件解决了这个问题。

Definitely do what hunzaboy suggests first.一定要先按照 hunzaboy 的建议去做。 Then if you're still getting the error, I found that one of my directives in my httpd-vhosts.conf file was causing the same error to persist even after taking his advice.然后,如果您仍然收到错误,我发现我的 httpd-vhosts.conf 文件中的一个指令导致相同的错误即使在接受他的建议后仍然存在。 I commented the line: "Require all granted" (which worked using a newer version of Apache) and everything was fine.我评论了这一行:“要求所有授予”(使用较新版本的 Apache),一切都很好。

这必须在中注释:LoadModule rewrite_module modules/mod_rewrite.so

检查 Wampserver 日志文件,此问题与您的 Apache 配置中的某些内容有关。

If you find mod_rewrite already uncommented and still you get the same error.如果您发现mod_rewrite已经取消注释,但您仍然会收到相同的错误。 Go and check if the headers_module is enabled or not.去检查headers_module是否启用。 For that you can follow below steps.为此,您可以按照以下步骤操作。

  1. Left click on wamp icon in the notification area.左键单击通知区域中的 wamp 图标。
  2. Hover to Apache悬停到Apache
  3. Hover to Apache Modules悬停到Apache Modules
  4. Click on headers_module点击headers_module

Now wait for wamp server to restart and check If it works.现在等待 wamp 服务器重新启动并检查它是否有效。

I had same issue, but the problem wasn't on all my websites, it was only on one.我有同样的问题,但问题不在我所有的网站上,它只在一个网站上。

So just make sure you don't have following code in your .htaccess file:因此,请确保您的.htaccess文件中没有以下代码:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM