LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-13-2007, 11:00 PM   #1
jarrell
LQ Newbie
 
Registered: Jun 2006
Location: United States
Distribution: Fedora
Posts: 13

Rep: Reputation: 0
Unhappy Apache Virtual Hosts


Okay here is the situation; without adding a virtualhost directive all domains pick up on the default httpd installation page. I then add in a virtualhost directive for one of my domains and point its domain root to the folder where the webfiles are stored for that domain and I get forbidden. I then did a chmod -R 755 on the folder where the webfiles are stored and located. I restart apache and still get the same thing. I take the virtualhost directive out and bam the domain pulls up the default page again.

** THIS IS THE httpd default install **, btw it was upgraded via the package updater. I am also trying to avoid having to uninstall this and compiling it from scratch (to keep from manually updating)
 
Old 07-14-2007, 07:28 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
What is the ownership on the files for the domain? You might also post your virtual hosts section and maybe someone will spot something.


By the way, the way virtual hosts work on Apache is if a request comes in for a virtual domain that is not listed (or the entry is somehow goofed up) the first listing (usually the default page) is what is returned.
 
Old 07-15-2007, 12:38 AM   #3
jarrell
LQ Newbie
 
Registered: Jun 2006
Location: United States
Distribution: Fedora
Posts: 13

Original Poster
Rep: Reputation: 0
Arrow Re: Apache Virtual Hosts

Quote:
Originally Posted by Hangdog42
What is the ownership on the files for the domain? You might also post your virtual hosts section and maybe someone will spot something.


By the way, the way virtual hosts work on Apache is if a request comes in for a virtual domain that is not listed (or the entry is somehow goofed up) the first listing (usually the default page) is what is returned.
Okay here is the directory listing:

drwxr-xr-x 2 jarrell jarrell 4096 Jul 15 00:53 .
drwxr-xr-x 5 jarrell jarrell 4096 Jul 15 00:53 ..
-rwxr-xr-x 1 jarrell jarrell 229 Jul 13 21:17 index.html
-rwxr-xr-x 1 jarrell jarrell 81488 Jul 13 19:02 splash.gif


Also I have removed the httpd package via the Yum Extender and compiled apache/php and still came up with same problem! anyway here is the VirtualHosts directives:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost optiplex.ckionline.net:80>
ServerAdmin hostmaster@ckionline.net
DocumentRoot /home/jarrell/www
ServerName jtjonline.net
ServerAlias www.jtjonline.net
ErrorLog logs/jtjonline-error_log
CustomLog logs/jtjonline-access_log common
</VirtualHost>

<VirtualHost optiplex.ckionline.net:80>
ServerAdmin hostmaster@ckionline.net
DocumentRoot /home/andrew/www
ServerName andysdev.com
ServerAlias www.andysdev.com
ErrorLog logs/andysdev-error_log
CustomLog logs/andysdev-access_log common
</VirtualHost>

<VirtualHost optiplex.ckionline.net:80>
ServerAdmin hostmaster@ckionline.net
DocumentRoot /var/webhosting/altsqlc.com
ServerName altsqlc.com
ServerAlias www.altsqlc.com
ErrorLog logs/altsqlc-error_log
CustomLog logs/altsqlc-access_log common
</VirtualHost>

<VirtualHost optiplex.ckionline.net:80>
ServerAdmin hostmaster@ckionline.net
DocumentRoot /home/rafael/www
ServerName theralfinator.com
ServerAlias www.therafinator
ErrorLog logs/theralfinator-error_log
CustomLog logs/theralfinator-access_log common
</VirtualHost>

<VirtualHost optiplex.ckionline.net:80>
ServerAdmin hostmaster@ckionline.net
DocumentRoot /usr/local/apache2/htdocs
ServerName ckionline.net
ServerAlias www.ckionline.net www.computerkingsinc.net computerkingsinc.net
ErrorLog logs/ckionline-error_log
CustomLog logs/ckionline-access_log common
</VirtualHost>

(btw...i placed optiplex.ckionline.net in the brackets to see if I could solve the problem and still came up with nothing.....please help! thanks!
 
Old 07-15-2007, 07:02 AM   #4
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
<VirtualHost optiplex.ckionline.net:80>
I do my declarations a bit differently, and the fact that you've got a domain there may be causing trouble. Here is an example of how I declare a virtual host:

<VirtualHost *:80>
Quote:
-rwxr-xr-x 1 jarrell jarrell 229 Jul 13 21:17 index.html
Who is your Apache server running as (I'm looking for user and group here)? I know you've got your files set to be world readable, but can the apache user get into the directory structure as well? You can test this by using su to become the Apache user and then seeing if you can read the file. If you can't, then look at the directory permissions or change the ownership to include whatever group Apache is running under.
 
Old 07-16-2007, 03:31 AM   #5
jarrell
LQ Newbie
 
Registered: Jun 2006
Location: United States
Distribution: Fedora
Posts: 13

Original Poster
Rep: Reputation: 0
Arrow

Quote:
Originally Posted by Hangdog42
I do my declarations a bit differently, and the fact that you've got a domain there may be causing trouble. Here is an example of how I declare a virtual host:

<VirtualHost *:80>


Who is your Apache server running as (I'm looking for user and group here)? I know you've got your files set to be world readable, but can the apache user get into the directory structure as well? You can test this by using su to become the Apache user and then seeing if you can read the file. If you can't, then look at the directory permissions or change the ownership to include whatever group Apache is running under.
Here is the deal. We all want to protect our directories even though we trust each other but I had to do a chmod 755 on the home directories of all users who are doing webhosting. Our files as stated are in www (i hate public_html....LOL) under our home directories and we arent trying to put our files outside of that. So if there is another way to doing this I am open for suggestions. Thanks but right now the apache side of things seems to be working.
 
Old 07-16-2007, 07:44 AM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
We all want to protect our directories even though we trust each other but I had to do a chmod 755 on the home directories of all users who are doing webhosting. Our files as stated are in www (i hate public_html....LOL) under our home directories and we arent trying to put our files outside of that.
Off the top of my head, about the only other thing I think you could do would be to put the Apache user in each group doing webhosting (from what you've posted I'm guessing that each user doing webhosting has their own group). That would allow you to not have the files world readable. In other words, you could change the permissions to 750 and (hopefully) still give Apache appropriate access.
 
Old 07-16-2007, 11:10 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Code:
/home
  +-- user1 (owner user1, group whatevergroup, permissions 711)
  |     +-- website (owner user1, group nobody; permissions 750)
  |     |      +-- web (owner user1, group whatevergroup; permission 755)
  +     +-- other user1 directory (default settings)
  +-- user2
  |     +-- website
  |            +-- web
My apache runs as group 'nobody', hence I change the group for one directory (subdir website) in a users home directory to group 'nobody' and give it 750 so only the owner and the group 'nobody' can get in there. The owner can create files and directories with the normal permissions in this subdirectory and members of the group 'nobody' can read and excute/descend them and no other users can touch them.

In this scenario it best to make an additional subdir (web) that will be the document root.

PS Only tested for access by other users, not for group apache
 
  


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
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
Virtual Hosts with Apache noripcord7 Linux - Games 1 02-22-2004 10:33 PM
Apache Virtual Hosts quozt Linux - General 3 10-15-2003 09:51 AM
Apache/Virtual Hosts Help C-Squared Linux - General 9 08-04-2003 12:45 PM
apache virtual hosts jonfa Linux - General 1 06-04-2002 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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