【发布时间】:2017-10-24 13:14:13
【问题描述】:
目标 :- 正确设置虚拟主机。
目前我正在开发 MAC 系统版本 10.10.05 os x yosemite。
我已经使用XAMPP配置了apache2、php和mysql
我已经关注all the necessary steps 配置虚拟主机。
我的文件 /private/etc/apache2/extra/httpd-vhosts.conf 会像
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName emsv2l.localhost.com
ServerAlias emsv2l.localhost.com
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/emsv2"
ErrorLog "/private/var/log/apache2/apple.com-error_log"
CustomLog "/private/var/log/apache2/apple.com-access_log" common
ServerAdmin webmaster@dev.plutustec.com
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName emsv2l-backend.plutustec.com
ServerAlias emsv2l-backend.plutustec.com
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/emsv2-backend/public“
ErrorLog "/private/var/log/apache2/apple.com-error_log"
CustomLog "/private/var/log/apache2/apple.com-access_log" common
ServerAdmin webmaster@dev.plutustec.com
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2-backend/public“>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
所以,现在如果我写 http://emsv2l.localhost.com/ 将被重定向到项目而不是显示目录结构。
我的/etc/hosts 文件会是这样的
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
#127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
#127.0.0.1 dev.local
#127.0.0.1 emsv2l-backend.plutustec.com # emsv2-backend
#127.0.0.1 emsv2l.plutustec.com # emsv2
#127.0.0.1 plutustec.com #localplutus site
127.0.0.1 emsv2l.localhost.com
127.0.0.1 emsv2l-backend.plutustec.com
任何帮助将不胜感激。
【问题讨论】:
-
你可以访问apache服务吗?您可能需要重新启动 apache。
-
我多次使用 XAMPP gui 重新启动 apache。
-
@ShashankShah 你能告诉我们你在
/Applications/XAMPP/xamppfiles/htdocs/emsv2下的文件吗?那里有index.* 文件吗? -
我认为在 Apache 中,虚拟主机的顺序也很重要 + 有类似
VirtualHostName 127.0.0.1的东西。如果您想要更合理、更简单的设置,请使用 nginx。
标签: php macos laravel virtualhost