If you just installed OpenCart and logged in to it’s admin panel you probably noticed that OpenCart asks you to move the storage directory for safety reasons. if you have no idea why it shows up and what should you do with it, you’re in the right place to find out.
Here’s what you’ll learn:
- What is storage directory in OpenCart
- How to move OpenCart storage directory outside of public directory automatically
- How to move OpenCart storage directory manually
What is storage directory in OpenCart
Storage directory contains temporary files (cache), some vendor files and extension modification files in OpenCart.
For example, if you just installed an OCMOD extension which adds additional code to one of the theme files, then system automatically creates a duplicate of the original file in the storage folder. That duplicate file has all the modifications from OCMOD, so core OpenCart files are never modified.
When the system will need the theme file, first it will check if there is a modified version if it in the storage folder. If there is, it will load the modifed version. If modification file not found, the system will automatically load default OpenCart file.
How to move OpenCart storage directory outside of public directory automatically
Storage folder might contain any sort of modified code, especially if you use lots of third party extensions. So it’s safer to hide this directory from public view.
If you have a correctly set up hosting server, there won’t be much to do to accomplish that. Select Automatically Move option, and OpenCart will offer you a safe place to move storage directory outside of public view. By default it’s one directory up from public, public_html or www directories (depending on your hosting server configuration).
Once you select Automatically Move, and then click a Move button, the storage directory should be safely moved, and the security notification should be gone.
If for some reason you might want to name storage folder differently (for example if you already have folder named storage there), you may do it before hitting Move button.
Moving OpenCart storage directory manually
In case your hosting account has limited rights or there are other limitations in your server, and moving storage directory automatically does not work, you can move the storage folder manually.
Here’s how you do it (the same information is available in the security notification when you select Manually Move):
- Move /YOUR SERVER DIRECTORY LIST/public_html/system/storage/ to
/YOUR SERVER DIRECTORY LIST/storage/ using FTP software like Filezilla. Just open the directory, and move the directory from one place to another.
- Edit public_html/config.php file: change define(‘DIRSTORAGE’, DIRSYSTEM . ‘storage/’); to define(‘DIR_STORAGE’, ‘/YOUR SERVER DIRECTORY LIST/storage/’);
- Edit public_html/admin/config.php file: change define(‘DIRSTORAGE’, DIRSYSTEM . ‘storage/’);to define(‘DIR_STORAGE’, ‘/YOUR SERVER DIRECTORY LIST/storage/’);
If you have no idea how /YOUR SERVER DIRECTORY LIST/ should look like you will see working examples in other OpenCart config.php file settings.
Here’s the exact example from my test server: