Site Administration Page 2 - Upload and Deploy Drupal from Ubuntu XAMPP to Hosting Server using SSH |
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:
Step 2. Using a Linux terminal, navigate to your Ubuntu XAMPP bin folder. codex-m@codex-m-desktop:/$ cd / 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): codex-m@codex-m-desktop:/opt/lampp/bin$ ./mysqldump -uROOT -pXAMPP_MYSQL_ROOT_PASSWORD -hLOCALHOST NAME_OF_YOUR_DRUPAL_DATABASE_IN_XAMPP | ssh YOUR_USERNAME@YOUR_SSH_HOSTNAME.COM mysql -uDRUPAL_DATABASE_USERNAME -pDRUPAL_DATABASE_PASSWORD -hDRUPAL_DATABASE_HOSTNAME DRUPAL_DATABASE_NAME_IN_REMOTE_SERVER 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 Important:
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 3. Go to the sites directory and then to the default directory: -bash-2.08b$ cd sites 4. Change the file permission of settings.php to 644. -bash-2.08b$ chmod 644 settings.php 5. Edit 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: /home/www/codexdrupal.php-developer.org/ 2. Edit .htaccess: -bash-2.08b$ pico .htaccess Simply change: # RewriteBase / to: 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"> 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.
blog comments powered by Disqus |
|
|
|
|
|
|
|