Home >How to store multiple Magento website with Apache2

How to store multiple Magento website with Apache2

As a Magento Solution Partner, BSS has a lot of website development projects. We have to store multiple dev site/live site on the same dedicated server. Today I’ll show you how to setup 2 different domains, for example bsscommerce.com and bsscommerce.net in one server.

Assume that we have Apache2 server, IP address is 192.168.1.1, of course we have root ssh access too.

Step 1: Create the directories to contain site’s content

With Ubuntu 14 and apache 2.4, the path of root document is /var/www/html. You can create 2 root documents for 2 sites with paths: /var/www/bsscommerce.com and /var/www/bsscommerce.net. You also can create other path for root document but I recommend you should create path as me to facilitate the management.

Create the following directories for bsscommerce.com

mkdir /var/www/bsscommerce.com/public_html
mkdir /var/www/bsscommerce.com/cgi-bin
mkdir /var/www/bsscommerce.com/logs

Create the following directories for bsscommerce.net

mkdir /var/www/bsscommerce.net/public_html
mkdir /var/www/bsscommerce.net/cgi-bin
mkdir /var/www/bsscommerce.net/logs

Step 2: Create 2 config files

Create config file for bsscommerce.com

Using command:

pico /etc/apache2/sites-available/bsscommerce.com.conf

Insert this content to file and save:
#
#  bsscommerce.com (/etc/apache2/sites-available/bsscommerce.com)
#
<VirtualHost *:80>
        ServerAdmin webmaster@bsscommerce.com
        ServerName  www.bsscommerce.com
        ServerAlias bsscommerce.com

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/bsscommerce.com/public_html

        # CGI Directory
        ScriptAlias /cgi-bin/ /var/www/bsscommerce.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /var/www/bsscommerce.com/logs/error.log
       CustomLog /var/www/bsscommerce.com//logs/access.log combined
</VirtualHost>
<Directory "/var/www/ bsscommerce.com/public_html">
        AllowOverride  All
</Directory>

Create config file for bsscommerce.net

Using command:

pico /etc/apache2/sites-available/bsscommerce.com.conf

Insert this content to file and save:
#
#  bsscommerce.net (/etc/apache2/sites-available/bsscommerce.net)
#
<VirtualHost *:80>
        ServerAdmin webmaster@bsscommerce.net
        ServerName  www.bsscommerce. net
        ServerAlias bsscommerce. net

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/bsscommerce. net /public_html

        # CGI Directory
        ScriptAlias /cgi-bin/ /var/www/bsscommerce. net /cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /var/www/bsscommerce. net /logs/error.log
       CustomLog /var/www/bsscommerce.net/logs/access.log combined
</VirtualHost>
<Directory "/var/www/ bsscommerce.net/public_html">
        AllowOverride  All
</Directory>

Step 3: Run site

Using command:

a2ensite bsscommerce.com
a2ensite bsscommerce.net

Step 4: Restart apache2

service apache2 restart

Step 5: Point 2 domains

Point 2 domains: bsscommerce.com and bsscommerce.net to ip address 192.168.1.1.

Step 6: Create magento site

Magento files and directories will be contained in the Root document.

Site bsscommerce.com: /var/www/bsscommerce.com/public_html
Site bsscommerce.net: /var/www/bsscommerce.net/public_html

Step 7: Set permission for root document

Site bsscommerce.com.

find /var/www/bsscommerce.com/public_html  -type d –exec chmod 755 {} \;
find /var/www/bsscommerce.com/public_html  -type f –exec chmod 644 {} \;

Site bsscommerce.net.

find /var/www/bsscommerce.net/public_html  -type d –exec chmod 755 {} \;
find /var/www/bsscommerce.net/public_html  -type f –exec chmod 644 {} \;

Only with 7 steps above. I hope you’ll find some use for your problem to store multiple Magento website with Apache2.

< Previous Post
Next Post >
+ posts