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?
4
Answers
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.
You need to use the following commands to change the file permissions if using Linux:
The above information is also available in the OpenCart installation package in install.text
Here is how I fixed it:
Find to which group-owner the folder should belong ‘www-root’ or ‘apache’
#show the owner and group-owner of files and directories
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".
Set the permissions of files and folders properly (as it can be dangerous for files to have execute permission)
I solved my nginx vs operncart on ubuntu permissionissue as below:
Hope someone will be help this code