Those of you who customize your website on localhost then want to publish it on the internet for everyone to access but don’t know how. Don’t worry, this lesson An guides you to put your website on hosting from localhost xampp!
Table of Contents
Instructions to put your website on hosting from localhost in 5 steps
An use localhost xampp so An will guide you on xampp’s interface!. If you use another localhost emulator, it’s hard to find the different locations but its function is similar.
Step 1 install wordpress on hosting
The first step you need to do is to install wordpress on your hosting to get the directory structure and database connection.
Then you will upload the wordpress source to that directory structure and change the database connection account.
If you do not know how to install wordpress on hosting, please review this lesson of An and then come back to this lesson.
See more: Instructions to install wordpress on hosting using cpanel
Step 2 compress the source and export the database file from localhost
# Compress wordpress source into a zip file
You access the place containing the wordpress source according to the structure “C:\xampp\htdocs\vuducan.vn“. You should note that the “vuducan.vn” is your website directory.
In this folder you select all the files and then right-click and select the line “Add to archive…“.
In this table, you click “zip‘ and then press the ‘ buttonok” Please.
After the compression is complete, your file will be in the same source folder.
#Export database file
Now to the export database file.
You open xampp and then press the “admin“at the” sectionMySQL“.
You select the database section connected to your website.
You choose the “Export‘ and then press the ‘ buttongo“.
After pressing the button “go” then your database file will be downloaded. You move that file to a folder that you can easily manage.
Now let’s go to step An to guide you to upload these 2 files to hosting.
Step 3 upload wordpress source and database from localhost
In this step 3, An wrote a post guide to restore website to hosting already. You go to read this lesson and then come back here.
Note: You just read to the end of step 2 and then come back to this lesson
Step 4 update database username and password
After you complete the above 3 steps, you check the website and you will have a database connection error message as shown below.
What you need to do now is to change the username and password of the database again.
First you need to access the cpanel admin page on your hosting and find the section “wordpress“.
Here you will choose the correct name of your website and click on the pen-shaped button to view information.
Here you will see user and password information. You click the “show” to see the password. You copy this information out to update to the wordpress source.
Now go back to the folder containing the website source in “file manager“. Find the file “wp-config.php” and press “edit“.
Click here “edit” always.
Now you update the copied database information into the following 3 parts:
DB_NAME: database name.
DB_USER: database username.
DB_PASSWORD: database password
Now go back to the top and add the following 2 pieces of code and then press the button “save changes“.
define(‘WP_HOME’,’https://avtcosmetics.com/’);
define(‘WP_SITEURL’,’https://avtcosmetics.com/’);
Remember to replace your domain name correctly. here An is leaving her domain name
Step 5 replace localhost path and fix 404 . error
#Replace the localhost path
When your wordpress source is customized on xampp localhost, the files in your media library will stick to the default path of localhost.
You need to change that path back to your domain name after uploading the website to your hosting.
Now you login to your wordpress manager and install the plugin called “Better Search Replace“, after installing, remember “activated“Plugin up!.
You go back to the website you built on localhost, log in to the admin page and find the section “vehicle” -> select the “library” and select a media file.
You find the link “URL“of and copy the prefix”localhost/vuducan.vn”
You go back to the website admin page that you just uploaded to the hosting and go to the “tools” -> select the “Better Search Replace“.
You manipulate the cells as follows:
Search for: Enter the old path on your localhost.
Replace with: Enter your new domain name instead.
Select tables: you press the key combination “Ctrl A” to select all.
3 check boxes Case-insensitive, replace GUIDs, Run as dry run: leave them all blank.
Finally, you press the button “Run search/Replace” to start the operation.
#Fix 404 error
You go to the “Setting” -> select the “Static path“.
You tick on “customization” and change it to “%Postname%“.
To finish, press the “save changes” it is done.
Conclude
That’s it, the lesson on how to put your website on hosting from localhost is done. Good luck with your studies and remember to read the next lessons!
Previous Post
Lesson 29: How to restore wordpress manually from backup file
Next post
Lesson 31: Summary and thanks