简体   繁体   English

在 CentOS 中更改 apache2 httpd 的 RootDirectory

[英]Change RootDirectory for apache2 httpd in CentOS

OK.好的。 I know this topic sounds like it's been asked a thousand times and has been answered a million times.我知道这个话题听起来好像被问了一千次,也被回答了一百万次。 And it has been asked so many times and there are so many answers.它被问了很多次,答案也很多。

However, I haven't been able to diagnose why is my configuration not working.但是,我无法诊断为什么我的配置不起作用。 Here/s my situation:这是我的情况:

I've setup a CentOS7 system for my web development and have managed to install apache2 httpd on it.我已经为我的网络开发设置了一个 CentOS7 系统,并设法在它上面安装了 apache2 httpd。

On normal setup it works just fine and successfully shows the index.html file i've put in the folder:在正常设置中,它工作得很好,并成功显示了我放在文件夹中的 index.html 文件:

//var/www/html'

Here's the permission for the index.html:这是 index.html 的权限: 在此处输入图像描述

Now I've changed the configuration file现在我已经更改了配置文件

/etc/httpd/conf/httpd.conf

and made the following changes:并进行了以下更改:

   DocumentRoot "/home/ftpuser"

#
# Relax access to content within /var/www.
#
<Directory "/home/ftpuser">
    AllowOverride None
    # Allow open access:
        Require all granted
    </Directory>

    # Further relax access to the default document root:
    <Directory "/home/ftpuser">

Changed the DocumentRoot to '/home/ftpuser'.将 DocumentRoot 更改为“/home/ftpuser”。 and changed the same value for both Directory Directives and I get this:并为两个目录指令更改了相同的值,我得到了这个:

在此处输入图像描述 I've double checked the file permissions and ownership and made sure everything is the same as the /var/www/html folder/ But apache2 still shows the same error message.我仔细检查了文件权限和所有权,并确保一切都与/var/www/html文件夹/相同,但 apache2 仍然显示相同的错误消息。

Now if I change the directory to somewhere inside the /var/www and change the httpd.conf parameters accordingly then the server works fine.现在,如果我将目录更改为/var/www内的某个位置并相应地更改httpd.conf参数,则服务器可以正常工作。

I've tried everything before posting a question.在发布问题之前我已经尝试了一切。 So please give me details on what I've missed.所以请给我详细说明我错过了什么。 I've tried all day and haven't been able to find the right answer.我已经尝试了一整天,但一直没能找到正确的答案。 I've also been referring to this resource online: Centos:httpd directives我也一直在网上参考这个资源: Centos:httpd directives

PS: I haven't looked too much in detail about using VirtualHosts. PS:我没有详细了解如何使用 VirtualHosts。 I wanted to configure the main server and use it from my home directory /home/ftpuser .我想配置主服务器并从我的主目录/home/ftpuser使用它。

Had you checked the error_log, it would have probably told you the error was a filesystem permissions error as opposed to a "server configuration" error.如果您检查了 error_log,它可能会告诉您该错误是文件系统权限错误,而不是“服务器配置”错误。

/home/ftpuser needs to be world-readable for the apache user to serve files from it (also world-executable if you enable htaccess) /home/ftpuser 需要是世界可读的,apache 用户才能从中提供文件(如果启用 htaccess,也是世界可执行的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM