Opencart - can't upload images - opencart

I moved a OpenCart version 1.5.6.4 installation from one server to another and after some time I noticed I can't upload images anymore. Whenever I use the image manager to upload the images it just gets stuck, the spinner wheel keeps spinning but the images are not uploading.
I tried changing the folder pemissions of the image and data folders to 777 and cleared the cache. I also tried to upload an extension that allows for multiple files uploads hoping that somehow magically it would fix the problem, needless to say, it didn't. Haven't found a solution on SO or OC forums.
My best guess is that the problem lies in the config files.
I runned a phpinfo(); and you can check it at http://atelier-faiblesse.ro/info.php.
The admin config contains the following code:
<?php
// HTTP
define('HTTP_SERVER', 'http://atelier-faiblesse.ro/admin/');
define('HTTP_CATALOG', 'http://atelier-faiblesse.ro/');
// HTTPS
define('HTTPS_SERVER', 'http://atelier-faiblesse.ro/admin/');
define('HTTPS_CATALOG', 'http://atelier-faiblesse.ro/');
// DIR
define('DIR_APPLICATION', '/var/www/clients/client9/web72/web/admin/');
define('DIR_SYSTEM', '/var/www/clients/client9/web72/web/system/');
define('DIR_DATABASE', '/var/www/clients/client9/web72/web/system/database/');
define('DIR_LANGUAGE', '/var/www/clients/client9/web72/web/admin/language/');
define('DIR_TEMPLATE', '/var/www/clients/client9/web72/web/admin/view/template/');
define('DIR_CONFIG', '/var/www/clients/client9/web72/web/system/config/');
define('DIR_IMAGE', '/var/www/clients/client9/web72/web/image/');
define('DIR_CACHE', '/var/www/clients/client9/web72/web/system/cache/');
define('DIR_DOWNLOAD', '/var/www/clients/client9/web72/web/download/');
define('DIR_LOGS', '/var/www/clients/client9/web72/web/system/logs/');
define('DIR_CATALOG', '/var/www/clients/client9/web72/web/catalog/');
// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'XXXXXXXX');
define('DB_PASSWORD', 'XXXXXXXX');
define('DB_DATABASE', 'XXXXXXXX');
define('DB_PREFIX', 'oc_');
?>
Do you notice any problems in the config file? Or do you know any other reasons file uploading might not work?

Run below commands from ssh to fix this issue.
chown -R www-data /var/www/clients/client9/web72/web/image
chmod -R 755 /var/www/clients/client9/web72/web/image

Related

I have Deployed My Django App in apache server . All the static files are getting served properly but its not accepting media files from Form Input

While Submitting a form having media input its showing
[Errno 13] Permission denied: '/home/ubuntu/django/media/pictures'
I have searched in google but no one told giving permissions for media files , they ever all telling about static files only . Can any one please tell me which permission i have to give to it with chmod no.
You're having permissions issues. To fix it, you need to allow the Apache process access to the folder and it's content.
This can be done through the following steps
Change the permissions to read and write
chmod 664 /home/ubuntu/django/media/pictures -R
Give the group Apache runs under (www-data group) group ownership of the folder and its content
sudo chown -R :www-data ~/home/ubuntu/django/media/pictures
Restart the Apache service
sudo service apache2 restart
If you want to ensure Django behaves as it should, you can also add the following to your settings.py
FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755
FILE_UPLOAD_PERMISSIONS = 0o644

Renaming Admin Folder in Opencart

