Tuesday, December 08, 2009

How to upload a Joomla! website's localhost version to my hosting server

Note: this article assumes that you use XAMPP to test your website offline - see one of my eariler articles about it here. The first suggested installation method of the Absolute Beginners Guide to Joomla! is XAMPP too.

So I donwloaded a Joomla! template, made some CSS modifications to it to look like what the client was asking for (plus added to it what I found fancy) and I wanted to upload the end result onto my hosting server so that the client can take a look at it. The most useful documentation I could find about this was Joomla!'s own article called How do you copy a site from localhost to a remote host?. However it assumes a little bit more knowledge than a beginner would have, therefore I decided to create an article about it and share it with you.

The steps that might not be self-explanatory if you had no experience with databases was 1. how to import a database and 2. how to actually make it work (typical error message: "Database Error: Unable to connect to the database:Could not connect to MySQL").

Answers are as follows:

1 How to import a database? - you first have to create a database on your hosting server and import the tables you exported from the localhost version. This may differ per hosting provider; GoDaddy actually allows you to access the database through phpMyAdmin once the database is created. Would you encounter "access denied" error when trying to import take the following steps:
a. Open the database file (the one you exported) with a text editor on your local PC / MAC.
b. Locate and remove the line saying "CREATE DATABASE [dbname]" and (right below) "USE: [dbname]".
c. Save the file and try to import it again.

2 How to actually make the database work? - there are some very important lines in the configuration.php file that I believe need some explanation:

var $host = 'name of your remote host'; - if you go to your phpMyAdmin main page on your hosting server, you'll find this information right below the server version; the entry is called 'Server'. This can be a longer, website address like name (like something.dbname.com) or even an IP address, both should work.

var $password = 'your_db_password'; - you'll have to provide the password of your database. As it is in plain text, it's not very secure to store it in your public html folder. You may check out the thread configuration.php contains mysql root password in plain text or the Joomla! documentation about How do I move confidential files outside of public_html? for more information or ways to change this.

I know it's not always very clear, so would you have any questions please feel free to ContactMe or comment below (note: comments are moderated); I'm always happy to help!

No comments:

Post a Comment

Dear legitimate commenters, please post your comments below. I'd be happy to receive your feedback; helps me a lot improving, or getting reassurance that I'm doing something really great here.

IMPORTANT! A note to commenters planning on advertising their business in comments: please be informed that I'm NOT going to post your comments but will ALWAYS mark them as SPAM.