July 05, 2008 | 04:18 PM  
Welcome

Don't have an account yet? You can create one, it is free, just click here

as a registered user you have some advantages like free downloads, comments and posting on our forums, depending upon this site's configuration and options.

 • •  Control Panel - Register - Login  • • 
Current Stable MDPro Lite 1.0821 Download
Docs Index - MultiSites Tutorial - MultiSites Tutorial
   11-Nov-2005  Print current page  Show map

MultiSites Tutorial

MultiSites Tutorial for MD-Pro 1.0.74+

Integrating XAMPP, MD-Pro and Multisite Module.

by Robert Bruhn Myriad Web Hosting

Assumptions in this tutorial:

  1. Tutorial is based on Windows XP using XAMPP, and MD-Pro 1.0.74.
  2. XAMPP is installed using the default destination (C:\apachefriends).
  3. You are able to install XAMPP and get it functioning on your computer. Download the program from: Apachefriends
  4. You are familiar with phpMyAdmin or some other method of adding databases to MySQL.
  5. Install of MD-Pro uses the default prefix for tables.
  6. Tutorial is for creating multisites using a single installation of MD-Pro. It will provide examples using 2 parked domains, 2 sub-domains, and 1 main site.
  7. The sites used in this tutorial are fictitious. The main site will be called 'mysite.com'. Parked domains will be called 'parkeddomain1.com', 'parkeddomain2.com'. Sub-domains will be called 'subdomain1.mysite.com', 'subdomain2.mysite.com'. Your sites will obviously be different and you should change things where necessary.
  8. You understand how to create parked domains or sub-domains on your remote server. In this tutorial, I use C-Panel.

    ** If you are on a shared webhost where creating subdomains adds a folder in your root public folder, and the webhost maps the subdomain to that subdomain folder, the following tutorial will not work for you. You MUST EITHER have a reseller account where you can Park the subdomains using WebHostManager(WHM), OR root access to the apache server. You might also try contacting your webhost and asking if they can point all subdomains to your public root folder using wildcard DNS (*.mysite.com). This tutorial explains the process using the WHM as a reseller. If you have root access to the apache server, you will have to find out how to make the subdomains work from another source.

  9. The way I created the Virtual Hosts containers and edited the HOST file for Windows XP worked for me. Yours may be different.

Preparing your computer and files

  1. Create a folder for your website. For instance, I created a folder called 'My Webs' in 'My Documents' that contains the folders for every website I work with. For example: 'C:\Documents and Settings\My Name\My Documents\My Webs\mysite'.
  2. Create the public folder appropriate for your remote server type (i.e. public_html, htdocs, docs) in the 'mysite' folder: '\My Websites\mysite\public_html'.
  3. Copy the MD-Pro files into your public folder.

Local Server Setup

  1. Install XAMPP and start the XAMPP program to run the local server. If it does not work, please refer to the Apachefriends docs for assistance.
  2. When you have XAMPP running, open your browser and type: http://localhost in the URL window. Click the link for your language, then click phpmyadmin on the left, and add a database. In this example, I will name the database 'mysite_mdpro'.


  3. The default username/password for XAMPP MySQL server is 'root'/'' (password empty). To make things easier in working with your remote site, you should create a database/username/password combination for the locally managed websites that corresponds to the configuration used on your remote server. For example, when adding a database on a remote server using C-Panel, I have to add a username/password for that database. The username is typically prefixed like: mysite_username. Therefore, I create the same configuration on my local server. The same is done for the database name. If you wish to do the same, follow the directions below. Otherwise, you will need to change each of the configuration files for your sites in MD-Pro and remember not to overwrite them when uploading/downloading files.
    1. In the XAMPP window, click 'phpmyadmin' if you do not already have that window open.
    2. On the left menu, click the little house (home) icon.
    3. In the main window, click the 'Privileges' link.
    4. In the main window, click the 'Add a new User' link.
    5. Enter the username/localhost/password relevant to your site as seen below. Check the appropriate boxes as seen below. Click 'Go'.
    6. After clicking 'Go', you should see the user was added successfully. If not, then I suggest reading up on MySQL and phpmyadmin docs.
    7. Write down the username/password because you will need them when installing MD-Pro.
    8. In phpmyadmin, create a database using the same naming convention your remote server uses. For example: mysite_databasename.
  4. In order to run and install MD-Pro on your local server, you must change the following files. While you have these files open, you will add the information needed for your multisite domains.
    1. C:\apachefriends\xampp\apache\conf\httpd.conf
      1. Open httpd.conf in a text editor.
      2. Scroll to the bottom and you will see the following.
      3. #
        #Use name-based virtual hosting.
        #
        #NameVirtualHost *
        #
        # VirtualHost example:
        # Almost any Apache directive may go into a VirtualHost container.
        # The first VirtualHost section is used for requests without a known
        # server name.
        #
        #<VirtualHost *>
        # ServerAdmin webmaster@dummy-host.example.com
        # DocumentRoot /www/docs/dummy-host.example.com
        # ServerName dummy-host.example.com
        # ErrorLog logs/dummy-host.example.com-error_log
        # CustomLog logs/dummy-host.example.com-access_log common
        #</VirtualHost>

        # Win32DisableAcceptEx ON
      4. Add the Virtual Host Containers at the bottom of the httpd.conf file, substituting the correct path and site names for your situation. I use the extension .loc so I know I'm working with the local site in my browser rather than the remote site. You can use a different extension or none at all. DO NOT FORGET TO UNCOMMENT (#) AND EDIT #NameVirtualHost *
      5. #
        #Use name-based virtual hosting.
        #
        NameVirtualHost *:80
        #
        # VirtualHost example:
        # Almost any Apache directive may go into a VirtualHost container.
        # The first VirtualHost section is used for requests without a known
        # server name.
        #
        #<VirtualHost *>
        # ServerAdmin webmaster@dummy-host.example.com
        # DocumentRoot /www/docs/dummy-host.example.com
        # ServerName dummy-host.example.com
        # ErrorLog logs/dummy-host.example.com-error_log
        # CustomLog logs/dummy-host.example.com-access_log common
        #</VirtualHost>

        <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot "C:/apachefriends/xampp/htdocs"
        ServerName localhost
        </VirtualHost>

        <VirtualHost *:80>
        ServerAdmin webmaster@mysite.loc
        DocumentRoot "C:/Documents and Settings/My Name/My Documents/My Webs/mysite/public_html"
        ServerName mysite.loc
        ServerAlias mysite.loc *.mysite.loc
        </VirtualHost>
        # I use the ServerAlias above so subdomains work correctly

        <VirtualHost *:80>
        ServerAdmin webmaster@parkeddomain1.loc
        DocumentRoot "C:/Documents and Settings/My Name/My Documents/My Webs/mysite/public_html"
        ServerName parkeddomain1.loc
        </VirtualHost>

        <VirtualHost *:80>
        ServerAdmin webmaster@parkeddomain2.loc
        DocumentRoot "C:/Documents and Settings/My Name/My Documents/My Webs/mysite/public_html"
        ServerName parkeddomain2.loc
        </VirtualHost>

        # Win32DisableAcceptEx ON
      6. Save the file and close.
    2. C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
      1. Open HOSTS using a text editor.
      2. # Copyright (c) 1993-1999 Microsoft Corp.
        #
        # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
        #
        # This file contains the mappings of IP addresses to host names. Each
        # entry should be kept on an individual line. The IP address should
        # be placed in the first column followed by the corresponding host name.
        # The IP address and the host name should be separated by at least one
        # space.
        #
        # Additionally, comments (such as these) may be inserted on individual
        # lines or following the machine name denoted by a '#' symbol.
        #
        # For example:
        #
        # 102.54.94.97 rhino.acme.com # source server
        # 38.25.63.10 x.acme.com # x client host

        127.0.0.1 localhost
      3. Add the ip and site names at the end of the HOSTS file after "127.0.0.1 localhost". You MUST have a space between the IP and Site name. You might get a warning about the file being changed, click No when the warning appears. Again, I use the extension .loc to distinguish between local and remote sites.
      4. # Copyright (c) 1993-1999 Microsoft Corp.
        #
        # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
        #
        # This file contains the mappings of IP addresses to host names. Each
        # entry should be kept on an individual line. The IP address should
        # be placed in the first column followed by the corresponding host name.
        # The IP address and the host name should be separated by at least one
        # space.
        #
        # Additionally, comments (such as these) may be inserted on individual
        # lines or following the machine name denoted by a '#' symbol.
        #
        # For example:
        #
        # 102.54.94.97 rhino.acme.com # source server
        # 38.25.63.10 x.acme.com # x client host

        127.0.0.1 localhost
        127.0.0.1 mysite.loc
        127.0.0.1 parkeddomain1.loc
        127.0.0.1 parkeddomain2.loc
        127.0.0.1 subdomain1.mysite.loc
        127.0.0.1 subdomain2.mysite.loc
    3. You must re-start the XAMPP apache server after saving the above files!!

