【问题标题】:Magento 2.3 - CentOS 7 - page_cache is not writableMagento 2.3 - CentOS 7 - page_cache 不可写
【发布时间】:2020-09-22 00:37:19
【问题描述】:

我正在尝试在 CentOS 基础服务器中安装 Magento 2.3.4。并得到以下错误:

Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/mage2/var/page_cache" is not writable in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...') #1 /var/www/html/mage2/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/m...') #2 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array) #3 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true) #4 /var/www/html/mage2/vendor/magento/framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true) #5 /var/www/html/mage2/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(38): Magento\Framework in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php on line 209

我已经运行了以下命令:

sudo chmod -R 777 var/ pub/ generated

似乎是文件和文件夹所有者|组问题。然后,我创建了一个用户并将其分配给 apache 组并运行以下命令来更改文件和文件夹所有者|组

sudo chown -R magento_user:apache * .[^.]*

sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; 

sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;   

sudo chmod u+x bin/magento

sudo service httpd restart

我使用 CLI 和以下命令安装了 Magento 并收到了成功消息

php bin/magento setup:install --base-url=http://example.com/ --db-host=localhost --db-name=dbname --db-user=dbuser --db-password=dbpass --admin-firstname=Rajiv --admin-lastname=Ranjan --admin-email=rajiv@gmail.com --admin-user=admin --admin-password=admin@123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

从浏览器访问时,我仍然没有收到相同的“写入权限”错误。

非常感谢任何帮助。

【问题讨论】:

  • 命令ls -lh var/ 显示什么?它应该显示page_cache 目录的当前所有者和权限

标签: magento2 centos7 file-permissions magento-2.3 magento-installation


【解决方案1】:

运行缓存清理命令,然后再次授予777权限并检查。

  • php bin/magento 缓存:清理
  • sudo chmod -R 777 var

【讨论】:

    【解决方案2】:

    花了太多时间后,找到了解决方案。 centos 限制写入目录。所以我执行了下面的命令,效果很好。

    sudo chcon -R --type httpd_sys_rw_content_t var
    sudo chcon -R --type httpd_sys_rw_content_t pub/media
    sudo chcon -R --type httpd_sys_rw_content_t pub/static
    sudo chcon -R --type httpd_sys_rw_content_t generated
    

    【讨论】:

      猜你喜欢
      • 2018-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-13
      • 1970-01-01
      相关资源
      最近更新 更多