Running multiple sites on Ubuntu + Apache2

 

Before I forget how to do this again… And because the info on the web is so confusing, mixing hundreds of different ways to do it. I try to use the latest Ubuntu methods not the traditional linux ones.

I want to share with y’all how I made it work. My server currently has 2 wordpress sites, 2 joomla sites and a phpmyadmin site.

badminton.hopto.org  joo
doctorj.hopto.org  wp
vitrail.hopto.org  wp
doctorj.hopto.org/phpmyadmin  Virtual Folder
spider.zapto.org                    joo

It’s finally all neat and tidy. I prefer this to using WordPress (multisite) function. Each site has separate mysql databases and permissions.

First, assure all domains are grouped by your DNS provider and all updated to a new ip if you’re using a dynamic WAN IP. I use no-ip and instructions are here to update the IP automatically: http://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client-on-ubuntu/

Also consider your router must redirect your port 80 (and ssl 443) to your ubuntu server.

Then understand that apache will receive the http and direct it using .htaccess and “sites-enabled” configurations. Sites enabled have a symbolic link to sites-available and I modified this

sudo nano /etc/apache2/sites-available/default

Also consider “default-ssl” in the same directory for processing ssl. I’m not there yet though.

In the config, each site has their html and php root in their respective /usr/share folders (which have www-data ownership and group access 755 – that’s another story).

<VirtualHost *:80>
ServerAdmin xxxx@gmail.com
ServerName pannawit.ddns.net
ServerAlias pannawit.ddns.net
DocumentRoot /usr/share/joomla
</VirtualHost>
<VirtualHost *:80>
ServerAdmin xxxx@gmail.com
ServerName badminton.hopto.org
ServerAlias badminton.hopto.org
DocumentRoot /usr/share/badminton
</VirtualHost>
<VirtualHost *:80>
ServerAdmin captainloknar@gmail.com
ServerName doctorj.hopto.org
DocumentRoot /usr/share/wordpress

<etc…>

it may be necessary to specify other things relative to script alias and security measures but I’m done for now.

Leave a Reply

Your email address will not be published. Required fields are marked *