虚拟主机在 Fedora 22 中不起作用

虚拟主机在 Fedora 22 中不起作用

最近,我从 Ubuntu 切换到 Fedora Workstation 作为我的开发环境,以便更好地了解 centOS 服务器(也出于其他原因)。

我一直在尝试设置本地 LAMP 堆栈以用于开发。

以下是我现在所拥有的

httpd    Apache/2.4.16 (Fedora), runs as apache/apache,
         mod_php is disabled,
         handler is
         "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"

php      5.6.14

php-fpm  runs as apache/apache,
         path is /run/php-fpm/www.sock, process type is mpm_event

/etc/httpd/conf.d/php.conf

<IfModule !mod_php5.c>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
</IfModule>

我还没有真正调整过 中的任何设置/etc/httpd/conf/httpd.conf。服务器和 PHP 似乎可以很好地工作/var/www/html,但当我尝试创建新的 时VirtualHost,我得到了403所有目录。我正在尝试通过添加配置文件来创建新的虚拟主机:

/etc/httpd/conf.d/sites.conf

<VirtualHost *:80>
    ServerName site1.local
    ServerAlias site1alias.local
    DocumentRoot /home/myuser/Projects/site1/www
    <Directory /home/myuser/Projects/site1/www>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

httpd-S 服务

AH00558: httpd: Could not reliably determine the server's
fully qualified domain name, using ::1.
Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   site1.local (/etc/httpd/conf.d/sites.conf:4)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex default: dir="/run/httpd/" mechanism=default 
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48

/etc/hosts

127.0.0.1   localhost gpc local localhost.localdomain site1.local site1alias.local
::1         localhost gpc local localhost.localdomain

SELinux通过使用设置为“允许” setenforce 0(似乎显示警告但允许操作)。

每当我尝试浏览http://localhost/或时http://site1.local/,我都会得到

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

也许

AH00558: httpd: Could not reliably determine the server's
fully qualified domain name, using ::1.
Set the 'ServerName' directive globally to suppress this message

和这个有关系吗?我试过改变ServerName localhost指令,/etc/httpd/conf/httpd.conf但没有效果。我没什么主意了。我觉得我在配置中遗漏了一些东西。任何帮助或建议都将不胜感激。

编辑

参赛作品来自/var/log/httpd/error_log

[Sat Oct 31 17:29:33.253428 2015] [core:notice] [pid 844:tid 140376890374272] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sat Oct 31 17:29:33.259649 2015] [suexec:notice] [pid 844:tid 140376890374272] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Sat Oct 31 17:29:33.274149 2015] [auth_digest:notice] [pid 844:tid 140376890374272] AH01757: generating secret for digest authentication ...
[Sat Oct 31 17:29:33.275309 2015] [lbmethod_heartbeat:notice] [pid 844:tid 140376890374272] AH02282: No slotmem from mod_heartmonitor
[Sat Oct 31 17:29:33.279406 2015] [mpm_event:notice] [pid 844:tid 140376890374272] AH00489: Apache/2.4.16 (Fedora) configured -- resuming normal operations
[Sat Oct 31 17:29:33.279437 2015] [core:notice] [pid 844:tid 140376890374272] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Oct 31 17:30:18.500583 2015] [core:error] [pid 937:tid 140376476202752] (13)Permission denied: [client 127.0.0.1:42036] AH00035: access to / denied (filesystem path '/home/myuser/Projects') because search permissions are missing on a component of the path
[Sat Oct 31 17:30:18.667997 2015] [core:error] [pid 937:tid 140376459417344] (13)Permission denied: [client 127.0.0.1:42036] AH00035: access to /favicon.ico denied (filesystem path '/home/myuser/Projects') because search permissions are missing on a component of the path, referer: http://site1.local/

权限

apache/apache 755 /var/www/html/
apache/apache 755 /home/myuser/Projects/site1/

答案1

这是你的错误。仔细看看:

[Sat Oct 31 17:30:18.500583 2015] [core:error] [pid 937:tid 140376476202752] (13)Permission denied: [client 127.0.0.1:42036] AH00035: access to / denied (filesystem path '/home/myuser/Projects') because search permissions are missing on a component of the path
[Sat Oct 31 17:30:18.667997 2015] [core:error] [pid 937:tid 140376459417344] (13)Permission denied: [client 127.0.0.1:42036] AH00035: access to /favicon.ico denied (filesystem path '/home/myuser/Projects') because search permissions are missing on a component of the path, referer: http://site1.local/

发生这种情况是因为 Apache 没有权限搜索(下降,许可x)父目录之一。

要解决该问题,首先检查哪个父目录缺少适当的权限,例如使用namei -l /home/myuser/Projects/index.php。找到所有用户缺少权限的目录x,然后使用 授予正确的权限chmod a+x /directory

答案2

错误 could not restrict fqdn 与此无关,您可以通过在 /etc/hosts 中添加一个条目来解决此问题,该条目包含您的外部 ip 和主机名。关于 php 错误:apache 日志中有什么内容吗?

编辑:

请检查 /home/myuser/Projects 的权限,它必须可供 httpd 用户 apache 读取(至少 rx)

相关内容