Results 1 to 9 of 9

Thread: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

  1. #1
    Join Date
    Oct 2011
    Beans
    17

    Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    I have a SINGLE machine, I have a single IP address. It is running 12.04 server. I have apache running. I want to serve multiple websites from the single machine. I have been searching ALL over and have had little success in having this set up properly.

    All help appreciated, but please don't post and tell me to "Set up virtual hosts".

    Also, if you tell me to change any text inside any files, please specify WHAT files, this seems to be a big problem with this scenario is no one wants to specify. Thanks in advance!

  2. #2
    Join Date
    Mar 2009
    Beans
    1,689

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    You need to set up name-based <you better not say it/>.

    Frankly apache's documentation is extremely good, and nothing I can do is going to make it better. Apache comes pretty much set up for it right out of the box, there's very little modification necessary.

    http://httpd.apache.org/docs/current...ame-based.html

    Better yet, google on apache2 name based virtual host example ubuntu and add your ubuntu version on it, and it will probably give you exactly what files to edit.

  3. #3
    Join Date
    Oct 2011
    Beans
    17

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    Ok, I've done that and followed the instructions to a tee, and it always directs to the main website. I can't get it to load the second website. I don't understand what I could be doing wrong as the multiple examples I've searched, which do it different ways, do not work.

  4. #4
    Join Date
    Oct 2011
    Beans
    17

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    Ok, so I have tried completely removing apache2, with a purge as well. when trying to do things like service restart, start, and stop, it says apache does not exist or whatever. same with running commands to unistall. BUT! When I view services there is apache2 in the list with a + symbol AND my websites are still being hosted. This makes NO sense to me at all... Any help appreciated.

  5. #5
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    If you post a list of domains you want to create, along with the directories they are supposed to serve from, I can generate an example configuration that you can build on.
    Providing that it is a new install that is

    Code:
    sudo apt-get purge apache2*
    apt-get install apache2
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  6. #6
    Join Date
    Jul 2012
    Beans
    9

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    I don't know if you are still having any issues but here is my 2 cents...

    httpd.conf example
    Code:
    Listen *:80
    DocumentRoot "/var/www"
    
    
    <VirtualHost *:80>
    ServerName example.com
    ServerAlias example.com *.example.com
    DocumentRoot "/home/[username]/example.com"
    HostNameLookups double
    </VirtualHost>
    
    
    <VirtualHost *:80>
    ServerName example.net
    ServerAlias example.net *.example.net example.info *.example.info
    DocumentRoot "/home/[username]/example"
    HostNameLookups double
    </VirtualHost>
    
    
    <VirtualHost *:80>
    DocumentRoot "[path]"
    ServerName [url]
    ServerAlias [url] *.[url]
    HostNameLookups double
    </VirtualHost>
    I learned the hard way to lookup the host name twice (otherwise it defaulted back to the main page for me)

    as for restarting apache:

    Code:
    service apache2 stop
    service apache2 start
    or

    Code:
    service apache2 restart
    or

    Code:
    ps aux | grep apache2
    kill -9 [pid]
    service apache2 start
    forgive me if something is wrong this is off the top of my head

    BASICFreak

  7. #7
    Join Date
    Dec 2007
    Beans
    562

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    Your virtual host declarations should go into their own files within the /etc/apache2/sites-available folder. For example, the file /etc/apache2/sites-available/example.com will contain only:
    Code:
    <VirtualHost *:80>
    ServerName example.com
    ServerAlias example.com *.example.com
    DocumentRoot "/home/[username]/example.com"
    HostNameLookups double
    </VirtualHost>
    Then the /etc/apache2/sites-available/example.net file will contain:
    Code:
    <VirtualHost *:80>
    ServerName example.net
    ServerAlias example.net *.example.net example.info *.example.info
    DocumentRoot "/home/[username]/example"
    HostNameLookups double
    </VirtualHost>
    Then you would enable each site using the file names from sites-available:
    Code:
    a2ensite example.com
    a2ensite example.net
    and then restart apache:
    Code:
    service apache2 restart
    That should take care of it. You shouldn't have to touch httpd.conf at all for a basic setup.

  8. #8
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    Quote Originally Posted by newbie-user View Post
    Your virtual host declarations should go into their own files within the /etc/apache2/sites-available folder.
    Technically you can throw them all in httpd.conf, but then it gets super messy.
    I prefer to create a file for each site I am hosting and put it in sites-available - makes it much easier to manage and troubleshoot.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  9. #9
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    12,497
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Apache serving multiple web pages on ONE MACHINE, ONE IP ADDRESS. Help setting up

    Plus a typo in one configuration doesn't block the rest of them from starting up.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •