简体   繁体   中英

Opencart Fresh Installation Error: Failed to open stream: Permission denied

I'm trying to install Opencart on a CentOS 7 Google Compute Cloud instance.I got this error when trying to install 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

Here's what I've done so far:

  • Read the install.txt and set permissions to files accordingly - Didn't work.
  • Set permissions to 0777 for the whole webapp directory - Didn't work.
  • Created the file.php file manually and changed permissions to 0777 - Didn't work.
  • Changed file ownership to apache:apache and added my user account and root account to the apache group, set permissions to 0777 again - Didn't work.
  • Plus, when I tried to install Wordpress to the same directory, WP installation didn't have permission to write the config.php file
  • I've been trying this with more than a handful of different VM instances. All with same error.

What am I missing?

You need to use the following commands to change the file permissions if using 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 

The above information is also available in the OpenCart installation package in install.text

Okay finally found the solution in this blog post . Many thanks to the author.

Apparently SELinux has another layer of permission settings and that's what kept apache from writing, despite the correct permissions.

Changing SELinux policies with chcon did the trick.

Here is how I fixed it:

  1. Find to which group-owner the folder should belong 'www-root' or 'apache'

    #show the owner and group-owner of files and directories

    `~$ 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. Grantpermission to the proper entity. In my case its 'www-root'. Since you're in /var/www/html, my guess is that the correct user is "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. Set the permissions of files and folders properly (as 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 {} \;

I solved my nginx vs operncart on ubuntu permissionissue as below:

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/

Hope someone will be help this code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM