LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 06:21 AM   #1
unclesamcrazy
Member
 
Registered: May 2013
Posts: 200

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, 07:04 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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, 07: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, 08:17 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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, 05:31 AM   #5
unclesamcrazy
Member
 
Registered: May 2013
Posts: 200

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, 06:17 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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, 08:32 AM   #7
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
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 08:34 AM.
 
Old 09-17-2014, 08:42 AM   #8
Germany_chris
Senior Member
 
Registered: Jun 2011
Location: NOVA
Distribution: Debian 12
Posts: 1,071

Rep: Reputation: 497Reputation: 497Reputation: 497Reputation: 497Reputation: 497
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



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 08:58 PM
squirrelmail on openBSD, Permission denied (13) in /htdocs... sarajevo Linux - Server 8 05-12-2009 06:34 AM
permission denied to paste files to secure micro chip. 'owner' is 'root'. who?me? Linux - Newbie 1 05-03-2009 07:46 AM
permission denied to paste files to secure micro chip. 'owner' is 'root'. who?me? Linux - Newbie 1 05-03-2009 07:40 AM
Uploading files using PHP giving Permission Denied error MatthewG Programming 4 05-27-2004 03:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 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
Open Source Consulting | Domain Registration