LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-20-2017, 11:37 AM   #1
raksasas
Member
 
Registered: Sep 2012
Posts: 55

Rep: Reputation: Disabled
Multiple sites with apache


Hi,
I am not sure what term to use here and not sure how to achieve it. Virtual host, alias, something else?

I have a freeBSD system as a local web server. I run Dokuwiki on it and mess around with Drupal/Joomla on it. I used Dokuwiki to keep hold my notes in it(projects, shopping list, etc). Now my kiddo's wants their places to keep their own notes. So I said sure.

Right now I have everything located here:
/usr/local/www/apache24/data/dokuwiki
/usr/local/www/apache24/data/drupal7
/usr/local/www/apache24/data/joomla36

What I am thinking I want to do is have it..
/usr/local/www/my_stuff
/usr/local/www/kiddo's_stuff
/usr/local/www/kiddo2's_stuff

http://10.1.1.13/My_stuff/index.html
http://10.1.1.13/My_stuff/wiki
http://10.1.1.13/My_stuff/drupal7
http://10.1.1.13/My_stuff/joomla36
http://10.1.1.13/kiddo1_stuff/index.html
http://10.1.1.13/kiddo1_stuff/wiki
html://10.1.1.13/kiddo2_stuff/index.html
html://10.1.1.13/kiddo2_stuff/wiki

I am not sure what to do in apache to get this to happen.

Thanks

Last edited by raksasas; 02-20-2017 at 11:40 AM.
 
Old 02-20-2017, 12:18 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
virtual servers with the IP to each one where for each one a different sub-directory to hold their stuff?

VirtualHost Examples

Code:
Mixed name-based and IP-based vhosts

Any address mentioned in the argument to a virtualhost that never appears in another virtual host is a strictly IP-based virtual host.

Listen 80
<VirtualHost 172.20.30.40>
    DocumentRoot "/www/example1"
    ServerName www.example.com
</VirtualHost>

<VirtualHost 172.20.30.40>
    DocumentRoot "/www/example2"
    ServerName www.example.org
</VirtualHost>

<VirtualHost 172.20.30.40>
    DocumentRoot "/www/example3"
    ServerName www.example.net
</VirtualHost>

# IP-based
<VirtualHost 172.20.30.50>
    DocumentRoot "/www/example4"
    ServerName www.example.edu
</VirtualHost>

<VirtualHost 172.20.30.60>
    DocumentRoot "/www/example5"
    ServerName www.example.gov
</VirtualHost>

Last edited by BW-userx; 02-20-2017 at 12:20 PM.
 
Old 02-20-2017, 03:19 PM   #3
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
why do you need virtual hosts for this?

You could just point the main apache instance at /usr/local/www for it's document root and it'd all work. Just have apache set to listen on *:80 or 10.1.1.13:80

documentroot: https://httpd.apache.org/docs/2.4/mo...l#documentroot
listen: https://httpd.apache.org/docs/2.4/mo...on.html#listen

if you want to create vhosts, then you'd need the first loaded vhost to be the one that points to /usr/local/www and instead of a listen directive, you declare the listen in the vhost directive itself.

Last edited by r3sistance; 02-20-2017 at 03:20 PM.
 
Old 02-20-2017, 10:28 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Yeah, an extra virtual host does not seem to be needed, the regular DocumentRoot would work. If you want a little fancier, maybe mod_userdir is in order.
 
Old 02-21-2017, 07:23 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
I agree forget what I suggested... just toss that idea on the fire and watch it burn.
 
Old 02-21-2017, 02:57 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,997

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Make one web page with links to the sites maybe.
 
Old 02-21-2017, 08:08 PM   #7
raksasas
Member
 
Registered: Sep 2012
Posts: 55

Original Poster
Rep: Reputation: Disabled
I am thinking modifying the "document root" is the best way...

But what if I want to this:

Servers name = webserver

so I want them to type:
http://kiddo1.webserver = http://10.1.1.13/kiddo1_stuff/index.html
http://kiddo2.webserver = http://10.1.1.13/kiddo2_stuff/index.html

Is that when I would do virtual host?

Sorry, I am still a little bit lost with virtual host. I am also having a few verbage/syntax issues transitioning from Debian to FreeBSD.

Last edited by raksasas; 02-21-2017 at 08:35 PM.
 
Old 02-22-2017, 12:04 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by raksasas View Post
so I want them to type:
http://kiddo1.webserver = /var/www/kiddo1_stuff/index.html
http://kiddo2.webserver = /var/www/kiddo2_stuff/index.html

Is that when I would do virtual host?
Yes, that would be a name-based virtual host.

If you want them to type:

http://webserver/~kiddo1/ = /home/kiddo1/kiddo1_stuff/index.html
http://webserver/~kiddo2/ = /home/kiddo2/kiddo2_stuff/index.html
Then that would be via mod_userdir instead.
 
