gpt4 book ai didi

linux - 如何将 DocumentRoot 更改为自定义文件夹

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:25:13 26 4
gpt4 key购买 nike

我使用 CentOS 5.8 获​​得了我的新 VPS 服务器,我还不能转移我的域,但我想通过 http://my-server-ip 访问我的站点,因为我使用的是 laravel框架 我需要将默认 DocumentRoot httpdocs 更改为 httpdocs/public 我试图将这些行放入 httpd.conf 文件:

<VirtualHost my-server-ip:80>
DocumentRoot /var/www/vhosts/my.domain.org/httpdocs/public
ServerName my.domain.org
</VirtualHost>

然而,在重新启动 apache 后,它会这样警告我:警告:DocumentRoot [/public] 不存在

我该怎么办?

最佳答案

您需要启用目录的读取(可能还有执行)权限。以 root 身份尝试:

# Recursively set the owner of this folder to 'www'
chown -R www /var/www/vhosts/my.domain.org/httpdocs/public

# Recursively give the owner read and execute privileges
chmod -R u+rx /var/www/vhosts/my.domain.org/httpdocs/public

作为某些设置的替代方案,用户可能被称为nobody。因此,如果 www 不起作用,请尝试:

chown -R nobody /var/www/vhosts/my.domain.org/httpdocs/public

编辑:作为用户 tink在评论中指出“...在 Centos 中,运行 apache 的用户被恰本地称为 apache。在 debian 及其衍生产品中,它是 www-data。”

关于linux - 如何将 DocumentRoot 更改为自定义文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13979588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com