【问题标题】:Opencart Fresh Installation Error: Failed to open stream: Permission deniedOpencart全新安装错误:无法打开流:权限被拒绝
【发布时间】:2020-07-23 08:59:18
【问题描述】:

我正在尝试在 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 并将我的用户帐户和 root 帐户添加到 apache 组,再次将权限设置为 0777 - 无效。
  • 另外,当我尝试将 Wordpress 安装到同一目录时,WP 安装没有写入 config.php 文件的权限
  • 我一直在尝试使用多个不同的 VM 实例进行此操作。都有同样的错误。

我错过了什么?

【问题讨论】:

    标签: php file opencart file-permissions permission-denied


    【解决方案1】:

    好的,终于在this blog post找到了解决方案。非常感谢作者。

    显然 SELinux 有另一层权限设置,这就是阻止 apache 写入的原因,尽管权限正确。

    使用 chcon 更改 SELinux 策略就可以了。

    【讨论】:

      【解决方案2】:

      如果使用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 
      

      OpenCart安装包中的install.text中也有上述信息

      【讨论】:

        【解决方案3】:

        这是我修复它的方法:

        1. 查找文件夹应属于“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`
          
        2. 授予适当实体的权限。在我的情况下,它的'www-root'。由于您在 /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
          
        3. 正确设置文件和文件夹的权限(因为文件具有执行权限可能很危险)

          # 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 {} \;
          

        【讨论】:

          【解决方案4】:

          我在 ubuntu 权限问题上解决了我的 nginx vs operncart 如下:

          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/
          

          希望有人会帮助这个代码

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2016-09-04
            • 2014-01-02
            • 1970-01-01
            • 1970-01-01
            • 2020-08-29
            • 1970-01-01
            • 2013-02-10
            • 2011-12-27
            相关资源
            最近更新 更多