403错误-Apache VirtualHost -Ubuntu 22.04
我最近安装了Ubuntu 22.04,并尝试在其上使用灯。 但是我对VirtualHost有问题。 我想在以下本地域中使用VirtualHosts:test.local 我将此域添加到 /etc /hosts中,然后将此配置添加到我的test.local.conf:
<VirtualHost *:80>
ServerName test.local
ServerAdmin webmaster@localhost
DocumentRoot /home/soroush/Sites/test
<Directory "/home/soroush/Sites/test" >
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
然后运行:a2ensite test.local.conf 但是,当我打开测试时。局域网在浏览器中,Apache向我显示了403个错误。 站点/测试文件夹和文件具有0777权限,所有者是我的用户名。 解决此问题我该怎么办?
i recently install ubuntu 22.04 and try to use LAMP on it.
but i have problem with VirtualHost.
i want use virtualhosts with a local domain like: test.local
i added this domain to /etc/hosts and add this configuration to my test.local.conf:
<VirtualHost *:80>
ServerName test.local
ServerAdmin webmaster@localhost
DocumentRoot /home/soroush/Sites/test
<Directory "/home/soroush/Sites/test" >
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
and then run: a2ensite test.local.conf
but when i open test.local in my browser, apache show me a 403 error.
Sites/test folder and files have 0777 permission and owner is my username.
what i should to do for fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将您的用户添加到Apache组,然后工作正常
sudo usermod -g www -data&lt; your_username&gt;
Add your user to the apache group then it's working fine
sudo usermod -g www-data <YOUR_USERNAME>
这与以前提供更好安全性的发行版不同
开箱即用。
解决问题:
将源代码移至/var/www
示例:/var/www/site
2.将您的VirtualHost提交
This is different to previous releases which provides better security
out of the box.
To solve the problem:
Move your source code to /var/www
Example: /var/www/site
2.Fix your Virtualhost
所有TIHS信息都可以,我只在 /etc /hosts文件中添加一排我的网站:
127.0.0.1 my-Site
All tihs info are ok, I only add a row of my site into the /etc/hosts file:
127.0.0.1 my-site
我的求解是降级到20.04;)对不起,如果我不能给您更好的解决方案。
my soluttion was a downgrade to 20.04 ;) sorry if I can't give you a better solution.