I'm new to opencart. While I understand the security benefits of renaming the admin folder and renaming all instances of 'admin' in the config file, my question is, if for example I install a payment extension that comes with its own admin and catalog folder to be merged, do I also rename the extensions admin folder to reflect the new change?
The .htaccess file isn't an option for now as my IP address isnt static.
Thanks for your anticipated reply.
Steps to Change OpenCart Admin Dashboard URL & Folder
Log into your hosting account cPanel, or FTP
Navigate to the folder containing the “admin” folder. It is usually the “public_html” or “/var/www/html” folders.
Right click on the “admin” folder and choose the “rename” option from the dropdown
Enter the new folder name for the “admin” folder. Use an un-common name which is hard to guess and completely unrelated to your business. (For eg: “STA22R1”, “ROCKETSCIENCE74851”)
Now, edit the /admin/config.php and replace ALL instances of the word ‘admin’ with the new folder name you have chosen in the above step.
// HTTP
define('HTTP_SERVER', 'http://test.domain.com/opencart/**admin**/');
define('HTTP_CATALOG', 'http://test.domain.com/opencart/');
// HTTPS
define('HTTPS_SERVER', 'http://test.domain.com/opencart/**admin**/');
define('HTTPS_CATALOG', 'http://test.domain.com/opencart/');
//DIR
define('DIR_APPLICATION', '/home/userna5/public_html/opencart/**admin**/');
define('DIR_SYSTEM', '/home/userna5/public_html/opencart/system/');
define('DIR_DATABASE', '/home/userna5/public_html/opencart/system/database/');
define('DIR_LANGUAGE', '/home/userna5/public_html/opencart/**admin**/language/');
define('DIR_TEMPLATE', '/home/userna5/public_html/opencart/**admin**/view/template/');
define('DIR_CONFIG', '/home/userna5/public_html/opencart/system/config/');
define('DIR_IMAGE', '/home/userna5/public_html/opencart/image/');
define('DIR_CACHE', '/home/userna5/public_html/opencart/system/cache/');
define('DIR_DOWNLOAD', '/home/userna5/public_html/opencart/download/');
define('DIR_LOGS', '/home/userna5/public_html/opencart/system/logs/');
define('DIR_CATALOG', '/home/userna5/public_html/opencart/catalog/');
// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'username_example');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'username_example');
define('DB_PREFIX', 'oc_');
If you are using vQmod, you will have to update the pathReplaces.php file, located in the /vqmod directory. The code to rename the ‘admin’ folder should already be there. It would be similar to the code shown below:
$replaces[] = array('~^admin\b~', 'backend');
Replace the word backend with the new folder name we have chosen in the above steps.
If you renamed the admin folder name then the other extension you are trying to install that will not work because the other extension is looking for the admin folder that folder is doesn't exists in the directory so, it will you the error like no /admin directory exists. But if you renamed the extension folder name as to your opencart admin then it may depend if your extension has install.xml then it will not work properly if there is no install.xml then it will work properly. I hope this answer will help you if you like this then please vote for it.

Django server error 403 forbidden nginx/1.10.3 (ubuntu)

