1.
进入/etc/apache2下打开httpd.conf,
找到 #Include /private/etc/apache2/extra/httpd-vhosts.conf
去除#。
2.
而后在/etc/apache2/extra下打开httpd-vhosts.conf,
输入
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/laravel/public" /*这是目标目录*/
ServerName ps.dev /*这是虚拟域名*/
3.
最后在/etc/下打开hosts,
输入127.0.0.1 ps.dev 并保存。
4.
重启apache服务。输入sudo apachectl restart
这时候访问localhost就可以访问到laravel中public目录的index.php文件了。
如果需要访问web目录下别的工作目录,就再次去httpd.conf中把Include /private/etc/apache2/extra/httpd-vhosts.conf 加上注释字符 #