Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am running apache2 in Ubuntu 14.04. I have been having trouble with permissions with FTP clients and CMS that use backend FTP. I never seem to be able to get the permissions right. Should www-data be the owner of /var/www/html and root as a user assigned to that group?
Some CMSes and Wordpress is especially bad about that because it's actually in the code to use the web user.
BTW you should never need to use root for ftp. www-data the default apache user on ubuntu should own your web files/directory to work properly with many cmses.
So this is what has worked before and what we did for clients with the same issue. chown the whole web root as www-data for both user and group.
So if your document root is /var/www/html, cd or change directory to /var/www and run this to change ownership on all files and directories.
chown -R www-data: html/
while still in the /var/www directory add write permissions to the group for files and directories by running this command.
find html -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +
Finally add your FTP user to the www-data group.
usermod -a -G www-data username
Replace usename with your FTP client username
Now this setup should allow you to use manage files and still allow the CMS ftp backend to still function and write to the direc. Let me know how that works for you.
This command worked for me:
sudo chown $(whoami) your_folder_name
Related
I'm trying to make some sort of cloud application on a headless raspbian machine.
The testing happens on a wamp-server running on windows8.1. PHP version is 5.6
The code works fine on my testing windows, but I run into issues when running the same code on my linux server. I've narrowed down the issue to the fact that (the linux user behind) my PHP code doesn't have write permissions on the folder where it should store files.
I can think of two ways to solve the issue: either give that php-user permissions, or change the user behind the php code. The last one would be quite interesting if it was possible to change per-script.
So, for my concrete question:
1) Where can I find what user is being used by my PHP code?
2) Can I change what user my PHP code uses, preferably on a per-project basis?
EDIT:
My script was running as root, as is shown by echo get_current_user();. I changed ownership of all files to root:webhosting, which was previously ftpuser:ftpgroup. However, when setting permissions to 770 I get access denied
EDIT2:
When using var_dump(posix_geteuid()); instead of get_current_user();, i get UID 33, which matches user www-data.
SOLUTION:
By looking at the EUID with var_dump(posix_geteuid(); I was able to validate the actual user, which does NOT match the get_current_user();. Changing the directroy and all files in it with sudo chown -R www-data:www-data <root of site> I managed to set the correct permissions.
I am not sure what the specifics are but normally when I have issues like that I change the ownership to www-data:www-data and if necessary for upload folders I change the folder permissions to 0755 and inside files permissions to 0644.
EDIT
I changed the permissions setting for security purposes.
You're PHP/Apache user is probably www-data. You probably want to run something like this.
sudo find path/to/project/ -exec chown www-data:root {} \;
File permissions may also be a problem. If so, run something like this.
sudo find path/to/project/ -type d -exec chmod 775 {} \;
sudo find path/to/project/ -type f -exec chmod 664 {} \;
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have mapped to a Windows share using cifs/samba on CentOS. Using this command:
sudo mount -t cifs -o username=Username //path/to/share /var/share
My PHP application now needs the ability to create directories and upload files to /var/share (which is now the mapped cifs share). All of the files there all belong to root:root. When I attempt to do a chown to change the files to apache:apache, there are no errors thrown by Linux, but when I do an ls -l, it still shows the owners to be root:root.
Is there a way to get around this so my app can write to the share?
The username in your mount command is the "Windows" username, with the authentication being managed by Samba. By default, the exported volume has everything owned by root. What you need to do is to specify the *NIX user and group names in your mount command. Here's what I do to mount my Mac on my Ubuntu box, using Apple's CIFS implementation:
sudo mount -t cifs //192.168.1.3/Shared /media/Shared -o username=mike,password=XXXX,uid=1000,gid=1000,nounix,sec=ntlmssp
You can use textual names instead of numbers for the uid and gid. the "nounix,sec=ntlmssp" is needed for compatibility with recent versions of the Mac OS X CIFS server.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am using ubuntu 12.04
When I am running my index file like"localhost/index.php" its working fine.
at the same time when I am running my script like "localhost/mypage/index.php" then it return a error called
You don't have permission to access /mypage/index.php on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
Please help me to overcome the problem ../thanks
Assuming you have your files in /var/www and have installed the default stack that Ubuntu provides, the proper way is to add your user to the www-data group and then chown that folder. Open a terminal and type:
sudo useradd -g www-data myuser
sudo chown -R www-data /var/www/
Perhaps the web user doesn't have permission to access sub-directories? You can CHMOD/OWN to the user apache run's as?
Find out the user read this article: https://stackoverflow.com/questions/2509334/finding-out-what-user-apache-is-running-as
Using CHMOD:
sudo chmod -R /folder/path/
sudo chown -R _www_user:_www_group /folder/path
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 14 hours ago.
Improve this question
I've recently converted over to Amazon's Elastic Beanstalk which has been great but I have one problem I haven't been able to fix or find a decent solution to.
When deploying via GIT with
$ git aws.push
My files are deployed but all my folders and files do not have the correct permissions. Currently running Win 8 with xampp for local development. For example on a recent WordPress deployment, all my folders were 777 once deployed to beanstlak. It is an NTFS partition the files are in too.
It is easy enough to SSH in and run:
$ sudo su
$ find /var/www/html/ -type d -exec chmod 755 {} \;
$ find /var/www/html/ -type f -exec chmod 644 {} \;
However I'd rather fix my permissions before upload however I don't think this is possible with Windows. I'm sure I can setup a script or some type of service hook to run these on deployment but I was hoping there may be an easier way.
Any insight from the SO community on setting windows file permissions to match Apache's?
It's actually not that hard to setup a hook to fix the permissions after your code is extracted onto your instance(s) but before it is considered "deployed". You could create a file called .ebextensions/00permissions.conifg, the name isn't important as long as it's in the right folder with the extension .config - the config scripts execute in alphabetical order. The contents would be like:
container_commands:
00fix_permissions_dirs:
command: "find . -type d -exec chmod 755 {} \;"
ignoreErrors: true
01fix_permissions_files:
command: "find . -type f -exec chmod 644 {} \;"
ignoreErrors: true
Note the default directory for a container_command is the directory the deploy files have been extracted to, so no need to set an explicit path.
You can see more info about the kinds of commands you can run on your instances in the Elastic Beanstalk documentation.
container_commands:
00fix_permissions_dirs:
command: "find /var/app/ondeck -type d -exec chmod 755 {} \;"
ignoreErrors: true
01fix_permissions_files:
command: "find /var/app/ondeck -type f -exec chmod 644 {} \;"
ignoreErrors: true
This will change the file permissions of the application. Currently there is no way to run commands when the app is fully deployed, but you can take advantage of the "ondeck" folder which is the folder where beanstalk put your app files before deploying them.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
So here is my problem. Its started when I discovered that I couldn't install plugins or themes in WordPress from the admin panel, it just kept asking for my connection info ( http://cl.ly/DLdH/o ).
I found a blog post which suggested changing the ownership of the wordpress folder to the Apache user, i.e. _www like so
sudo chown -R _www ./
That did, partially, fix the problem as I was able to install plugins and themes as well as writing to the directory through PHP which was all good but then I couldn't add/delete/edit any of the files in my text editor or even in Finder. It just keeps asking for my user password in order to process the action.
Changing the ownership back fixes the password issue but then I cant do any writing to the directory though PHP anymore.
Is there a way to allow me do both things at the same time?
EDIT:
I came across this cmd
sudo dscl . -append /Groups/_www GroupMembership [myUsername]
which added me i.e. my username to the group _www, then I executed
sudo chown -R _www .
sudo chgrp -R _www .
then it worked!
Have the user own the files. Change the group to _www. Give write permission to group.
chown -R <username> .
chgrp -R _www .
chmod -R g+w .