我在mac os上使用xampp,我想在其上添加虚拟主机
我在apaceh config上使用此代码
<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.
错误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
我该如何解决这个问题?! 感谢!
答案 0 :(得分:0)
这些有助于在mac上创建虚拟主机
/Applications/XAMPP/xamppfiles/etc/httpd.conf
取消注释
包括行
Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
将您的网站添加到vhosts文件中
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
我的自定义主机
<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