LinuxQuestions.org
Review your favorite Linux distribution.
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 03-16-2010, 06:53 PM   #1
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Rep: Reputation: 0
Permissions and Apache


(Kind of) Linux newbie, and I'm at the point where I usually wreck my installation.

Scenario:

LAMP installed, vsftpd livened up, and accepting connections from my username.

Now, usually I find I can't FTP stuff in, and figure I don't have permission. So I 'chmod 777' my /var/www and everything FTPs in fine. But of course I can't view the website, so I 'chown -R' to root (I know this isn't a good idea, but in an internal environment it's generally got me going).

Anyway, this isn't working for me, and I know isn't good practice - so what am I supposed to be doing exactly?
 
Old 03-16-2010, 06:58 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
The FTP user you are logging in as should belong to the same group that your /var/www directory belongs to. This would let both Apache and the FTP user have access without giving it up to everyone.
 
Old 03-16-2010, 07:15 PM   #3
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks - so do I need to set this user as the apache user also (or put apache in the same group perhaps)?
 
Old 03-16-2010, 11:32 PM   #4
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
I would put both the user and Apache itself in their own group, say "web". Only add users to the group that absolutely need access, keep everyone else out.
 
Old 03-17-2010, 12:35 AM   #5
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
make sure you chroot the user.
 
Old 03-17-2010, 06:00 AM   #6
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks - MS3FGX, how do I put Apache itself into a group?
 
Old 03-17-2010, 06:19 AM   #7
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
Quote:
Originally Posted by toothsome View Post
Thanks - MS3FGX, how do I put Apache itself into a group?
sample:
1.#groupadd webusers
2.either
edit /etc/group and add apache user on it
webusers:x:502:apache

or

#usermod -G webusers apache

then
chown -R apache:webusers /var/www/html/websample
chmod 760 -R /var/www/html/websample

so all included on the webusers group has access to upload/download and write

you can also consider these good parameters on vsftpd.conf
chown_username
chown_uploads
 
Old 03-17-2010, 08:34 AM   #8
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks - almost there, but still having a permissions issue:

Code:
drwxrw-r--  2 apache.user webusers 4096 2010-03-16 17:35 www
toothsome@ubu2:/var$ cd www
-bash: cd: www: Permission denied
I have done a
Code:
chmod 760 -R /var/www/
and even a
Code:
sudo chmod +g -R /var/www
and checked that my username is in 'webusers' but still no joy. I've also checked via my other test (trying to rename /var/www/index.html via FTP) but this isn't working. What have I missed?
 
Old 03-17-2010, 01:02 PM   #9
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
problem is you can't ftp right?what's the error?what user do you use to login? and what is the default home directory of the user your using to login to the ftp?
 
Old 03-17-2010, 01:10 PM   #10
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Original Poster
Rep: Reputation: 0
I can FTP fine, and move around the directories but it fails when I try to go from /var into /var/www

I'm using my username - toothsome. I've checked in the 'webusers' group:
Code:
webusers:x:1001:toothsome,apache.user
 
Old 03-17-2010, 01:36 PM   #11
freelinuxtutorials
Member
 
Registered: Oct 2009
Posts: 70

Rep: Reputation: 21
do you use "su - toothsome" when switch user. BTW, changing permission of /var/www is not really recommended . you can set it to default back to 755 with uid and gid as root. recommended is to set the default home directory of your ftp after /var/www/html
 
Old 03-17-2010, 01:50 PM   #12
toothsome
LQ Newbie
 
Registered: Mar 2010
Posts: 10

Original Poster
Rep: Reputation: 0
When do you mean to use 'su - toothsome'?
 
  


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
Apache Permissions smoothpeddi Linux - Newbie 3 05-23-2009 02:33 AM
Apache file permissions problem. {Apache/2.2.6 Fedora 8} hacker supreme Linux - Server 5 01-31-2008 04:26 PM
Apache permissions MicahCarrick Programming 2 07-26-2006 05:38 PM
Apache permissions mylo2003 Linux - Newbie 7 08-01-2003 08:06 PM
Apache Permissions Canadian_2k2 Linux - Networking 4 12-02-2002 02:51 PM


All times are GMT -5. The time now is 08:05 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