I have some media content in ubuntu server. I can upload files. but when I try to load files it shows 403 forbidden nginx/1.10.3 (ubuntu).In file permission, it displays rw--------.
How can I retrieve all content without error?
I'm not familiar with Ubuntu
I used this snippet to recover files. However, it only works the single time. After some while, it shows the same error.
sudo chmod -R 664 /home/django/media/image/
sudo chmod -R a+X /home/django/media/image/
The nginx user must be able to read those files. You can use group permissions to allow that. Also the wsgi user must have its umask set so that files it creates are readable for the group as well.
In your case it looks like your wsgi user has umask 077, which makes files it creates only readable by the owner (rw--------). Thus nginx does not have read permission. Instead use umask 027, which will permit group users to access those files, but not write to them (there's no reason for nginx to have write access).
For example if you are using gunicorn as your wsgi server, you can use gunicorn flags --group www --umask 027. Make sure both gunicorn and nginx user belongs to the www group.
Fix permission something like this.
# set group to `www` for all files recursively
sudo chgrp www -R /home/django/media/
# set all files to be read/write by owner and readable by group `www`
find /home/django/media/ -type f -exec chmod 640 {} ;
# same with directories +execute
find /home/django/media/ -type d -exec chmod 750 {} ;
Alternatively, use 644 for files and 755 for directories, and 022 for umask. Then group permissions don't matter, since all users gets read access.
The latter option is not security best practice, but it's probably fine, as long as you only give the django user write access.

Redis telling me "Failed opening .rdb for saving: Permission denied"

I'm running Redis server 2.8.17 on a Debian server 8.5. I'm using Redis as a session store for a Django 1.8.4 application.
I haven't changed the software configuration on my server for a couple of months and everything was working just fine until a week ago when Django began raising the following error:
MISCONF Redis is configured to save RDB snapshots but is currently not able to persist to disk. Commands that may modify the data set are disabled. Please check Redis logs for details...
I checked the redis log and saw this happening about once a second:
1 changes in 900 seconds. Saving...
Background saving started by pid 22213
Failed opening .rdb for saving: Permission denied
Background saving error
I've read these two SO questions 1, 2 but they haven't helped me find the problem.
ps shows that user "redis" is running the server:
redis 26769 ... /usr/bin/redis-server *.6379
I checked my config file for the redis file name and path:
grep ^dir /etc/redis/redis.conf =>
dir /var/lib/redis
grep ^dbfilename /etc =>
dbfilename dump.rdb
The permissons on /var/lib/redis are 755 and it's owned by redis:redis.
The permissons on /var/lib/redis/dump.rdb are 644 and it's owned by redis:redis too.
I also ran strace on the server process:
ps -C redis-server # pid = 26769
sudo strace -p 26769 -o /tmp/strace.out
But when I examine the output, I don't see any errors. In particular I don't see a "Permission denied" error as I would expect.
Also, /var/lib/redis is not an NFS directory.
Does anyone know what else could be causing this? I'd hate to have to stop using Redis. I know I can run the command "set stop-writes-on-bgsave-error yes" but that doesn't solve the problem.
This is now happening on a daily basis and the only way I can stop the error is to restart the Redis server.
Thanks.
I just had a similar issue. Despite my config file being correct, when I checked the actual dbfilename and dir in redis-client, they were incorrect.
Run redis-cli and then
CONFIG GET dbfilenamewhich should return something like
1) "dbfilename"
2) "dump.rdb"
1) is just the key and 2) the value. Similarly then run CONFIG GET dir should return something like
1) "dir"
2) "/var/lib/redis"
Confirm that these are correct and if not, set them with CONFIG SET dir /correct/path
Hope this helps!
If you have moved Redis to a new mounted volume: /mnt/data-01.
sudo vim /etc/systemd/system/redis.service
Set ReadWriteDirectories=-/mnt/data-01
sudo mkdir /mnt/data-01/redis
Set chown and chmod on new redis data dir and rdb file.
The permissons on /var/lib/redis are 755 and it's owned by redis:redis
The permissons on /var/lib/redis/dump.rdb are 644 and it's owned by redis:redis
Switch configurations while redis is running
$ redis-cli
127.0.0.1:6379> CONFIG SET dir /data/tmp
redis-cli 127.0.0.1:6379> CONFIG SET dbfilename temp.rdb
127.0.0.1:6379> BGSAVE
tail /var/log/redis/redis.cnf (verify saved)
Start Redis Server in a directory where Redis has write permissions
The answers above will definitely solve your problem, but here's what's actually going on:
The default location for storing the rdb.dump file is ./ (denoting current directory). You can verify this in your redis.conf file. Therefore, the directory from where you start the redis server is where a dump.rdb file will be created and updated.
Since you say your redis server has been working fine for a while and this just started happening, it seems you have started running the redis server in a directory where redis does not have the correct permissions to create the dump.rdb file.
To make matters worse, redis will also probably not allow you to shut down the server either until it is able to create the rdb file to ensure the proper saving of data.
To solve this problem, you must go into the active redis client environment using redis-cli and update the dir key and set its value to your project folder or any folder where non-root has permissions to save. Then run BGSAVE to invoke the creation of the dump.rdb file.
CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE
(Now, if you need to save the dump.rdb file in the directory that you started the server in, then you will need to change permissions for the directory so that redis can write to it. You can search stackoverflow for how to do that).
You should now be able to shut down the redis server. Note that we hardcoded the path. Hardcoding is rarely a good practice and I highly recommend starting the redis server from your project directory and changing the dir key back to./`.
CONFIG SET dir "./"
BGSAVE
That way when you need redis for another project, the dump file will be created in your current project's directory and not in the hardcoded path's project directory.
You can resolve this problem by going into the redis-cli
Type redis-cli in the terminal
Then write config set stop-writes-on-bgsave-error no and it resolved my problem.
Hope it resolved your problem
Up to redis 3.2 it shipped with pretty insane defaults which opened the port to the public. In combination with the CONFIG SET instruction everybody can change your redis config from outside easily. If the error starts after some time, someone probably changed your config.
On your local machine check that
telnet SERVER_IP REDIS_PORT
is denied. Otherwise check your config, you should have the setting
bind 127.0.0.1
enabled.
Dependent on the user that runs redis, you should also check for damage that the intruder has done.

Fatal error: require_once() - After moving htdocs to another drive

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs/system/startup.php' (include_path='.;N:\New folder\php\PEAR') in N:\New folder\htdocs\index.php on line 23...
This error is showing on localhost server when I had to uninstall XAMPP folder from c: drive but I took backup of htdocs and MySQL folder and when I reinstall XAMPP in n: drive and copy paste old htdocs and MySQL to new files, this error is showing...
2nd problem which I am facing is that my SQL is not running on XAMPP control panel whereas
Apache is running without any issue...
What can be the reason for this error?
OpenCart uses two config.php files, one at root and another in admin folder. In these files some global variables are defined containing also paths to installation folder. When you installed the OC, it automatically find the paths and write them into both config files.
But when you changed the directory of your OC (moving on disk, uploading to server), they don't update automatically and you need to do this manually:
// DIR
define('DIR_APPLICATION', '/path/to/public_html/catalog/');
define('DIR_SYSTEM', '/path/to/public_html/system/');
define('DIR_DATABASE', '/path/to/public_html/system/database/');
define('DIR_LANGUAGE', '/path/to/public_html/catalog/language/');
define('DIR_TEMPLATE', '/path/to/public_html/catalog/view/theme/');
define('DIR_CONFIG', '/path/to/public_html/system/config/');
define('DIR_IMAGE', '/path/to/public_html/image/');
define('DIR_CACHE', '/path/to/public_htmll/system/cache/');
define('DIR_DOWNLOAD', '/path/to/public_html/download/');
define('DIR_LOGS', '/path/to/public_html/system/logs/');
E.g. if you have old paths like this one:
define('DIR_APPLICATION', 'c:/htdocs/catalog/');
And now you moved it to n:/New folder, change all the paths accordingly, e.g.
define('DIR_APPLICATION', 'n:/New folder/htdocs/catalog/');