我正在尝试在CentOS 7 Google Compute Cloud实例上安装Opencart。我在尝试安装OC v3.0.3.2 时遇到了这个错误
Warning: fopen(/var/www/webapp/system/storage/session//sess_d637dd9f9b2bc6b85077072329): failed to open stream: Permission denied in /var/www/webapp/system/library/session/file.php on line 29Warning: flock() expects parameter 1 to be resource, bool given in /var/www/webapp/system/library/session/file.php on line 31Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/webapp/system/library/session/file.php on line 33Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/webapp/system/library/session/file.php on line 35Warning: flock() expects parameter 1 to be resource, bool given in /var/www/webapp/system/library/session/file.php on line 37Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/webapp/system/library/session/file.php on line 39
以下是我迄今为止所做的:
- 读取install.txt并相应地设置文件权限-不起作用
- 将整个webapp目录的权限设置为0777-无效
- 手动创建了file.php文件,并将权限更改为0777-无效
- 将文件所有权更改为apache:apache,并将我的用户帐户和根帐户添加到apache组,再次将权限设置为0777-不起作用
- 另外,当我尝试将Wordpress安装到同一目录时,WP安装没有权限写入config.php文件
- 我已经在少数几个不同的VM实例中尝试过这种方法。都有相同的错误
我缺少什么?
如果使用Linux,则需要使用以下命令来更改文件权限:
sudo chmod 0777 system/storage/cache/
sudo chmod 0777 system/storage/download/
sudo chmod 0777 system/storage/logs/
sudo chmod 0777 system/storage/modification/
sudo chmod 0777 system/storage/session/
sudo chmod 0777 system/storage/upload/
sudo chmod 0777 system/storage/vendor/
sudo chmod 0777 image/
sudo chmod 0777 image/cache/
sudo chmod 0777 image/catalog/
sudo chmod 0777 config.php
sudo chmod 0777 admin/config.php
以上信息也可在install.text 中的OpenCart安装包中获得
Okay终于在这篇博客文章中找到了解决方案。非常感谢作者。
显然,SELinux有另一层权限设置,尽管权限正确,但这正是apache无法编写的原因。
用chcon更改SELinux策略成功了。
以下是我修复它的方法:
-
查找文件夹应属于哪个组所有者"www root"或"apache">
#显示文件和目录的所有者和组所有者
`~$ ls -l` `drwxr-xr-x 2 www-root www-root 4096 Nov 12 09:25 website1` `-rw-r--r-- 1 root root 7598 Nov 11 05:31 website2`
-
授予适当实体的权限。在我的情况下,它是"www根"。由于您在/var/www/html中,我猜测正确的用户是";apache";。
# Grants permission to www-root sudo chown www-root:www-root -R /var/www/www-data/website # in your case, try www-data or apache sudo chown www-data:www-data -R /var/www/html/opencart
-
正确设置文件和文件夹的权限(因为文件具有执行权限可能很危险(
# Sets directory permissions to 755 (rwxr-xr-x) sudo find /var/www/html/opencart -type d -exec chmod 755 {} ; # Sets file permissions to 644 (rw-r--r--) sudo find /var/www/html/opencart -type f -exec chmod 644 {} ;
我在ubuntu权限问题上解决了我的nginx与operatncart,如下所示:
sudo chown $USER:www-data /var/www/html/opencart3037/*
sudo chmod g+s /var/www/html/opencart3037/*
sudo chmod o-rwx /var/www/html/opencart3037/
sudo chown -R www-data:www-data /var/www/html/opencart3037/
sudo chmod -R 770 /var/www/html/opencart3037/
希望有人能帮助这个代码