Xampp虚拟主机错误500应该怎么解决?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (150)

我在Mac OS上使用xampp,并且想在其上添加虚拟主机

在apaceh配置上使用此代码

<VirtualHost 127.0.0.1:80>
    ServerName mvcproject.local
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/mvcproject/public"
</VirtualHost>
<Directory "/Applications/XAMPP/xamppfiles/htdocs/mvcproject/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
</Directory>

像这样改变我的主机

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1 Masouds-MacBook-Pro.local # added by Apache Friends XAMPP
127.0.0.1 mvcproject.local

出现这个错误

Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.

error 500 mvcproject.local Apache/2.4.33 (Unix) OpenSSL/1.0.2o PHP/7.2.5 mod_perl/2.0.8-dev Perl/v5.16.3

怎么解决这个问题?

提问于
用户回答回答于

这些有助于在Mac上创建虚拟主机

  1. /Applications/XAMPP/xamppfiles/etc/httpd.conf 在这个文件中取消注释包含行 Virtual hosts Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
  2. 将网站添加到vhosts文件 /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf My custom host
<VirtualHost *:80>
    ServerName mysite.local
    DocumentRoot "/Users/yourusername/path/to/your/site"
    <Directory "/Users/yourusername/path/to/your/site">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/mysite.local-error_log"
</VirtualHost>

编辑主机文件

     sudo nano /etc/hosts
    #Add the following line
    127.0.0.1 mysite.local

重新启动你的XAMPP

扫码关注云+社区

领取腾讯云代金券