Useful Resources for sNusers

Print This Page
Installing sNews:  Main  Install 1.4  Install 1.6 or 1.5  
Server Installation:  Install XAMPP-XP  
Databases:  For sNews  SQL Files  Multiple Installations  
Multiple sNews Installations

 

Multiple sNews Installations

Preparing for Multiple Installations

You have one installation of sNews running on your host's server (online). You would like to install more sNews sites there but you aren't sure how to do it. Before doing this, we need to organize our directory structure so that each installation will run independently of the other(s).

Directory Structure

Normally, when we install sNews on a server, we upload all of its files (and folders) into the domain's root directory. On the host server, this root directory is usually named public_html. When we install more than one sNews site on the domain, each must be located within its own site-specific directory within the domain root directory. For this tutorial, we will deal with three installations:

Site 1 - snews1
    Directory location: public_html/snews1
    URL path: http://www.your-domain.com/snews1

Site 2 - snews2
    Directory location: public_html/snews2
    URL path: http://www.your-domain.com/snews2

Site 3 - snews3
    Directory location: public_html/snews3
    URL path: http://www.your-domain.com/snews3

 

.htaccess file configuration

Since each site is located in its own directory, we'll need to configure the .htaccess file in each so that it functions within its directory. We do this by adding a new line in the .htaccess file under the RewriteEngine On line for each site installation:

In snews1/.htaccess:
    RewriteEngine On
    RewriteBase /snews1

In snews2/.htaccess:
    RewriteEngine On
    RewriteBase /snews2

In snews3/.htaccess:
    RewriteEngine On
    RewriteBase /snews3

 

snews.php configuration

The configuration settings for sNews are located near the top of the snews.php file under the Database Variables. Only two of these variables must change in each site's snews.php file. All of the others will remain the same in all three since we'll be creating the table-sets for all three in the same database. The $db['website'] variable must point to the site's root directory, and the $db['prefix'] variable must point to the tables within the database... in this case, each table-set will have a prefix added to the table-names (we'll create the tables later). So, our settings in each snews.php file will look like this:

In snews1/snews.php:
    $db['website'] = 'http://your-domain.com/snews1/';
    $db['prefix'] = 'sn1_';

In snews2/snews.php:
    $db['website'] = 'http://your-domain.com/snews2/';
    $db['prefix'] = 'sn2_';

In snews3/snews.php:
    $db['website'] = 'http://your-domain.com/snews3/';
    $db['prefix'] = 'sn3_';

 

Creating the database table-sets

Each of our installations require its own set of database tables. It is not necessary to have a separate database for each installation on the same domain... and your host package may only allow you to create one database. In this tutorial, we will put the table-sets for each installation into the same database. The first step, of course, is to have your empty database created beforehand, so we can use phpMyAdmin to create the tables within it. There are two ways to create the tables for each site in the same database.

Three separate SQL files

Using the tutorial for creating an SQL File, we can create a new, separate file and use it to create the table-sets for each installation. In each file, we must add the table prefix (as assigned in the settings above) to the table names within the file. Adding the prefix gives each set of tables a unique name... so that each install will save and get its data from the right database tables. In this case, we create 3 new SQL files, one for each set of tables, and save them as snews1.sql, snews2.sql and snews3.sql. Within each file, we change the table-names as follows:

In snews1.sql
    CREATE TABLE sn1_articles (
    CREATE TABLE sn1_categories (
    CREATE TABLE sn1_comments (
    CREATE TABLE sn1_settings (

In snews2.sql:
    CREATE TABLE sn2_articles (
    CREATE TABLE sn2_categories (
    CREATE TABLE sn2_comments (
    CREATE TABLE sn2_settings (

In snews3.sql:
    CREATE TABLE sn3_articles (
    CREATE TABLE sn3_categories (
    CREATE TABLE sn3_comments (
    CREATE TABLE sn3_settings (

 

INSERTS in the settings tables: Insert strings put data into a table during the table creation step. In this case, there are 23 data insert strings under the settings table script, and they insert default settings data to make each site run (they will not run without this data). You must also add the prefix to all instances of settings in these strings, so that the data will be inserted into the right tables (of course). So, you will add the prefixes for the INSERT strings in each file as follows:

In snews1.sql
    INSERT INTO sn1_settings VALUES

In snews2.sql:
    INSERT INTO sn2_settings VALUES

In snews3.sql:
    INSERT INTO sn3_settings VALUES

 

One consolidated SQL file

One of the advantages in using SQL files to create database tables (in phpMyAdmin) is that we can put all of the table creation scripts in the same file. If we are creating all of the table-sets at once, it is simply a matter of putting all scripts for each set of tables under each other in one SQL file. When we use the Import tab in phpMyAdmin to import the file, all of the tables will be created at once. So, using the same step for creating separate files, we can combine the contents of all files in one SQL file. For details on using phpMyAdmin to create database tables, refer to the tutorial for creating a database For sNews.