LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-05-2014, 07:21 AM   #1
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

Rep: Reputation: 1
Permission denied while uploading files in htdocs because owner and group is apache


I have a ftp user which is created to upload files in apache's htdocs directory (/var/www/html)
There are some project directories in /var/www/html which needs owner and group both 'apache' to work correctly but if directory's owner and group is 'apache', ftp user is not able to upload files in those directories and if I change the owner and group of the project directory to ftp user's, the functionality does not work.

What should I do to solve this problem.
Please help.

--Thanks & Kind Regards
Sam
 
Old 09-05-2014, 08:04 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
Make ftp user a member of apache group? Set write permission for others in the upload directories?

Or maybe use apache module mod_ruid2 and set owner of /var/www/html to any user you want in httpd config and in filesystem
 
Old 09-05-2014, 08:13 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I like keefaz idea with the ftp user inside the apache group. Else you could check into ACL and have the ftp group or user write permission to the directory.
 
Old 09-05-2014, 09:17 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
What distribution is this?

Those with SELinux enabled also need to have the proper security labels applied to the file - and that is likely not done by ftp.
 
Old 09-17-2014, 06:31 AM   #5
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

Original Poster
Rep: Reputation: 1
Sorry for Late Answer.
It is CentOS 6.5. vsftpd as a ftp daemon installed on it. httpd is installed on it.
No, SELinux is not installed on it. May be it was installed before but now there is no SELinux.

I think the owner and group of htdocs directory(/var/www/html) should be apache.

This is the line in /etc/passwd
Code:
apache:x:48:48:Apache:/var/www:/bin/bash
user:x:1001:501:FTP USER user:/home/www/html:/bin/bash
This is the line in /etc/group
Code:
user:x:501:apache
apache:x:48:user
I have assigned group user to apache as well as group apache to user, but still not able to upload files into htdocs(owner & group apache) when logged in as user from ftp.
 
Old 09-17-2014, 07:17 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
I don't think that would change anything.

Apache doesn't run with multiple groups. The group the process runs under is specified in the apache configuration file (48).

All the group file does is give the USER access to both gids.

Now if the apache user logged in, then that user would have access to both.

You also don't address what the users UMASK is for ftp. Normally (for security) it is set to 077, which would prevent group or world access unless the ftp user changes the access mode.
 
Old 09-17-2014, 09:32 AM   #7
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 810

Rep: Reputation: 264Reputation: 264Reputation: 264
Did you add the ftp user to the apache group? Then make sure that the group has write access to the files.

EDIT: On my Debian system, I think that my /var/www/ was owned by root... did you double-check the ownership of those files?

Last edited by maples; 09-17-2014 at 09:34 AM.
 
Old 09-17-2014, 09:42 AM   #8
Germany_chris
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Arch
Posts: 1,021

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Quote:
Originally Posted by unclesamcrazy View Post
Sorry for Late Answer.
It is CentOS 6.5. vsftpd as a ftp daemon installed on it. httpd is installed on it.
No, SELinux is not installed on it. May be it was installed before but now there is no SELinux.

I think the owner and group of htdocs directory(/var/www/html) should be apache.

This is the line in /etc/passwd
Code:
apache:x:48:48:Apache:/var/www:/bin/bash
user:x:1001:501:FTP USER user:/home/www/html:/bin/bash
This is the line in /etc/group
Code:
user:x:501:apache
apache:x:48:user
I have assigned group user to apache as well as group apache to user, but still not able to upload files into htdocs(owner & group apache) when logged in as user from ftp.
Unless you uninstalled SELinux or turned it off it's enabled by default.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Apache htdocs owner:group 500:500?? DJRcomputing Linux - Server 2 07-07-2011 09:58 PM
squirrelmail on openBSD, Permission denied (13) in /htdocs... sarajevo Linux - Server 8 05-12-2009 07:34 AM
permission denied to paste files to secure micro chip. 'owner' is 'root'. who?me? Linux - Newbie 1 05-03-2009 08:46 AM
permission denied to paste files to secure micro chip. 'owner' is 'root'. who?me? Linux - Newbie 1 05-03-2009 08:40 AM
Uploading files using PHP giving Permission Denied error MatthewG Programming 4 05-27-2004 04:38 PM


All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration