LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-23-2006, 10:38 PM   #1
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Rep: Reputation: 30
Apache: Allowing IP Access and NameVirtualHost concurrently


Hi guys,

I have always been using NameVirtualHost to manage multiple domains on one machine.

But, for a clean httpd.conf (no namevirtualhost specified), any access to the server will default to DocumentRoot yah?

But I realise I can't do that if NameVirtualHost is enabled. Anyway to allow both way of access?
 
Old 08-24-2006, 04:46 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
I don't understand what your saying. I don't think the absense of a line "NameVirtualHost" makes httpd.conf all that much cleaner, but that's your call.

I have no trouble configuring Apache for both Virtual Hosting and also have a default DocumentRoot. I think that's what you're asking how to do. The first virtual host is your default host. Here's some cut/paste snippets from my httpd.conf showing bits and pieces of the setup. You can hit the three different hosts shown below like this (you can also hit one of the virtual host's files via the default host, I laid things out that way on purpose):
Code:
http://myhostname.domain.com
http://virthost1.domain.com
http://myhostname.domain.com:8000
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    # Default
    ServerAdmin me@myemail.com
    ServerName myhostname.domain.com
    ServerAlias myotherhostname.domain.com
    DocumentRoot /web/apache2/htdocs
    # blah, blah, blah
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin theotherguy@email.com
    ServerName virthost1name.domain.com
    ServerPath /virthost1/
    DocumentRoot /web/apache2/htdocs/virthost1
    ErrorLog logs/virthost1-error_log
    CustomLog logs/virthost1-access_log common
    RewriteEngine on
    RewriteRule ^(/virthost1/.*) /web/apache2/htdocs$1
    # blah, blah, blah
</VirtualHost>

<VirtualHost _default_:8000>
    ServerAdmin yetanotherguy@email.com
    ServerName myhostname.domain.com
    ServerPath /port8000/
    DocumentRoot /web/apache2/htdocs/port8000
    ErrorLog logs/8000-error_log
    CustomLog logs/8000-access_log common
    ScriptAlias /cgi-bin/ "/web/apache2/htdocs/port8000/cgi-bin/"
    # blah, blah, blah
</VirtualHost>
Note: I cut/pasted my httpd.conf snippets and manually edited to generalize things. Hopefully I didn't make any typos in that manual editing, but I certainly could have. Use as an example only.
 
Old 08-24-2006, 09:19 PM   #3
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
i'm sorry i am not clear enough. perhaps it is my lack of understanding on this issue - my apologies

What i'm looking at is to access the server via its IP (say http://192.168.1.10)
since we are still testing it. By accessing the server by that default IP, if there's nothing mentioned for DocumentRoot, it will show the Apache Test Page yah?
Let's say DocumentRoot in this case is /home/user

I then point beta.domain.com to it using NameVirtualHost (why am I doing this is because the actual domain.com is still pointing to another old server, doing migrating).
For this DocumentRoot, it will be in /home/user/beta


In this /home/user, there are other folders like /home/user/sql (phpMyAdmin), /home/user/other

so my question is: am I able to configure it such that I can access the server using the name (NameVirtualHost) http://beta.domain.com AND using the IP, http://192.168.1.10 and thus I can also access the other folders via http://192.168.1.10/sql etc...
 
Old 08-25-2006, 09:20 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
As haertig said, set up your first NameVirtualHost to point to /home/user. Then any access will default to this host. Also, if there is no valid DocumentRoot, Apache will spit out an error, not the test page. (You haven't pointed it to the test page).
 
Old 08-27-2006, 10:46 PM   #5
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Original Poster
Rep: Reputation: 30
ah.. i got it to work already.. many thanks for the pointers!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
allowing rsh access uerden Linux - Networking 5 11-08-2006 02:15 PM
Allowing access only to specific websites? matux Linux - Security 2 11-28-2005 09:18 PM
Allowing port access to non-root joosep Linux - Networking 1 08-05-2005 09:24 AM
Allowing only SFTP access vanibhat Linux - Enterprise 8 06-30-2005 02:10 AM
Allowing user access to one directory only aje Slackware 5 05-25-2005 08:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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