Page 1 of 1

Move the storage directory outside of the web directory

Posted: Wed Dec 27, 2017 7:41 am
by JackD
Hi All,
I am hosting OpenCart websites, mostly 2.x ones.
As I am getting familiar with version 3.x, I just want to know more about this storage folder moving outside the web directory, what pops up as an important security notfication at first OC setups.
As a sysadmin, I just simply don't get this security solution. I've never met something like this before using other engines.
Why is this important? And what are the exact permission requirements for the moved folder?
Can anyone explain these for me from a sysadmin point of view? I couldn't find any specific details in documentation.
???

Re: Move the storage directory outside of the web directory

Posted: Thu Dec 28, 2017 1:12 am
by straightlight
Requires domain permissions for Opencart to write its cache data when either using vendors, cache and extensions. Move your system/storage outside your public_html folder. Then, set recursive settings to the storage folder with CHMOD 0755. In your config.php and admin/config.php files, edit your DIR_STORAGE definition folder to its new destination as well as from your .htaccess file (if found in your .htaccess file as well).

Re: Move the storage directory outside of the web directory

Posted: Thu Jan 04, 2018 7:43 am
by JackD
If I have multiple Opencart 3.x sites hosted on my linux server, virtualhosts stored in /var/www/, should I move storage directories of all sites to different directories outside /var/www/{site}/, named diferently after the sites?
e.g.:
/var/www/site1/system/storage -> /var/www/site1_storage
/var/www/site2/system/storage -> /var/www/site2_storage
/var/www/site3/system/storage -> /var/www/site3_storage
straightlight wrote:
Thu Dec 28, 2017 1:12 am
Requires domain permissions for Opencart to write its cache data when either using vendors, cache and extensions. Move your system/storage outside your public_html folder. Then, set recursive settings to the storage folder with CHMOD 0755. In your config.php and admin/config.php files, edit your DIR_STORAGE definition folder to its new destination as well as from your .htaccess file (if found in your .htaccess file as well).

Re: Move the storage directory outside of the web directory

Posted: Thu Jan 04, 2018 7:55 am
by straightlight
Good question. :)

Each domain should use their own storage folder so to avoid cache conflict. Although, each config.php and admin/config.php files of each stores must also be configured accordingly as well as each .htaccess files from the OC root store path by remove the entire line where the system/storage is located.

Re: Move the storage directory outside of the web directory

Posted: Sun Mar 11, 2018 10:23 am
by hobiesan
I am installing Opencart for the first time, and am getting the pop-up window in the admin area telling me to move the storage directory. However, my pop-up window is incomplete. I've seen others post images of their pop-up window and there is a bottom section with a place to enter a path and a "Move" button. My pop-up window does not have this bottom section. And there is no scroll bar on the window to move it down. I would post an image, but I cannot seem to upload an image to this forum either. FWIW, I'm not a noob on computers, as I have been a engineer/developer for over 25 years.

I am running Chromium 64.0 browser on a Debian 9.3 linux system, and my opencart is hosted on Dreamhost. Adblock is turned off for my Opencart site.

I guess I can try moving the storage directory manually via an ssh login, and editing the appropriate config.php files. But I thought I'd mention this problem in case anyone else has also had this problem, and in case a Issue needed to be opened on Github.

Also, I downloaded the Opencart from Github, so I probably installed the latest code from the master branch. Maybe this is the issue?

Re: Move the storage directory outside of the web directory

Posted: Thu Mar 15, 2018 12:44 am
by Johnathan
NEVER install OpenCart from github. While it does contain bugfixes, it also usually has unfinished code, and you're likely going to run into issues if you use that. Always use the official versions found here:

https://www.opencart.com/index.php?route=cms/download

The latest version 3.0.2.0 does have bugs, which you can look for fixes in the bugfix forum topic or on github, and then fix yourself. Hopefully one of these days we'll actually get an official 3.0.3.0 release that has the bugfixes in it...

Re: Move the storage directory outside of the web directory

Posted: Thu Mar 15, 2018 1:21 am
by straightlight
FWIW, I'm not a noob on computers, as I have been a engineer/developer for over 25 years.
Despite the un-relative years of experience since Opencart hasn't been created at that time, while the above is correct regarding the stable releases to be used rather than the dev versions, followed are instructions on how to resolve these issues with the security modal window when the automatic settings has not been selected but rather the manual option on PCI servers: viewtopic.php?f=202&t=201745#p713479

Re: Move the storage directory outside of the web directory

Posted: Thu Oct 17, 2019 5:05 am
by aoe123
hi there,

everything is fine with installation except this fucking move thing.

i already installed many scripts but this one is really annoying. why i have to move something?

it wastes my time and its annoying because it doesnt work. not automatically and also not manually.
where i have to change what? please give me exact advises, thanks!

when i wanna move it automatically i get this looong message:

Image

the hoster is hoststar.
so what can i do??
please clear and straight answers, thanks.

Re: Move the storage directory outside of the web directory

Posted: Fri Oct 18, 2019 12:10 am
by IP_CAM

Re: Move the storage directory outside of the web directory

Posted: Thu Feb 13, 2020 9:07 am
by Lytrax
We could avoid all that move thing outside of the webroot if we add a simple Apache htaccess to `/storage/` directory:

Code: Select all

## no access to this folder

# Apache 2.4
<IfModule mod_authz_core.c>
    Require all denied
</IfModule>

# Apache 2.2
<IfModule !mod_authz_core.c>
    Order Allow,Deny
    Deny from all
