Home arrow Site Administration arrow Page 2 - Upload and Deploy Drupal from Ubuntu XAMPP to Hosting Server using SSH

Import Drupal Database from XAMPP to a Hosting Server - Administration

This is an important tutorial on how to upload and deploy your Drupal website from Ubuntu XAMPP to a remote hosting server. In this way, you can deploy your website to the Internet and make it viewable by everyone.

  1. Upload and Deploy Drupal from Ubuntu XAMPP to Hosting Server using SSH
  2. Import Drupal Database from XAMPP to a Hosting Server
By: Codex-M
Rating: starstarstarstarstar / 4
December 20, 2010

print this article



To import a Drupal database from your XAMPP, go through the following steps.

Step 1. Create a MySQL database first in your remote server. This will be used for your Drupal website. You can go to your hosting control panel and create the database. For details, you need to refer to your hosting support for creating MySQL databases. Take note of the following MySQL login credentials created:

  • Username
  • Password
  • Database name
  • Hostname

Step 2. Using a Linux terminal, navigate to your Ubuntu XAMPP bin folder.

codex-m@codex-m-desktop:/$ cd /
codex-m@codex-m-desktop:/$ cd opt
codex-m@codex-m-desktop:/opt$ cd lampp
codex-m@codex-m-desktop:/opt/lampp$ cd bin

Step 3. Execute the MySQL dump command to copy the Drupal database from your XAMPP to your remote hosting MySQL database server (do not forget the "." dot sign before the forward slash):


Note: The credentials: Drupal_database_username, Drupal_database_password, Drupal_database_hostname and Drupal_database_name_in_remote_server are the MySQL login credentials for your Drupal website in the remote server, which you created in the first step.

If you want to see a screen shot of the command prompt, go here: http://www.php-developer.org/screenshot/mysqldumptoremotehostingserver.jpg

Important: Do not close the terminal while the copying is going on; wait until it is completed.

Copy All Drupal Files in Your XAMPP to a Remote Server

Execute the SCP (secure copy command using Terminal/SSH) command that will copy all files (including folders and hidden files such as .htaccess) from your Drupal XAMPP localhost folder to your Drupal website hosting root directory.

codex-m@codex-m-desktop:~$ scp -r /opt/lampp/htdocs/drupal/. your_ssh_username@sshhostname.com:/home/www/codexdrupal.php-developer.org/

If you would like to see this in a command prompt screenshot: http://www.php-developer.org/screenshot/scpcommandrupaltoremote.jpg


  1. Do NOT forget to place a "." dot sign after /drupal/ as this will make it possible to copy all hidden files, such as .htaccess.
  2. /home/www/codexdrupal.php-developer.org/ is the full server path to your root directory, as determined already in the previous sections (using fullserverpath.php script).
  3. You are required to enter your SSH password to proceed with the file uploading.
  4. The path to your local Drupal installation in XAMPP is: /opt/lampp/htdocs/drupal/ 

    The drupal folder name can change depending on what you are using.
  5. The uploading process can take a very long time. Do not close the terminal while the copying is going on; wait until it is done.

Configure Settings.php for database, base URL and .htaccess

To make your website work in the new hosting server, you need to make some adjustments in settings.php, base URL and the .htaccess. Follow the steps below:

1. Log in to your SSH server:

codex-m@codex-m-desktop:~$ ssh yourusername@your_ssh_hostname.com

2. Go to your Drupal website root directory:

-bash-2.08b$ cd www
-bash-2.08b$ cd codexdrupal.php-developer.org

3. Go to the sites directory and then to the default directory:

-bash-2.08b$ cd sites
-bash-2.08b$ cd default

4. Change the file permission of settings.php to 644.

-bash-2.08b$ chmod 644 settings.php

5. Edit settings.php
-bash-2.08b$ pico settings.php

6. Define the MySQL connection string of your remote Drupal website. Look for the $db_url variable and assign updated/correct values:

$db_url = 'mysqli://mysqluser_name:mysql_password@coolest@codexserver.com/mysqldatabase_name';

See the screen shot here:

In the screen shot the MySQL username is codex_m, the MySQL password is cutegirls999, the MySQL hostname is coolest@codexserver.com and the name of the MySQL database is drupaldatabase.

7. Define the base URL. Find the $base_url variable. It should be set to your Drupal home page URL (depending on whether you are using a sub-domain or main domain).

$base_url = 'http://codexdrupal.php-developer.org';  // NO trailing slash!

In the above base URL, the home page of the Drupal website in the remote hosting server is http://codexdrupal.php-developer.org/.

8. Save the changes in settings.php by pressing Control- O and then press the Enter key. Exit the editor by pressing Control-X.

You might notice that at this time, when you view your website in the browser, the home page is working, but other pages in the website return "Internal Server Error."

This is because you need to make some adjustments in your .htaccess. To edit:

1. Go to your root directory using the SSH command line. You might need to type cd ..

-bash-2.08b$ cd ..

to go back to the root directory. You will know when you are in the root directory when you type:

-bash-2.08b$ pwd

Then it will return, for example:


2. Edit .htaccess:

-bash-2.08b$ pico .htaccess

Simply change:

# RewriteBase /


RewriteBase /

You will just remove the # before RewriteBase. Save the changes (Control-O - Enter key, then Press Control X to exit).

Finishing Touches for Drupal Deployment to Your Hosting Server

You can also do the following to complete your Drupal deployment:

1. Secure your Cron.php, and add the following lines in your .htaccess:

<Files "cron.php">
  Order allow,deny
  Allow from 123.456.789.123

Change the IP address 123.456.789.123 to use your own IP address. You can get your IP address here: http://www.whatismyip.com/

The above .htaccess lines will prevent public access to your cron.

2. Enable cron in your hosting account to automatically run cron.php. For some hosting accounts, you may have problems executing your cron, so you might change the file permission of cron.php to 755.

A sample configuration in Agilityhoster.com that will run the cron.php once a day can be found here: http://www.php-developer.org/screenshot/cronsetupdrupal.jpg. This method might not be the same for other hosting companies. In this case, you need to consult with your hosting support.

After completing all of these steps, try to browse to your website and log in as administrator. You can change your password if you like. Make sure everything is working properly, as it was on the XAMPP local host.

>>> More Site Administration Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: