Once the full website is all done, the next step is to migrate the site from localhost to the web server.
First step is to back up database and all files just in case something goes wrong.
Turn on XAMPP and go to phpMyAdmin –
Log in to the server and create a new file where all files will be stored –
Once the folder is created, open the folder and click on ‘Upload’. There is only one file possible to select therefore, go to the actual folder and zip all files (not full folder just files!). This is because if full folder was zipped, ending of the URL address would be ‘wp_client_wp’ and this is not correct. So if only files are zipped, ending of the URL address will be ‘wp_client’ as it is required.
Once the files are zipped, upload it to the server –
Click ‘Go Back’ and there is the zip file –
Once the file is extracted, delete the zip file to avoid hacking into the site –
Next step is to create database on the server in phpMyAdmin –
Log in to My cPanel and click on ‘MySQL Databases’
Step 1 – Setting up a database
After clicking on ‘MySQL Databases’ option, this window will appear –
Choose name of database and click ‘Create Database’. Confirmation window will appear saying that database was created –
Click ‘Back’ and the main screen will appear.
Once database is created, username and password needs to be created for database.
Always use ‘Password Generator’ for safeness, it is hard to hack! Make sure that generated password is copied and saved somewhere safe.
After creating username and password for the database, user needs to be added to the database.
After clicking ‘add’, the window with privileges will appear (what user can and cannot do in database). By clicking them all, user has full control of database.
Final stage screen looks like this –
Once the database is created, go back to ‘File Manager’, find ‘wp-config.php file’ and click ‘Code Editor’ –
Add password, username and database name for the new created database and save changes –
Then go to phpMyAdmin in localhost and export database again but with different settings. Click on ‘Custom export method’ –
Scroll down and tick ‘View output as text’, then click ‘Go’ –
This option will output the full database in text so select it all and copy –
Then go to phpMyAdmin on the server and find new database that just been created. Click on the title and then ‘SQL’. Paste all the text in there and click ‘Go’ –
This way, the full database from localhost just has been imported to the database on the server. Click on ‘Structure’ and check if all tables and content are there –
What is needed to do now is to change and update WordPress URLs in new database as at the moment, all URL are set up to localhost which is not needed anymore. This is an example of the code that is needed to rewite URLs –
(Source: http://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/)
Copy and paste the code into text editor and change URLs. Where it says‘http://www.oldurl’ – replace that with ‘http://localhost/WP’ and where it says‘http://www.newurl’ – replace is with ‘http://www.veronikalesnakova.co.uk/wp_client’ –
Once the URLs are all changed, copy the code and paste it into ‘SQL’ and click ‘Go’ –
Now it is all done and migrated.
Type the URL of the website into the browser and see the result –
There is and error that means that sections of the site are not loading in right order therefore, this line of code needs to be added into ‘functions.php’ –
(Source: http://php.net/manual/en/function.ob-start.php)
Open ‘functions.php’ file on the server and add ‘ob_start();’ at the top of the code –
This way all sections of the website i.e. header, footer etc. will load in right order.
NOTE: This is not the right way of adding code into the file! It should be never done on the server but in files and then uploaded to the server. However, for saving time, this time the code was changed on the server.
Refresh the website and it is all done and working!
However, after clicking on the navigation, another pages are not visible and it says that the files are not there. To fix that, go to the Admin section of the website > Settings > Permalinks > Save Changes.
All pages are now loaded and saved and the full website is functioning perfectly fine.