LinuxQuestions.org
Visit Jeremy's Blog.
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 04-24-2008, 09:42 PM   #1
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: My HDD...
Distribution: WinXP for designing, Linux for life.
Posts: 2,329
Blog Entries: 1

Rep: Reputation: 47
Please check my virtualhost...


I need to set up a virtualhost (for the first time), and I wanted to make sure I had it set up correctly before I uncommented it.

How does this look? (link to copy of httpd.conf)
 
Old 04-24-2008, 10:04 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Looks OK to me. I'd put the ServerName at the top to make it more readable, but it doesn't actually matter.

I assume that your DocumentRoot is correct, etc.

Give it a try - it won't damage anything is you do have a mistake
 
Old 04-25-2008, 12:54 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You have Slackware12 in you signature, however not sure if that's the distro that you're using for your webserver.

If you run a stock Slackware 12 box, vhosts are defined in /etc/httpd/extra/httpd-vhosts.conf. You uncomment one line in /etc/httpf/httpd.conf as shown below to activate it; this line is commented out (so non-functional) by default
Code:
Include /etc/httpd/extra/httpd-vhosts.conf
The content of my httpd-vhosts.conf:
Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

# catch-all
<VirtualHost *:80>
    ServerAdmin my@email.here
    DocumentRoot /srv/httpd/htdocs
    ServerName btd-techweb02
</VirtualHost>

# site 1
<VirtualHost *:80>
    ServerAdmin my@email.here
    DocumentRoot /home/wim/www/site1/web
    ServerName site1.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site1/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# site2
<VirtualHost *:80>
    ServerAdmin my@email.here
    DocumentRoot /home/wim/www/site2/web
    ServerName site2.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site2/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


# site3: stringdokter.com
<VirtualHost *:80>
    ServerAdmin your@email.here
    DocumentRoot /home/phantom_cyph/www/stringdokter/web
    ServerName www.stringdokter.com
    ErrorLog /var/log/httpd/stringdokter.com-error_log
    CustomLog /var/log/httpd/stringdokter.com-access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/phantom_cyph/www/stringdokter/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
I have added your site (italic) to show you, but not tested it.

As you might notice, I don't use the standard apache directory for the websites, but the user's home directory. Reason is that I consider it easier when it comes to ftp. Usually a system administrator wants to jail ftp-users to their home directory and I have seen too many questions regarding permissions and access to /var/www/htdocs in relation with ftp. In the setup that I have choosen, a user can ftp to his/her home directory and descend into the web directory to update the website. Disadvantage however is that if apache needs to write files, you need to open the permissions a bit.

My directory tree for the sites looks like this:
Code:
/home
   |
   +--- wim
   |     |
   |     +--- www
   |           |
   |           +--- site1
   |           |     |
   |           |     +--- web (externally accessible files go here, e.g. webpages)
   |           |     |     |
   |           |     |     +--- files (directory that can be written by apache)
   |           |     |
   |           |     +--- inc (files required for the website, but need to be kept secure, go here)
   |           |
   |           +--- site2
   |           |     |
   |
   +--- phantom_cyph
   |     |
   |     +--- www
   |           |
   |           +--- stringdokter
   |           |     |
   |           |     +--- web
   |           |     |     |
   |           |     |     +--- files
   |           |     |
   |           |     +--- inc
   |           |
I saw that you have php enabled, so here a small tip which also explains the inc directory in my setup:
I don't want php code that e.g reveals login credentials for a database to be accessible from the outside world (anything in web is), so that goes in inc. The webpage that uses that code will go in web and will use a include statement to access it.


Sorry for the long story, I hope it helps a bit in understanding things.
 
  


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
403 using VirtualHost... kvnband Linux - Server 1 03-01-2007 05:13 AM
Postifx and VirtualHost maginotjr Slackware 3 12-05-2005 10:28 AM
VirtualHost amdathlonboy Linux - Networking 2 06-22-2004 06:23 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 03:10 AM
Help with Apache <VirtualHost> please. smakkythecamel Linux - Networking 2 06-12-2003 08:15 PM

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

All times are GMT -5. The time now is 03:21 AM.

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