Creating a Test Site on Ubuntu
There are a number of ways to create a test site.
Steps for a Standard Ubuntu/Apache2 Server
Get the Code to Your Server
- Log into your site using SSH with root or an account with sudo account
cd /var/wwwwget http://ftp.drupal.org/files/projects/cm_starterkit_moderate-7.x-1.12-core.tar.gz(use the link to most recent version of the kit http://drupal.org/project/cm_starterkit_moderate)tar -xvf cm_starterkit_moderate-7.x-1.12-core.tar.gzmv cm_starterkit_moderate-7.x-1.12 [youdecide].[yourdomain].org
Create a Database
- $ mysql -u ''adminusername'' -p
- mysql> CREATE DATABASE ''databasename'';
- mysql> GRANT ALL PRIVILEGES ON ''databasename''.* TO "''username''"@"''localhost''" IDENTIFIED BY "''password''";
- mysql> FLUSH PRIVILEGES;
- mysql> EXIT
Tell Apache Where to Send Requests for [youdecide].[yourdomain].org with a VHost
cd /etc/apache2/sites-availablesudo nano [youdecide].[yourdomain].org-
<VirtualHost *:80> ServerName [youdecide].[yourdomain].org ServerAdmin webmaster@localhost DocumentRoot /var/www/[youdecide].[yourdomain].org AccessFileName .htaccess <Directory /var/www/[youdecide].[yourdomain].org> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> - Save the file using ctrl-X
- Tell Apache2 to enable the new site using the new VHost file
sudo a2ensite [youdecide].[yourdomain].org - The server should tell you
Run '/etc/init.d/apache2 reload' to activate new configuration! sudo service apache2 restart(service is easier to remember than init.d)
The last step requires you add a ANAME or CNAME record to your DNS provider. These steps vary based on where your domain is registered.
Steps to Clone or Copy a Live site to a Dev site in Ubuntu/Apache/MySQL
Go to the settings for the live site and make note of which databases are being used
/var/www/sitelive/sites/default/settings.php
If you are using CiviCRM you would need to take note of both the current live CiviCRM and Drupal databases
sitelive_drupal1
sitelive_civicrm1
In phpMyAdmin or your preferred method create two new dev databases
If you have sitedev_drupal1 then create sitedev_drupal2
If you have sitedev_civicrm1 then create sitedev_civicrm2
Backup your live databases
mysqldump -u username -p sitelive_drupal1 > sitelive_drupal1_yyyymmdd.sql
mysqldump -u username -p sitelive_civicrm1 > sitelive_civicrm1_yyyymmdd.sql
Then upload the data from the backed up live databases to the new dev databases
mysql -u username -p sitedev_drupal2 < sitelive_drupal1_yyyymmdd.sql
mysql -u username -p sitedev_civicrm2 < sitelive_civicrm1_yyyymmdd.sql
Once the new dev databases are created and populated with data, then copy the live directory to a new dev directory
Let's assume your directories are called sitelive and sitedev
Make a copy of sitelive directory
sudo cp -R -p sitelive sitelive_copy
Backup sitedev directory
sudo mv sitedev sitedev_backup
Create a new sitedev directory by changing the name of the sitelive
sudo mv sitelive_copy sited
Once the new databases are created and the a new sitedev directory is created, then change drupal and civicrm settings in settings.php and civicrm.settings.php
/var/www/sitedev/sites/default/
All the references to databases in the settings.php and civicrm.settings.php will need to point to the new dev databases.
Now you should be able to load http://sitedev.org
If you are using CiviCRM, then go to CivicRM > Administer > System Settings > CMS Database Integration
Copy the CiviCRM settings to the settings.php file in the sitedev directory
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion