PHP 虚拟主机的设置问题

PHP virtualhost's settings issue

我有一个可用的虚拟主机设置给我们

Listen 1234

<VirtualHost *:1234>
  DocumentRoot "/Users/localuser/sites/testphp"
  ServerName localhost
  ErrorLog "/private/var/log/apache2/testphp-error_log"
  CustomLog "/private/var/log/apache2/testphp-access_log" common 
</VirtualHost>

<Directory "/Users/localuser/sites/">
    AllowOverride All
    Options Indexes MultiViews FollowSymLinks
    Require all granted
</Directory>

PHP 页面可由 url localhost:1234.

访问

现在我需要添加另一个项目,但我想将它放到不同的文件夹中 sites。 所以我添加另一个虚拟主机设置为

Listen 1235

<VirtualHost *:1235>
  DocumentRoot "/Users/localuser/Desktop/PE_RS/Projekty/php/hello-slim/public"
  ServerName localhost
  ErrorLog "/private/var/log/apache2/hello-slim-error_log"
  CustomLog "/private/var/log/apache2/hello-slim-access_log" common
</VirtualHost>

<Directory "/Users/localuser/Desktop/PE_RS/Projekty/php/">
    AllowOverride All
    Options Indexes MultiViews FollowSymLinks
    Require all granted
</Directory>

但在这种情况下,我得到的是 localhost:1235

Forbidden

You don't have permission to access / on this server.

不知道有没有关系,我已经在httpd-userdir.conf UserDir sites.

里设置了

感谢您的帮助。

总的来说,设置没问题。该问题与 folder/file 权限有关。我认为在桌面上设置 PHP 项目文件夹是错误的。将其移入 ~ 并通过命令 sudo chmod -R 777 php 修复权限后(此解决方案的本质)一切正常!

灵感来自 askubuntu.com...