Old 02-23-2017, 05:01 PM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
raksasas, is your concern with privacy (can't access each other's notes) or with a convenient way of typing e.g. name.server.com?
or both?
or something else?
 
1 members found this post helpful.
Old 02-24-2017, 06:58 AM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
why do you need virtual hosts for this?
Ray Charles saw this one coming.
 
Old 02-25-2017, 11:41 AM   #11
raksasas
Member
 
Registered: Sep 2012
Posts: 55

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
raksasas, is your concern with privacy (can't access each other's notes) or with a convenient way of typing e.g. name.server.com?
or both?
or something else?
Some of all of it.
  • Privacy - yes and no
  • Convenience - yeah.
  • Organizing the files
  • Hands on learning experience for me and the kiddos - Primary reason. Kind of the reason why I am avoiding the easy route of just changing the Apache "Document Root". I can read the stuff all day long but I have a very hard time grasping it until I do it.

Moving on. I have gotten the virtual host working but I have lost access to the stuff in /usr/local/www/apache24/data/. I am thinking it is because the both vhost is pointing to
Code:
/usr/local/www/my_stuff/
and not the /
Code:
usr/local/www/apache24/data/
Also, How do it get access to the stuff by IP if my DNS server goes down? My dns records both point to 10.1.1.13

Is this where I would do some port based vhost?

Last edited by raksasas; 02-25-2017 at 12:24 PM.
 
Old 02-25-2017, 02:33 PM   #12
raksasas
Member
 
Registered: Sep 2012
Posts: 55

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by raksasas View Post
I have gotten the virtual host working but I have lost access to the stuff in /usr/local/www/apache24/data/. I am thinking it is because all my vhost is pointing to
Code:
mystuff.conf = /usr/local/www/my_stuff/
kiddo1.conf = /usr/local/www/kiddo1/
kiddo2.conf = /usr/local/www/kiddo2/
and not the
Code:
/usr/local/www/apache24/data/
I got it working again. Kind of followed the Debian apache way by creating a file called 000-default.conf in the Includes folder.

I put this in it.
000-default.conf
Code:
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/apache24/data/"
</VirtualHost>
Now to figure out how to access the stuff if my DNS server happens to go down with out editing the local host file on my systems.
mystuff.webserver
kiddo1.webserver
kiddo2.webserver

Last edited by raksasas; 02-26-2017 at 07:28 AM.
 
Old 02-25-2017, 07:04 PM   #13
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
[Now to figure out how to access the stuff if my DNS server happens to go down with out editing the local host file on my systems.[/quote]I use dnsmasq to resolve all internal names, and configure dnsmasq to forward all unmatched requests on to the internet DNS server (google in my case). Everything on my internal lan web server remains working even if the entire internet goes out.
 
Old 02-25-2017, 10:34 PM   #14
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by raksasas View Post
both vhost is pointing to
Code:
/usr/local/www/my_stuff/
That's a very unusual place for Apache to be pointing to for DocumentRoot. Usually the web material is kept under /var/www/something
 
Old 02-26-2017, 07:42 AM   #15
raksasas
Member
 
Registered: Sep 2012
Posts: 55

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Doug G View Post
[Now to figure out how to access the stuff if my DNS server happens to go down with out editing the local host file on my systems.
I use dnsmasq to resolve all internal names, and configure dnsmasq to forward all unmatched requests on to the internet DNS server (google in my case). Everything on my internal lan web server remains working even if the entire internet goes out.[/QUOTE]

I have a local DNS server with forwarders to openDNS.
Locally I have some A records:
mystuff.webserver -> 10.1.1.13
kiddo1.webserver -> 10.1.1.13
kiddo2.webserver -> 10.1.1.13

If it it is unresponsive,crashed,off, etc is there a way to access those locations without having to maintain the host file on all my systems?


Quote:
Originally Posted by Turbocapitalist View Post
That's a very unusual place for Apache to be pointing to for DocumentRoot. Usually the web material is kept under /var/www/something
I thought it was too but it's FreeBSD
 
  


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
LXer: Hosting Multiple SSL Web Sites On One IP With Apache 2.2 & GnuTLS (Debian Lenny) LXer Syndicated Linux News 0 02-04-2011 01:40 PM
Apache (CentOS 5) multiple secure sites deadeyes Linux - Server 3 10-11-2009 07:00 AM
hosting multiple sites w/ apache pH* Linux - Networking 2 10-15-2004 03:02 PM
Multiple Apache Sites, on Multiple IP's, on Same Box?? RickyJ Linux - General 1 06-19-2003 10:55 AM
Multiple Apache Sites, on Multiple IP's, on Same Box?? RickyJ Linux - Software 0 06-19-2003 09:50 AM

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

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