Fixed: Opencart installation error linux: warning: fopen(system/storage) failed to open stream: Permission denied

Warning: fopen(/var/www/html/webocreation.com/system/storage/session/....): failed to open stream: Permission denied in /var/www/html/webocreation.com/system/library/session/file.php on line 29 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 31 Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 33 Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 35 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 37 Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 39 


 These errors occurs because of the file permissions. In most of the forum, I found that they suggested to give full permission 0777 for the storage folder, this can be dangerous as per the security reason.
I have added the opencart upload folders and files at /var/www/html/webocreation
Following are the commands that I run:
cd /var/www/html/webocreation
Now I am in the folder, then I list the details of the files and folder:
ls -la


Change the ownership of the files and folders to the apache:apache 
sudo chown apache:apache -R . 
Let's make the all files secure by giving permissions of 0644 
find . -type f -exec chmod 0644 {} \; 
 Likewise, let's make the directory accessible for the apache 
find . -type d -exec chmod 0755 {} \;
 Now, let give access to read all files for the httpd server 
sudo chcon -t httpd_sys_content_t . -R 
 Allow write only to specific dirs 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/cache -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/download -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/logs -R
sudo chcon -t httpd_sys_rw_content_t ./system/storage/modification -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/session -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/upload -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/vendor -R
Once these commands are run then you are ready to install.


Then, open the browser and run the URL and you may get warning saying config.php file need to be writable, then for that run following two commands:
sudo chcon -t httpd_sys_rw_content_t ./config.php -R 
sudo chcon -t httpd_sys_rw_content_t ./admin/config.php -R

Comments

Popular posts from this blog

Opencart error: Notice: Trying to access array offset on value of type null in ..../vendor/scss.inc.php on line 1753

Creating Class Templates