We help IT Professionals succeed at work.

How do I give addmin permission to PHP user/permission to write to filesystem on Ubuntu 14 server?

733 Views
Last Modified: 2014-08-07
Hi,

When joomla or wordpress try to write to the filesystem, which user do they use?
Is it possible to give that user admin permissions?

I did a test on my MAIN SERVER (ubuntu 14.04 x64 with php 5.5.9) and on page 3 of this application I got one error:
PHP cannot write to filesystem: http://www.mismatched.be/index.php?step=2

I also use two shared hosting servers, one in the US and on in Italy and the same test does not give that error:
http://www.associazioneculturaleinasia.it/check.php?step=2
and
http://just.bo/index.php?step=2

How is it that automatically on those servers when I use Joomla or Wordpress the CMS installation software can write to .htaccess, configuration.php and wp-config.php files and tmp, cache, logs folders without any problems and on my I get errors?

On my ubuntu MAIN SERVER server (with the php permissions problem) I manually upload joomla.zip or wordpress.zip and unzip them and then I use the following command to give the permissions:

for the directories
sudo find /site_installation_folder/ -type d -exec chmod 755 {} \;


for files only
sudo find /site_installation_folder/ -type f -exec chmod 644 {} \;


What am I doing wrong and how to enable the right permissions so that I don't have to set 777 chmod permissions on any folder?

thanks in advance
Comment
Watch Question

Kent WSr. Network / Systems Admin
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Sysadmin
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi mugojava thanks for your message.
Do I change the owner for a CMS folder using:

sudo chown -R apache:apche /path_to_folder/

thanks

Author

Commented:
ah thanks David will try right away :)
Kent WSr. Network / Systems Admin
CERTIFIED EXPERT

Commented:
Yes, that how to change the user.group.  Then set your permissions the same way using chmod
(sudo chmod -R 550 /path_to_folder/)
And on the certain files that need apache to write -
(sudo chmod 660 /path_to_folder/file.ext)

Do you understand what each integer's place means in the chmod permissions?

Author

Commented:
works! thanks!

I changed the permissions on the entire folder and everything works.

By the way, when I use SCP now to connect, my user "lupocatttivo" cannot delete, rename etc. files that are owned by www-data. Is it possible to add my user "lupocatttivo" to the www-data group as well as the admin group (which it already is). Is this possible?

thanks again
Yes.
Kent WSr. Network / Systems Admin
CERTIFIED EXPERT

Commented:
Yes, you can do that, or just use sudo.  Sudo is safer.

Every user also has a "group", so you can change owner to like apache.lupocatttivo, and give yourself either r+w (6) or rwx (7),  So for apache.lupocattivo, 570 would give apache read, your group "lupocatttivo" rwx, and all others nothing.

In the permissions, say 660, the first 6 is for "user", second 6 is for "group", and last 0 is "all others".

Apache will work correctly if it's got appropriate permissions as either user or group.  You don't have to have it as both user and group, that's just a common method.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.