As explained on a post I wrote a couple of months ago, you can install and design a WordPress blog or website without a hosting account. This can be done through localhost and you can complete everything right on your computer using WampServer. You can post articles, install themes and plugins and do everything you would normally do with a WordPress blog… the only thing is that only you can access it on your computer. Now, if you’ve already created the WordPress blog on your computer, how then do you transfer it from localhost to the internet without losing the design, installed plugins, posts and everything? This post explains that in clear details.
There are four main things you need to do to accomplish this:
1. Upload the files from localhost to cPanel file manager
2. Import the database from local PhpMyAdmin to the one on your cPanel
3. Editing wp-config.php file
4. Changing the site’s URL from PhpMyAdmin
1. Uploading the files to cPanel
- You should go to the location you installed WordPress to on your computer. If you used WampServer and followed the guide I previously wrote, this should be in C:\wamp\www\wordpress
- Compress all the files located here to a zip file.
- Log in to cPanel, then go to file manager and upload the zip archive to public_html
- Extract the files to this location.
Now you’re done with the first step, let’s proceed.
2. Importing the database
All your settings, posts, created pages and the most important data that makes your WordPress blog function properly is in the database and you must export this from localhost and import it to your cPanel.
- Launch WampServer and go to http://localhost
- Select phpMyAdmin
- Click on your WordPress database on the left
- Now select Export and click Go
- You should see a download dialogue. Save the .sql file.
- Now log in to cPanel and go to phpMyAdmin
- Click on Databases and create a new database. Name it whatever you like but be sure it’s something you can remember.
- After creating the databases, select it from the left and click the Import tab. Locate and upload the.sql file you downloaded earlier, remember?
- Now you’ve successfully imported the database, lets move on to the next step.
3. Editing wp-config.php file
This file is what connects your wordpress blog to the database and it needs to be edited.
- Go to cPanel file manager and the directory in which you installed WordPress. Locate wp-config.php and open it using cPanel editor.
- Scroll down a bit till you see something that looks like this:
define(‘DB_NAME’, ‘wordpress‘);/** MySQL database username */
define(‘DB_USER’, ‘root‘);/** MySQL database password */
define(‘DB_PASSWORD’, ‘password‘);/** MySQL hostname */
As you can see, you’re only changing the words in red.
wordpress = The nameof the database you created on your cPanel. Normally, you should write it here in this format: username_databasename. Username is your MySQL username which is the same thing as your cPanel username in most cases. For example, doncaprio_wordpress2.
root = your MySQL username. In most cases, this is he same as your cPanel username but if it’s different, you should contact your host.
password = your MySQL password. Again, this is often the same as your cPanel password. Contact your web host if it’s different.
4. Changing the site’s URL from phpMyAdmin
- Go to phpMyAdmin on cPanel, select your database, then click wp_options table
- Locate the option name labelled site_url
- Edit this line and replace http://localhost/wordpress with your real domain name. Ex. http://www.doncaprio.com
- Now click on GO to save your changes.
- Check http://your-domain.com/wp-admin. Normally, this should display the admin login page.
- If there’s an error message about database connection, you should go back to Step 3. Your MySQl database name, username and / or password is wrong and you must contact your host if this happens.
- Log in with the username and password you used to log in on localhost.
- Go to Settings > General. Update your URL if you stilll have http://localhost/wordpress there.
That’s all! You may now check your blog to see it appear just the way it appeared on WampServer, including all the posts and everything. Still having issues with it? Drop your comment maybe I can be of help.