Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Mar 23, 2006 5:05 pm 
Offline
Senior Newbie

Joined: Thu Mar 16, 2006 2:22 pm
Posts: 6
I am running Debian small and have Apache2 installed. I have a couple of web sites I run using named virtual hosts. These are in /var/www/name.of.vhost1, /var/www/name.of.vhost2, etc.

I set these directories up as root, and then used chown to change the user to myself and the group to www-data. I am looking for an easy way to manage the permissions and groups of all of my web content. Every time I create a file or directory will I have to run chmod and chown to set the permissions?

What are some of the best practices for setting up virtual host directories and files?


Top
   
 Post subject:
PostPosted: Fri Mar 24, 2006 1:13 am 
Offline
Senior Newbie

Joined: Thu Mar 31, 2005 12:49 am
Posts: 10
What is the purpose of chowning stuff to www-data? Unless you have a reason otherwise, chown it to your default group. Then you can work with files inside the directory without having to manage permissions.


Top
   
 Post subject:
PostPosted: Fri Mar 24, 2006 1:39 pm 
Offline
Senior Newbie

Joined: Thu Mar 16, 2006 2:22 pm
Posts: 6
Beek wrote:
What is the purpose of chowning stuff to www-data?


I'm not sure. That is what the User and Group directives in Apache are set to, I'm not real clear on what the significance of these are.

If I own the access.log file and have it set to my default group will Apache be able to write to it?


Top
   
 Post subject:
PostPosted: Fri Mar 24, 2006 2:11 pm 
Offline
Senior Newbie

Joined: Thu Mar 31, 2005 12:49 am
Posts: 10
Okay, I'm a little confused about what is going into these directories... I think people conventionally public content that will be served by apache in /var/www, while log files go to some subdirectory of /var/www

You have to be careful with the permissions of log files, since Apache writes to them as root (and www-data or whatever user you have set in httpd.conf). See http://httpd.apache.org/docs/1.3/misc/s ... serverroot

For my server, I have all the apache logs in /var/log/www, and that directory is only readable and writable by root. When logrotate runs, the old logs get moved to another directory that is world readable.


Top
   
 Post subject:
PostPosted: Fri Mar 24, 2006 2:28 pm 
Offline
Senior Newbie

Joined: Thu Mar 16, 2006 2:22 pm
Posts: 6
Beek wrote:
Okay, I'm a little confused about what is going into these directories... I think people conventionally public content that will be served by apache in /var/www, while log files go to some subdirectory of /var/www


In each /var/www/vhost directory, I have directories for htdocs, cgi-bin, and other content. I also put a log directory in here for the access and error logs for each vhost.

Beek wrote:
For my server, I have all the apache logs in /var/log/www, and that directory is only readable and writable by root. When logrotate runs, the old logs get moved to another directory that is world readable.


I want a seperate log for each vhost. Is it better to put them somewhere under /var/log as opposed to /var/www? What do I need to do to get logrorate to rotate the new logs?


Top
   
 Post subject:
PostPosted: Sun Mar 26, 2006 5:11 am 
Offline
Senior Newbie

Joined: Thu Mar 31, 2005 12:49 am
Posts: 10
edwaldspurger wrote:
Beek wrote:
For my server, I have all the apache logs in /var/log/www, and that directory is only readable and writable by root. When logrotate runs, the old logs get moved to another directory that is world readable.


I want a seperate log for each vhost. Is it better to put them somewhere under /var/log as opposed to /var/www? What do I need to do to get logrorate to rotate the new logs?


It is a potential security risk to have the logs in that directory if they aren't owned by root, or if any of the parent directories aren't owned by root. And you can still have separate logs for each vhost. My logs for each vhost are named /var/log/www/vhostname_access.log, /var/log/www/vhostname_error.log, etc... To get them under logrotate's control, I created /etc/logrotate.d/httpd with this content:

Code:
/var/log/www/*.log {
  missingok
  daily
  notifempty
  sharedscripts
  postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true;
  endscript
}


Of course it would need some adjustment for your setup.


Top
   
 Post subject:
PostPosted: Sun Mar 26, 2006 10:16 am 
Offline
Senior Newbie

Joined: Thu Mar 16, 2006 2:22 pm
Posts: 6
Thank you for all the help Beek!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group