prestashop file permission issues - linux

I'm facing issues accessing my website in prestashop without setting 777 file permissions. It throws Error: 500or not found error if I've not set 777 to all folder and files in html directory.
I then ran these 2 commands from within /var/www/html directory
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
After this I'm able to see my website running(only the home page), but not the admin panel or any other link. How can I fix it?

Are you sure all files and sub folders Permission changed ?
Try using following code in simple php script and run it.
Following PHP script will update all folder permission to 755 and all files with 644 permission RECURSIVELY.
<?php
exec ("find /path/to/folder -type d -exec chmod 0755 {} +");
exec ("find /path/to/folder -type f -exec chmod 0644 {} +");
?>
Not sure if this can help you. But you should try
Enable error reporting in PrestaShop 1.6
PrestaShop root folder, double click the folder named config and then open the file named defines.inc.php for editing.
Find the line of code below:
define('_PS_MODE_DEV_', false);
Change the 'false' to 'true' and then click the Save Changes button to save and activate the change. The changed line should read as follows:
define('_PS_MODE_DEV_', true);

Related

Setting multiple file permissions at once using ssh ( recursive folder/file permission )

I am working with digital ocean and WordPress. I have uploaded my theme and my file permissions are all wrong. I know how to set the file permissions individually using ssh but I'm wondering if I can do multiple at once rather than doing each individually. I want to set all folders inside my theme to 755 and all files to 644 (correct me if this is wrong)
Here's what I have done so far; I navigated to my theme folder using ssh then used to following command to set file permissions;
chmod 644 file.php
chmod 755 folder
chmod -R 755 will set these permissions to all files and subfolders in the tree. To set the directories to 755 and either leave the files alone or set them to 644. For this, you can use the find command. For example:
To change all the directories to 755 (drwxr-xr-x):
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
To change all the files to 644 (-rw-r--r--):
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
Please try below command for directory
find /var/www/html/ -type d -exec chmod 755 {} \;
Below command is for files permission
find /var/www/html/ -type f -exec chmod 644 {} \;

Changing permission of files on searching a directory

I am trying to search all directories with name 'bin' and change the permission of files under all directories which were successfully found. I tried with the below command:
find -type d -name bin -exec chmod 777 {} \;
But this changed the permission of bin directory. It did not change the permission of the files underlying bin. Please help.
Recursively changing the permission with -R as shown in the solution below is the key. Not the solution provided in the similar question.
Your approach was slightly unsuccessful.
Since your bin directory contains another files and directories, you've to change their permission recursively.
$ find -type d -name bin -exec chmod -R 777 {} \;
I Hope, this is what you've expected in return.

Permission to parent and child folders in ubuntu

I'm new to Ubuntu. Giving permission to folder using the following command in Terminal.
chmod -R 777 /var/www/html/
This command is working for html folder only. But, I have many sub folders in html folder.
How can i give 777 permissions to all the sub folders at a time?
I think you really want to do is set the directories to 755 and either leave the files alone or set them to 777. For this, you can use the find command. For example:
To change all the directories to 755 (-rwxr-xr-x):
find /var/www/html/ -type d -exec chmod 755 {} \;
To change all the files to 777 :
find /var/www/html/ -type f -exec chmod 777 {} \;
Hope this helps you.

changing permissions of files in a directory recursively

I am trying to change the permissions of a files present in a directory and subdirectories using the below command and running into below error..can anyone help?
user#machine:/local/mnt/workspace$ find . -type f -exec chmod 644 {} \;
chmod: changing permissions of `./halimpl/ncihal/adaptation/NonVolatileStore.cpp': Operation not permitted
you can run the following command:
#chown -R directory_path
But it will change the permissions of directories also.
For only files, you can run.
#find directory_path -type f -exec chmod 644 {} \;
It also looks like you dont have enough permissions. try
#sudo find directory_path -type f -exec chmod 644 {} \;
or run the command as root user.
It looks to me like you don't have permission to change NonVolatileStore.cpp.
Are you aware of chmod's -R switch that recursively changes permissions?
if you have the root privilege, try:
sudo find . -type f -exec chmod 644 {} \;
It could be that you simply don't own that file. Run an ls -l on it to see full permissions and who the owner is.
It could also be the filesystem is read only.

How to secure drupal file with permission?

i'm asking what's the best linux permission to drupal files in the purpose to secure it.
My setting.php is under 444 but the others are 755 .
Thank you
Once finished editing the settings.php file, you should change it to 440 giving only you and the webserver read-only access.
440 is fine for the settings file. For the others do:
Navigate to sites/default folder:
chown -R :www-data files
Then give you and web server read/write permission to files folder ('s' makes the files inside the directory inherit these permissions.)
chmod g+ws files
If you need to overwrite previous created files' permissions do (navigate to sites/default/files):
find . -type d -exec chmod g+ws {} \;
find . -type f -exec chmod 664 {} \;
Now your web server can read/write but not execute files in the files directory.

Resources