在 CentOS 6.4 中运行带有 httpd 2.4.4 的 php-fpm

在 CentOS 6.4 中运行带有 httpd 2.4.4 的 php-fpm

我从 CentOS/RHEL 6.4 附带的 httpd 2.2 升级到了 httpd 2.4.4。我在尝试使用 php-fpm 提供 Roundcube 邮件时遇到错误。我们在 Freenode 上的 #httpd 上尝试了多种解决方案。我会大大感谢任何见解。它与 httpd 2.2 配合良好。

到目前为止,我们遵循了以下指示: https://wiki.apache.org/httpd/PHP-FPM

我得到的错误是Forbidden: You don't have permission to access / on this server。错误日志显示:

[Fri Sep 06 15:26:23.542241 2013] [autoindex:error] [pid 16868:tid 140266652563200] [client 129.105.171.78:50823] AH01276: Cannot serve directory /var/www/roundcubemail/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

/etc/httpd/conf.d/ssl.conf 中的 VirtualHost

<VirtualHost *:443>
    ServerName mail.mydomain.org
    DocumentRoot /var/www/roundcubemail
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/domain.crt
    SSLCertificateKeyFile /etc/pki/tls/private/domain.key
    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/roundcubemail/$1
</VirtualHost>

/etc/httpd/conf.d/roundcubemail.conf

<Directory "/var/www/roundcubemail/">
    Options -Indexes
    SetOutputFilter DEFLATE
    AllowOverride All
    Require all granted
</Directory>

/var/www/roundcubemail/.htaccess

AddDefaultCharset     UTF-8
AddType text/x-component .htc

<IfModule mod_php5.c>
php_flag        display_errors  Off
php_flag        log_errors      On
# php_value     error_log       logs/errors

php_value       upload_max_filesize     5M
php_value       post_max_size           6M
php_value       memory_limit            64M

php_flag        zlib.output_compression         Off
php_flag        magic_quotes_gpc                Off
php_flag        magic_quotes_runtime            Off
php_flag        zend.ze1_compatibility_mode     Off
php_flag        suhosin.session.encrypt         Off

#php_value      session.cookie_path             /
php_flag        session.auto_start      Off
php_value       session.gc_maxlifetime  21600
php_value       session.gc_divisor      500
php_value       session.gc_probability  1

# http://bugs.php.net/bug.php?id=30766
php_value       mbstring.func_overload  0
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^favicon\.ico$ skins/larry/images/favicon.ico
# security rules
RewriteRule \.git - [F]
RewriteRule ^/?(README(.md)?|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ - [F]
RewriteRule ^/?(SQL|bin) - [F]
</IfModule>

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>

<IfModule mod_headers.c>
# replace 'append' with 'merge' for Apache version 2.2.9 and later
#Header append Cache-Control public env=!NO_CACHE
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</IfModule>

FileETag MTime Size

<IfModule mod_autoindex.c>
Options -Indexes
</ifModule>

答案1

这是 PHP,不是吗?你的代码VirtualHost还应该包含:

DirectoryIndex index.php

答案2

添加后

 DirectoryIndex index.php

错误

 Got error 'Primary script unknown\n'

意思是找不到 index.php,/var/www/roundcubemail您确定它在那里吗?对于 roundcube 来说,使用public_html文件夹将敏感文件放在无法触及的地方是一种很好的做法,因此您的 index.php 可能就在那里。

相关内容