How to solve a Linux permission issue for opencart

自闭症网瘾萝莉.ら 提交于 2019-12-06 00:07:50

问题


I had used subversion to revert my PHP Opencart project, but I got a permission issue (sample shown below:

Warning: imagejpeg(): Unable to open '/var/www/html/opencart/image/cache/data/pavblog/img-blog-620x300w.jpg' for writing: Permission denied in /var/www/html/opencart/system/library/image.php on line 45

Warning: imagejpeg(): Unable to open '/var/www/html/opencart/image/cache/data/pavblog/img-blog-250x250w.jpg' for writing: Permission denied in /var/www/html/opencart/system/library/image.php on line 45

Warning: imagejpeg(): Unable to open...

I executed the below commands to add permissions to these folders, but I'm still getting the warning messages on my site.

sudo chmod 777 /var/www/html/opencart
cd /var/www/html/opencart 
sudo chmod 777 image/ 
sudo chmod 777 image/cache/ 
sudo chmod 777 image/data/ 
sudo chmod 777 system/cache/ 
sudo chmod 777 system/logs/ 
sudo chmod 777 download/ 
sudo chmod 777 config.php
sudo chmod 777 admin/config.php

How can I fix this?


回答1:


You need to apply permissions recursively. Try

sudo chmod -R 777 image/cache/




回答2:


To fix your permissions, you'll need to take two different steps:

  1. Grant permission to the proper entity. Since you're in /var/www/html, my guess is that the correct user is "apache".

    # Grants permissions to apache
    sudo chown apache:apache -R /var/www/html/opencart
    
    # If that doesn't work, perhaps try www-data
    sudo chown www-data:www-data -R /var/www/html/opencart
    
  2. Set the permissions of files and folders properly (it can be dangerous for files to have execute permission)

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


来源:https://stackoverflow.com/questions/26551819/how-to-solve-a-linux-permission-issue-for-opencart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!