Laradock 虚拟主机无法在 mac monterey apache2 上工作
我读过很多关于这个主题的文章,但没有一个提到我所拥有的完全相同的环境(Mac OS Monterey)。所以到目前为止我所做的...
我已经成功安装了最新版本的 Docker 和 Docker。 LaraDock 与 apache2。我的 phpMyAdmin 在 localhost:8081 上工作正常。然后我按照文档和一些教程为多项目设置 laradock。
我在工作区容器内成功创建了一个 laravel9 项目(ProjectA)。我可以在浏览器中查看该网站,地址为 localhost/ProjectA/public。
我想为 ProjectA 创建一个虚拟主机,以便能够在浏览器中键入 projectA.test 并指向 localhost/ProjectA/public。
因此,我再次按照 Laradock 上的说明编辑了 laradock/apache2/sites/default.apache.conf
<VirtualHost *:80>
ServerName laradock.test
DocumentRoot /var/www/
Options Indexes FollowSymLinks
<Directory "/Users/Sites">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
并创建了 laradock/sites/projectA.conf
<VirtualHost *:80>
ServerName projectA.test
DocumentRoot /var/www/projectA/public
Options Indexes FollowSymLinks
<Directory "/var/www/projectA/public">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
</VirtualHost>
即使在 Docker 中重新启动 apache2 后,projectA.test 也不会显示正确的网站,但指向根。
在 apache2 文件夹中,有一个名为 vhost.conf 的文件,其中包含 /etc/apache2/sites-available/*.conf。当我将上面的 2 个conf 文件复制到该文件夹(以前不存在)时,我收到“禁止”错误:您无权访问此资源。 Apache/2.4.29 (Ubuntu) 服务器位于 utopia.test 端口 80。
阅读有关 apache 错误 403 的文章后,我将公共文件夹的权限更改为:
sudo chmod -R 775 public
sudo chown -R _www:_www public
drwxrwxr-x@ 15 _www _www 480 Mar 19 18:11 public
如果有人可以提供帮助,我将非常感激。
I have read many posts on the subject but none refers to exactly the same environment I have (Mac OS Monterey). So what I have done so far...
I have successfully installed the latest versions of Docker & LaraDock with apache2. I have phpMyAdmin working fine at localhost:8081. Then I followed the docs and some tutorial to set up laradock for multiproject.
I successfuly created a laravel9 project (ProjectA) inside the workspace container. I can view the website in the browser at localhost/ProjectA/public.
I want to create a virtual host for ProjectA to be able to type projectA.test in the browser and point to localhost/ProjectA/public.
So again, I followed the instructions on Laradock and edited the laradock/apache2/sites/default.apache.conf
<VirtualHost *:80>
ServerName laradock.test
DocumentRoot /var/www/
Options Indexes FollowSymLinks
<Directory "/Users/Sites">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
and created a laradock/sites/projectA.conf
<VirtualHost *:80>
ServerName projectA.test
DocumentRoot /var/www/projectA/public
Options Indexes FollowSymLinks
<Directory "/var/www/projectA/public">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
</VirtualHost>
Even after restarting apache2 in Docker, projectA.test does not display the correct website but point to the root.
In the folder apache2 there is a file called vhost.conf with Include /etc/apache2/sites-available/*.conf. When I copied the 2 conf files above into that folder (which was not there before), I get a Forbidden error : You don't have permission to access this resource. Apache/2.4.29 (Ubuntu) Server at utopia.test Port 80.
After reading an article on apache error 403, I change the permission on the public folder to be:
sudo chmod -R 775 public
sudo chown -R _www:_www public
drwxrwxr-x@ 15 _www _www 480 Mar 19 18:11 public
I would really appreciate if someone could help please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对这个问题感到非常厌倦,以至于我忘记在更改权限后重新启动 Apache...这就是窍门!
我希望这对其他人有帮助,因为我在有关该主题的任何教程或帖子中都没有找到此解决方案!
I was so tired with this issue that I forgot to restart Apache after changing permission... that was the trick!
I hope this will help others as I did not find this solution in any of the tutorials or posts on the subject!