How to solve Linux permission problem for opencart

I used subversion to return my PHP Opencart project, but I had a permission problem (example shown below:

Note: imagejpeg (): Unable to open '/var/www/html/opencart/image/cache/data/pavblog/img-blog-620x300w.jpg' for write: 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 write: Permission denied in / var / www / html / opencart / system /library/image.php on line 45

Warning: imagejpeg (): Cannot open ...

I executed the following commands to add permissions to these folders, but I still get 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?

+6
source share
2 answers

Apply permissions recursively. Try

sudo chmod -R 777 image/cache/

+2
source

To fix your rights, you need to perform two different steps:

  • Grant permission to the correct object. Since you are in / var / www / html, I assume 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 
  • Set permissions for files and folders correctly (it may be dangerous for files to have permission to execute)

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

Source: https://habr.com/ru/post/977194/


All Articles