Raspberry Pi 3, browser permissions on apache2 php script - php

Having a nightmare with permissions on RP3, apache2, php
I can run my php api script from terminal with no problems. I use the browser for debugging and get the 'permission denied' when trying to edit text files from the browser.
I have temporarily set permissions to 777 on /var/www but this is insecure, and i can no longer remember the original permissions that were on /var/www
Can i somehow give the broswer (chromium) permission to edit files in /var/www?
I have tried setting inheritance, but to no avail, as i am copying files over all the time, i have to keep resetting the permissions to 777 (which is not ideal), so i can debug the code in a browser.
Any help would be greatly appreciated
Rgds
Mike

Usually, the permissions for folders are 0755 and for folders are 0644.
To set the permissions for folders:
sudo find /var/www -type d -exec chmod 0755 {} \;
To set the permissions for files:
sudo find /var/www -type f -exec chmod 0644 {} \;
Now about the user/group, Apache is probably using the user www-data with group www-data.
To set the user/group for write permissions:
sudo chown www-data:www-data /var/www -R
A note about security: opening up the option to edit the files from the browser is insecure without any login, allowing anyone to edit your files. Also, the write permissions should only be allowed in a directory where the users upload files and NOT for all your /var/www files.

Related

WordPress Plugin update asking for FTP

I moved a WordPress site to our VPS. In admin I am asked to update plugins, if I do that I am prompted for FTP info. As we don't run FTP on the server this is not possible.
I then changed the the permissions of all of the files to apache:apache using:
chown -R apache:apache *
This fixed the issue and WordPress can now update the files, however, now I cannot edit the files using filezilla. I also tried changing ownership to:
chown -R myuser:apache *
So that I can edit the files but give apache group access. Now I can edit the files with filezilla but no longer update items in WordPress.
So, what is the correct way to go about this giving me write access on file level but still giving WordPress access to update the files?
Seems file permission issue.
cd wordpress
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
and following
define( 'FS_METHOD', 'direct' );
in wp-config.php
or
sudo chown -R www-data:www-data wordpress
From WHMPanel, Software, Multi PHP Manager, enable Enable PHP-FPM to fix file permissions issues.
This prevents the popup appearing asking for FTP credentials.

Which permissions should be for symfony 3 folders and files?

I've reinstall Ubuntu 16.04 and after getting pull my symfony 3.4 project from git, it loads but without CSS and JS. I think that the problem with the permissions for folders and files.
If it's permissions related, then first make sure of which user is your web user.
If you never changed it, then it's www-data
As for the permissions, do this (replace www-data if needed):
chown -R www-data:www-data /var/www/
find /var/www/ -type d -exec chmod 0775 "{}" \;
find /var/www/ -type f -exec chmod 0664 "{}" \;
find /var/www -type d -exec chmod g+s "{}" \;
[Warning]
In some projects like symfony, some files have the execution permission.
Doing this will remove the permission.
Thus, I recommand to move all your projects out of the /var/www folder before doing this.
When done with permissions, just copy (not move) your projects in the /var/www folder, they will inherit web user and web group (www-data in this case) and keep execution permission.
[Side note]
You're using too many tags.
file-permissions, symfony, ubuntu should have been enough... ;)

file and folder permission settings for WordPress folder on linux

I have moved my website project to a linux environment and I have an issue assigning permission.
Command that I run:
sudo chown -R admin01:admin01 /var/www/html/counsyl
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
If I set
sudo chown -R admin01:admin01 /var/www/html/counsyl
where admin01 is the username, and this user is not root. I am able to edit the files and folders but the issue is I can't add images or upload plugins etc from the WordPress admin area.
If I run the following command
sudo chown www-data:www-data -R *
It allows me to upload images or plugins etc. But now I am unable to edit the files etc from admin01 account.
So what might be the correct permission so that I can edit the files with admin01 user(not root) and at the same time upload files and folders from the WordPress admin area? I will appreciate if you can give some explanation also so that I understand what I am doing wrong.
Permissions of folders and files inside WordPress folder after running the command
sudo chown admin01:www-data -R /var/www/html/counsyl
Have you tried with 755 permission mate?
chmod -R 755 /var/www/html/counsyl
I think above will help you
Try adding both owner as admin01 and user as www-data. This will help you:
sudo chown admin01:www-data -R /var/www/html/counsyl
Try this, it should work. Structure is like
chown -R USERNAME:GROUPNAME /PATH/TO/FILE
Thank you

Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server?

Hi anyone can help me for this issue , I have developed a site and it is hosted on my development server but now my client wants to move it to his own production server, and my client doesn't have access to his cpanel for this server. I only have the ftp access, so I have added his database in my own development server, while in development I used my amazon s3 for storing the images , when I push to production I loss the amazon plugin . I can't able to install the plugin , so I moved to upload once again to those images through WordPress, now I face this error while uploading an image : Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server? , and change the ftp file permission access to 755 and changed the uploads file permission to 777 , Still I am not able to upload the images, can some one help me for this issue.
This is a problem of the Apache permissions. I had this problem and i broke my mind for many days to understand what was happening.
The correct way (USE IT):
(the solution that i used, and worked)
You need to give Rewrite permissions to the Apache.
For Ubuntu:
Run via ssh: chown -R www-data:www-data /var/www/the/wordpress/directory
For Centos:
Run via ssh: chown -R apache.apache /var/www/the/wordpress/directory
The Wrong Way (I don't recommend it, but works...)
You can change the permissions to 777 in all the paths that Wordpress need to change. wp-content/plugins recursively on folders to solve install/update problems, and wp-content/uploads recursively on folders to solve upload media problems.
Never use it because you are giving permissions to anyone change your files. A open way for the crackers that don't like you.
run these command to provide proper file permissions
Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
Set group ownership inheritance
sudo chmod g+s /var/www/html/;
Set the permissions of the files/directories
sudo find /var/www/html/ -type d -exec chmod 755 {} ;
sudo find /var/www/html/ -type f -exec chmod 644 {} ;
Give write permissions to the group (for editing files via FTP)
sudo chmod -R g+w /var/www/html/;

Enabling write permissions Ubuntu Server in var/www/image directory

I'm trying to get my php test upload script to work and was wondering what the command would be to allow files to be uploaded in ubuntu server in the var/www/image directory
What username will be uploading the files? Usually on Ubuntu the Apache web server username is www-data. You can check for sure by finding the web server process in a process list command and seeing which username under which it is running.
ps aux | grep apache or ps aux | grep httpd should give you that answer.
Then you will usually want to make that Apache username the owner of the directory and all files and directories within it:
cd /var/www/image
# recursively (all subdirs & files) set owner to www-data for current directory
chown -R www-data .
Ordinarily, the above should be enough, but if for some reason the directory, files or subdirectories do not have write permission for the owner username, that's easily fixed by changing the permissions to add that write access, like this:
cd /var/www/image
# recursively add "w"rite permissions for the "u"ser (owner) to current directory
chmod -R u+w .
cd /var/www/image
For file like image you don't need execution permission :
sudo chmod 664 *
If you have directories inside image and you want to apply permission :
sudo find . -type d -exec chmod 755 "{}" \;
This will recursively search your directory and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
sudo find . -type f -exec chmod 644 "{}" \;
File name with space case (thanks to Nicklas B)
find . -type f -print0 | xargs -0 chmod 644
Change edit group to www-data
chown -R (owner):www-data (folder)
And folder permission to 775
cd /var/www
sudo chmod 775 image
You'll be prompted to enter the admin password - do so, and hit [return].
Change edit group may solve most of the problems of permissions.
Changing do www-data and set permission to 775.

Categories