</IfModule>
Or to the webroot htaccess:

Code: Select all

RewriteRule ^(/storage/) - [F,L,NC]
There are also simple config options for Nginx servers.

Re: Move the storage directory outside of the web directory

Posted: Thu Feb 13, 2020 8:27 pm
by straightlight
Lytrax wrote:
Thu Feb 13, 2020 9:07 am
We could avoid all that move thing outside of the webroot if we add a simple Apache htaccess to `/storage/` directory:

Code: Select all

## no access to this folder

# Apache 2.4
<IfModule mod_authz_core.c>
    Require all denied
</IfModule>

# Apache 2.2
<IfModule !mod_authz_core.c>
    Order Allow,Deny
    Deny from all
</IfModule>
Or to the webroot htaccess:

Code: Select all

RewriteRule ^(/storage/) - [F,L,NC]
There are also simple config options for Nginx servers.
Take note that the above changes are server-specifics and may not respond on other servers. In addition, those changes does not specifically reflect on the storage folder as opposed to the original instructions in the FAQ.

Re: Move the storage directory outside of the web directory

Posted: Mon May 25, 2020 5:40 am
by Cue4cheap
Can I just create the storage directory outside the web directory and the rest will be created? i.e. cache, download, modification, session, etc.?

Thanks!

Mike

Re: Move the storage directory outside of the web directory

Posted: Mon May 25, 2020 5:57 am
by straightlight
By following the FAQ instructions (first post), you still need to move all sub-folders along with the storage folder outside of your public_html folder as described here: viewtopic.php?f=134&t=215776#p717782

Re: Move the storage directory outside of the web directory

Posted: Wed May 27, 2020 11:29 pm
by rubensyanesb
Hi!
I am installing Open Cart v3.0.3.3 in order to migrate a site from an older version.
Everything was fine until I moved the storage folder outside the public_html folder.

After the move, I edited the config files of the main folder and the admin folder in this way, following the documentation:
Main folder Config.php

Code: Select all

define('DIR_APPLICATION', '/home/c1300630/public_html/2020/catalog/');
define('DIR_SYSTEM', '/home/c1300630/public_html/2020/system/');
define('DIR_IMAGE', '/home/c1300630/public_html/2020/image/');
define('DIR_STORAGE' . '/storage/');
Admin Config.Php

Code: Select all

define('DIR_SYSTEM', '/home/c1300630/public_html/system/');
define('DIR_IMAGE', '/home/c1300630/public_html/image/');
define('DIR_LANGUAGE', '/home/c1300630/public_html/admin/language/');
define('DIR_TEMPLATE', '/home/c1300630/public_html/admin/view/template/');
define('DIR_CONFIG', '/home/c1300630/public_html/system/config/');
define('DIR_STORAGE', '/storage/'); 
But it seems that the systme doesn´t take the change in account.
I am having these warnings in the front end:

Code: Select all

Warning: fopen(DIR_STORAGElogs/openbay.log): failed to open stream: No such file or directory in /home/c1300630/public_html/2020/system/library/log.php on line 22Warning: Cannot modify header information - headers already sent by (output started at /home/c1300630/public_html/2020/system/framework.php:42) in /home/c1300630/public_html/2020/catalog/controller/startup/session.php on line 25Warning: Cannot modify header information - headers already sent by (output started at /home/c1300630/public_html/2020/system/framework.php:42) in /home/c1300630/public_html/2020/catalog/controller/startup/startup.php on line 99Warning: Cannot modify header information - headers already sent by (output started at /home/c1300630/public_html/2020/system/framework.php:42) in /home/c1300630/public_html/2020/catalog/controller/startup/startup.php on line 157Warning: fopen(DIR_STORAGElogs/openbay.log): failed to open stream: No such file or directory in /home/c1300630/public_html/2020/system/library/log.php on line 22Warning: fclose() expects parameter 1 to be resource, boolean given in /home/c1300630/public_html/2020/system/library/log.php on line 39Warning: fopen(DIR_STORAGElogs/error.log): failed to open stream: No such file or directory in /home/c1300630/public_html/2020/system/library/log.php on line 22
And in admin I am able to login, but immediately I got an error screen with the following message and nothing else:

Code: Select all

Warning: fopen(/storage/logs/openbay.log): failed to open stream: No such file or directory in /home/c1300630/public_html/2020/system/library/log.php on line 22Warning: fopen(/storage/logs/error.log): failed to open stream: No such file or directory in /home/c1300630/public_html/2020/system/library/log.php on line 22Warning: Cannot modify header information - headers already sent by (output started at /home/c1300630/public_html/2020/system/framework.php:42) in /home/c1300630/public_html/2020/system/library/response.php on line 36Warning: fclose() expects parameter 1 to be resource, boolean given in /home/c1300630/public_html/2020/system/library/log.php on line 39Warning: fclose() expects parameter 1 to be resource, boolean given in /home/c1300630/public_html/2020/system/library/log.php on line 39Warning: fclose() expects parameter 1 to be resource, boolean given in /home/c1300630/public_html/2020/system/library/log.php on line 39

Re: Move the storage directory outside of the web directory

Posted: Thu May 28, 2020 8:12 pm
by straightlight
Replace both instances of:

Code: Select all

define('DIR_STORAGE', '/storage/');
with:

Code: Select all

define('DIR_STORAGE', '/home/c1300630/storage/');
Then, ensure to follow this FAQ afterwards: viewtopic.php?f=134&t=215776#p718325 . This should resolved the issue.