在 Centos 7 上设置虚拟主机的权限

在 Centos 7 上设置虚拟主机的权限

我正在阅读一本书中有关设置虚拟主机的章节。其过程是:

1.创建一个文件/etc/httpd/conf.d/example.com.conf 2.将其内容设置为

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot    /var/www/html/example/
</VirtualHost>

最后

3.执行apachectl configtestapachectl graceful

这似乎正在发挥作用。但更常见的是,DocumentRoot位于/home/exampleuser/public_html.这条路径对apache组来说是有问题的,所以我修改了权限

drwxr-x--- 3 exampleuser apache 4096 Feb  8 09:50 exampleuser
drwxr-xr-x 2 exampleuser apache 4096 Feb  8 09:55 public_html

其中exampleuser是目录所属的用户,是使用useradd exampleuser命令创建的。

我还添加了此代码/etc/httpd/conf/httpd.conf并重新加载了 httpd.service。

<Directory “/home/exampleuser/public_html”>
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
</Directory>

书上没有说明什么是正确的权限配置,所以我想知道我是否做得正确?如果我保留现在的权限,是否会出现安全问题?

httpd error_log 文件

[Wed Feb 08 10:25:55.453239 2017] [mpm_prefork:notice] [pid 4848] AH00171: Graceful restart requested, doing restart
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using example.com. Set the 'ServerName' directive globally to suppress this message
[Wed Feb 08 10:25:55.732490 2017] [auth_digest:notice] [pid 4848] AH01757: generating secret for digest authentication ...
[Wed Feb 08 10:25:55.733391 2017] [lbmethod_heartbeat:notice] [pid 4848] AH02282: No slotmem from mod_heartmonitor
[Wed Feb 08 10:25:55.736501 2017] [:warn] [pid 4848] NSSSessionCacheTimeout is deprecated. Ignoring.
[Wed Feb 08 10:25:55.745349 2017] [mpm_prefork:notice] [pid 4848] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4 mod_fcgid/2.3.9 mod_nss/1.0.14 NSS/3.21 Basic ECC configured -- resuming normal operations
[Wed Feb 08 10:25:55.745375 2017] [core:notice] [pid 4848] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

答案1

配置中的引号是什么?

<Directory “/home/exampleuser/public_html”>

尝试:

<Directory "/home/exampleuser/public_html">

并查看登录/var/log

相关内容