Apache-2.4

httpd 無法訪問外部目錄-moodle

  • April 28, 2020

我正在 rhel 實例中安裝 moodle 。我想將目錄“moodle”保留在 /var/www/http 之外。我遵循了這個文件。為了定義moodle目錄,我將/etc/httpd/conf/httpd.conf文件更新如下:

<Directory "/usr/moodle_dir/moodle">
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Alias /moodle "/usr/moodle_dir/moodle" 

所有moodle內容都在moodle目錄中。我禁用了 SELinux setenforce 0

我將文件權限設置為:

chown -R apache:apache /usr/moodle_dir   

當我在瀏覽器中點擊 URL 時,它說

您無權訪問此伺服器上的 /moodle。

誰能讓我知道問題出在哪裡?(當我將moodle目錄放在www/http中時,瀏覽器中載入了moodle頁面。)php版本7.3,rhel:7.7。Moodle 3.8.2

$$ the latest $$ 更新: 我在 /var/www/html/test 中添加了一個目錄,<Directory並相應地更新了條目Alias。然後它起作用了。這意味著,目錄引用正在工作。還有其他東西阻止 httpd 訪問外部 www/html 目錄。

使用 Apache 2.4,

Order allow,deny
Allow from all

應該替換為

Require all granted

檢查您的 php.ini,如果 open_basedir 尚未設置為 /var/www/html/…

; open_basedir, if set, limits all file operations to the defined directory
; and below.  This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
; http://php.net/open-basedir
;open_basedir =

另外,您是否正在使用 fpm-php,檢查程序所有者以及是否在其配置中設置了 chroot,例如。/etc/php/7.0/fpm/pool.d/www.conf:

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =

引用自:https://serverfault.com/questions/1014344