Installing MD-Pro on local server.

  1. Install MD-Pro on your local server. An example of my install url is: http://mysite.loc/install.php
  2. During MD-Pro install, you will be asked to enter information concerning your database. If you created a username/password in phpmyadmin above, this is where you will enter them.
  3. When setting the Administration information for the MD-Pro, I use the same information I will be using for my remote site. Meaning, use .com instead of .loc if you followed my example above.
  4. Below, "Complete Server Path" on my system = C:/Documents and Settings/My Name/My Documents/My Webs/mysite/public_html
  5. After installing, you can access the site using the correct URL: http://mysite.loc or clicking the link on the final page.
  6. Remove the install files as directed by MD-Pro.

Setting up the Multisite

  1. Log in to your local site using your Admin username/password. XAMPP must be running.
  2. Click the Administration link in the upper right block.
  3. Click Settings in the Admin Menu.
  4. Click the Modules icon.
  5. Click the Regenerate link so the Multisites module appears in the list.
  6. Initialize the Multisite module, then activate it.
  7. We now need to change, move, and create some folders and files to get the Multisite module to work with our sites.
    *** If you want to know why I'm changing some files and doing certain things, Click Here. You need to understand PHP and the inner workings of MD-Pro. Perhaps there is a better way to do what I did. Perhaps others can add to this tutorial, but I'm only going to show what worked for me.
    1. In your website's public folder, create a folder named 'parameters' (\My Webs\mysite\public_html\parameters).
    2. Inside the folder 'parameters', create a folder for your main site as well as any other domains or subdomains you want.
    3. I use the same template for all my sites, so I did not find it necessary to create a 'theme' or 'images' folder inside each multisite folder. However, if you want to use different themes for each site, then you should do this. You can read about what to do, and not to do, by reading the AutoTheme docs concerning mutlisites.
    4. Copy the '/modules/NS-Multisites/installation/whoisit.inc.php' file to the '/parameters/' folder you created above.
    5. Copy the '/config/md-config.php' file to each of your site folders.
      '/parameters/mysite/md-config.php'
      '/parameters/parkeddomain1/md-config.php'
      '/parameters/parkeddomain2/md-config.php'
      '/parameters/subdomain1.mysite/md-config.php'
      '/parameters/subdomain2.mysite/md-config.php'
    6. To remain consistent with file naming, open '/modules/NS-Multisites/installation/config.php' and do the following:
      Find the line:

      { include("parameters/".$serverName."/config.php"); }

      change to:

      { include("parameters/".$serverName."/md-config.php"); }

      Save as 'md-config.php'
    7. Replace the file '/config/md-config.php' with the file you just re-named ('/modules/NS-Multisite/installation/md-config.php').
    8. Copy the file '/public_html/pnTables.php' into each of your site folders:
      '/parameters/mysite/pnTables.php'
      '/parameters/parkeddomain1/pnTables.php'
      '/parameters/parkeddomain2/pnTables.php'
      '/parameters/subdomain1.mysite/pnTables.php'
      '/parameters/subdomain2.mysite/pnTables.php'
    9. Open the file 'md-config.php' in each of the site folders and assign a specific prefix to designate each site. Example:
      '/parameters/mysite/md-config.php' will remain $pnconfig['prefix'] = 'md';
      '/parameters/parkeddomain1/md-config.php' will change to $pnconfig['prefix'] = 'pd1';
      '/parameters/parkeddomain2/md-config.php' will change to $pnconfig['prefix'] = 'pd2';
      '/parameters/subdomain1.mysite/md-config.php' will change to $pnconfig['prefix'] = 'sd1';
      '/parameters/subdomain2.mysite/md-config.php' will change to $pnconfig['prefix'] = 'sd2';
    10. If you wish to keep each site separate and not share tables, then skip the next step. If you want to share certain tables with the main site, such as the Users, then continue.
    11. Open pnTables.php for each site folder (except main site - 'mysite') and do the following, using the prefixes you chose for your sites:
      Find the line

      $prefix = $GLOBALS['pnconfig']['prefix'];

      below this line, type:

      $prefix2 = 'md';

      Go through the pnTables.php file and change $prefix to $prefix2 for those tables you wish to share. Example:

      $users = $prefix . '_users';
      $pntable['users'] = $users;
      $pntable['users_column'] = array

      changes to

      $users = $prefix2 . '_users';
      $pntable['users'] = $users;
      $pntable['users_column'] = array

      **Note - This is an example. If you are actually sharing the users tables, then you need to edit all of the associated users tables. It also might be wise to change the _group_membership prefix so users are assigned to the proper group throughout your multisites.
    12. Open the '/parameters/whoisit.in.php' file and add the following:
      $serverName = str_replace(".loc","",$serverName);

      **Note - if you have sites with different extensions than what you see in the list, add what you need to strip the extension off. I am adding .loc because that is the extension I used for my local server.

      Pay attention to the note in the whoisit.in.php file!!
      /* things could be changed here, SERVER_NAME may be useless in certain configurations. For instance, instead of using SERVER_NAME, you may have to use HTTP_HOST. Also, with subdomains, you may want to suppress the first level of the domain name, and, to continue with my example of "linux.mouzaia", you may rather use "mouzaia". */

      You may need to change:

      // modification mouzaia .71
      global $SERVER_NAME;
      // -------------------
      $serverName = $SERVER_NAME;

      To:
      // modification mouzaia .71
      global $SERVER_NAME;
      global $HTTP_HOST;
      // -------------------
      $serverName = $HTTP_HOST;

    13. I had one remote server where I needed to change this.

    14. Run XAMPP and go to phpmyadmin. Create a SQL Dump of your MD-Pro database and save the file to your computer. Open the sql file and "find and replace" the prefix used with one of your 'site' prefixes. (ie. My tables have a prefix of 'md_' and I replace that with 'pd1_' for the first multisite 'parkeddomain1').
    15. Save the sql file and the run the new sql in phpmyadmin so your multisite tables are created. Delete those tables you don't need due to sharing with the main site tables (ie. Deleting the 'pd1_users' tables). Repeat the last two steps for each of your multisites (except the mainsite - 'mysite').
    16. You should now be able to go to each of your sites on your local server. For example:
      http://mysite.loc
      http://parkeddomain1.loc
      http://parkeddomain2.loc
      http://subdomain1.mysite.loc
      http://subdomain2.mysite.loc

