Wordpress recovery howto - renuecomputers :)

coffee

Well-Known Member
Reaction score
1,832
Location
United States
At one point I decided to move my website to a 3rd party webserver. However, Before I could do that my webserver all and out died. Therefore I almost lost everything. However, I did have a back up of my files and also my database. So, I had my files backup and my mysql backup of my wordpress site. My plan is to somehow rebuild my website on a local computer and make sure things work and then migrate it to the new hosting server on the internet.

First Steps:
1. Install linux on a computer.
2. Install Apache2 on linux.
3. You might have to edit your php.ini file and increase the upload size for files. The default is 2megs. However, My backup is 5megs. Be sure to restart apache2.
3. Install phpmyadmin and create a database for wordpress.
4. Restore your file system - In my case /var/www/wordpress - and make sure ownership is correct - once again in my case www-data:www-data (user:group).

sudo chown -R www-data:www-data /var/www/wordpress

5. Using phpmyadmin make sure you select your wordpress database and then perform a import. Select your database-backup.sql file (your database backup) and upload it.

Now, What you will find is that even if you can see your frontpage it will have missing media and such. You will not be able to login or visit other pages. This is because your paths are incorrect. In my case, My paths pointed to www.renuecomputers.com which is my NEW site location. I wanted to install them on my replacement server dino. So, We can fix this pretty darn quick:

Locate your /var/www/wordpress/wp-content/wp-login.php and pull it up in an editor - I use nano.

cd /var/www/wordpress/wp-content

sudo nano wp-login.php


Now do a search (control-w) for this line:

require( dirname(__FILE__) . '/wp-load.php' );

Below that line copy and paste this into the file:

//FIXME: do comment/remove these hack lines. (once the database is updated)
update_option('siteurl', 'http://your.domain.name/the/path' );
update_option('home', 'http://your.domain.name/the/path' );


change the path to where your website is - once again, in my situation I used 'http://dino'

Now, you can login to your site. If you find that you are getting 404 errors then go in and rename your plugins directory to something else like plugins-BAK and try again.

sudo mv plugins plugins-BAK

I found that one of my security plugins was causing this problem. So, After renaming the plugins directory I was able to go and rename my plugin security directory and rename plugins-BAK back to plugins.

Now you can go into your admin area and change the paths for media and menus, ect that you need to change. When you are done, remove the code you inserted into your wp-login.php file and things should run fine.

For more info:
https://codex.wordpress.org/Moving_..._Accidentally_Changed_your_WordPress_Site_URL

I hope this helps others. So far I have my website now running on my temporary webserver and I plan to migrate it to my new location and then update it from there. But this would save you from having to recreate everything from scratch :) . Especially if you have done a lot of editing of your files and css.

coffee


 
Back
Top