最近在 CentOS 6.x / 7.x 安裝 ownCloud 時,都會出現下面的畫面[@more@]經過反覆的測試,發現應該是 SElinux 造成的問題
只要暫且把 SELinux 關閉
# setenforce 0
可以在 owncloud 目錄下的 README.SELinux 中提到
NOTE: IF YOU INSTALLED FROM THE OFFICIAL OWNCLOUD RPM, YOU DO NOT NEED TO
FOLLOW THE INSTRUCTIONS BELOW! THEY HAVE ALREADY BEEN DONE FOR YOU!
If you are running Fedora 16 with SELinux enabled, you need to relabel the
ownCloud installation directory to allow the webserver to store files there.
To do that, execute the following commands as user root AFTER you installed
ownCloud:
# semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/owncloud/data’
# restorecon ‘/var/www/html/owncloud/data’
# semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/owncloud/config’
# restorecon ‘/var/www/html/owncloud/config’
To remove the ownCloud directory label execute the following commands as
user root AFTER you uninstalled ownCloud:
# semanage fcontext -d -t httpd_sys_rw_content_t ‘/var/www/html/owncloud/data’
# restorecon ‘/var/www/html/owncloud/data’
# semanage fcontext -d -t httpd_sys_rw_content_t ‘/var/www/html/owncloud/config’
# restorecon ‘/var/www/html/owncloud/config’
Note: all of the above applies only to the default policies. If you modified
them, please give the webserver write-access to the directories
/var/www/html/owncloud/data and /var/www/html/owncloud/config
Note: for non-Fedora / Redhat systems running SELinux the policy might be
called differently.
Enjoy you own Cloud!
只要是用 rpm 來安裝的,就可以不用做設定,但即使做了設定也沒有用
解決方式:
1. 關閉 SELinux,這是我最不建議的
# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
重新開機
# reboot
2. 設定目錄擁有者及 SELinux
# chown -R apache:apache /var/www/html/owncloud/data
# chown -R apache:apache /var/www/html/owncloud/config
# chcon -R -t httpd_sys_rw_content_t /var/www/html/owncloud/config
# chcon -R -t httpd_sys_rw_content_t /var/www/html/owncloud/data
# chcon -R -t httpd_sys_rw_content_t /var/www/html/owncloud/apps