Remote Server Setup

  1. After all that, this should be simple!!
  2. Connect to your remote server via FTP and upload the whole public folder of your site.
  3. Set proper CHMOD on necessary files (see the list in MD-Pro docs).
  4. Create MySQL dump from your local database using phpmyadmin.
  5. Create database on remote server using same database_name/username/password that you used when installing on the local server.
  6. Run the MySQL dump so your database is recreated on the remote server.
  7. Return to your CPanel and click the Parked Domains icon. Add your park domains.
  8. Return to your CPanel and click the Subdomains icon. Add your subdomains
  9. Log in to your Reseller WebHostManager and select the link for Park a Domain
  10. In the list of your sites, select your main site, then add the subdomains so they are parked on your main site. This will allow your subdomains to point to your root public folder.
  11. You do NOT need to park your Parked Domains here.

You should now be able to run your multisites on your remote server. If you are working with a program like Dreamweaver, and have added your site to the site manager, then your files locally and remotely should be updated automatically.
The only thing you have to be careful of is updating your local or remote database tables by dumping the sql.

Why the file changes

This is an example of the process MD-Pro goes through.
When viewing an MD-Pro site, the index.php file is called.
Line 26 of the index file contains the following: include_once 'includes/pnAPI.php';
Line 29 of the index file contains: pnInit();
The function pnInit is located on Line 202 of the pnAPI.php file. Within this function is an include statement on Line 220: include 'config/md-config.php';
This config/md-config.php file is the one that is replaced with NS-Multisite/installation/config.php file you changed and renamed in the step above.
Inside the NS-Multisite/installation/config.php file, there is the php code:
include("parameters/whoisit.inc.php");
if (!(empty($serverName)))
{ include("parameters/".$serverName."/config.php"); }
define("WHERE_IS_PERSO","parameters/".$serverName."/");
In the steps above, you move the original config/md-config.php into each site folder and change the above code from --"parameters/".$serverName."/config.php"-- to --"parameters/".$serverName."/md-config.php"--.
Furthermore, the proper pnTables are included in the same pnInit() function within pnAPI:
if (file_exists(WHERE_IS_PERSO . 'pntables.php')) include WHERE_IS_PERSO . 'pntables.php';
WHERE_IS_PERSO is defined in the code above.
So, in processing...
A person comes to your site, the index.php page is called initiating the function in pnAPI. The pnAPI function includes the config/md-config.php file. Replacing the original md-config.php with the newly re-named Multisite config.php (now md-config.php) file directs the process to include the whoisit.inc.php file you copied into the parameters folder. The server name is determined, and the proper md-config.php file is included. Thus, allowing it all to work.  
Docs Index - MultiSites Tutorial - MultiSites Tutorial