Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running Ubuntu 13.04 64-bit (Ubuntu 12.04.3 LTS) This is fresh install. How do I configure LAMP to run Apache2 on each PC through a four port router. I want one PC to act as the primary server, with the ability to serve its own web content, while having the other PCs available to receive specific domain requests and server pages.

I have the following domain:
⠀ShowMeMn.com
I have the following A Host:
⠀srv1.showmemn.com
⠀srv2.showmemn.com
⠀srv3.showmemn.com

I want each server to respond to calls without a port prefixing the URL.

I am running through the instructions on Virtual Hosts from Ubuntu Documentation ApacheMySQLPHP wiki

Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in /etc/apache2/sites-available. By default, there is one site available called 000-default. This is what you will see when you browse to http://localhost or http://127.0.0.1. You can have many different site configurations available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/. To do this, we must create a new site and then enable it in Apache2.

To create a new site:

  • Copy the default website as a starting point. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.conf
  • Edit the new configuration file in a text editor sudo nano on the command line, for example: sudo nano /etc/apache2/sites-available/mysite.conf. The keyboard shortcuts for saving a file in nano and closing nano are always at the bottom of every page in nano.
  • Change the DocumentRoot to point to the new location. For example, /home/user/public_html/
  • Change the Directory directive, replace "Directory /var/www/" by "Directory /home/user/public_html/"
  • You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites
  • Save the file

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

sudo a2dissite default && sudo a2ensite mysite

Finally, we restart Apache2:

sudo /etc/init.d/apache2 restart

If you have not created /home/user/public_html/, you will receive an warning message

To test the new site, create a file in /home/user/public_html/:

echo '<b>Hello! It is working!</b>' > /home/user/public_html/index.html

Example: srv1.showmemn.com NOT srv1.showmemn.com:8080

I use Godaddy to forward DNS requests from the main IP to the router. All internal requests are then referenced via port forwarding:

Example:
⠀srv1.showmemn.com (port forwards to 10.0.0.2)
⠀srv2.showmemn.com (port forwards to 10.0.0.5)

Any help would be greatly appreciated. In addition I have not altered /etc/host file, I would like to do this the correct way since all my attempts have failed.


In addition, I set up the host file with the following:

127.0.0.1   localhost
127.0.1.1   svr2
10.0.0.2    srv2.showmemn
10.0.0.25   srv1.showmemn.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
share|improve this question
    
This has to be configured in your Router. –  rechengehirn Dec 31 '13 at 12:05
    
How do you mean? I forwarded all requests arriving on port 80 to 10.0.0.2 You lost me. –  ShowMeMn Dec 31 '13 at 12:29
    
Can anyone help me. I am running through the instructions on help.ubuntu.com/community/ApacheMySQLPHP. –  ShowMeMn Dec 31 '13 at 12:32
    
In addition I went to the following link wiki.apache.org/httpd/CommonMisconfigurations to make sure I did not change anything that shouldn't be. –  ShowMeMn Dec 31 '13 at 12:43
    
How are you doing URL-based port-forwarding on your router? That's typically the realm of a DNS server.. –  douggro Dec 31 '13 at 16:03
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.