Making a mirror of a WordPress blog on my own computer

This post was written by eli on January 29, 2017
Posted Under: Internet,Linux,Notes to self,Server admin

This is a note to self on how to create a mirror copy of this blog on my own computer. My own peculiar methods are all over.

  • Create a virtual host on my apache httpd server (port 99)
  • Uncompress the site’s entire public_html directory into the virtual host site’s root directory (that’slazy, I got a lot of unnecessary files this way)
  • Create a git repo, and add the blog/ directory so I have a look on what happens (not really necessary, but I make git repos everywhere)
  • Create a new database, and fill it with an SQL backup of the site:
    $ mysql -D blogmirror < ~/Desktop/blogdb-Mon_17.01.23-05.23.sql
  • Change the database settings in wp_config.php. For a local database, which requires no password, it became (DB_HOST remained “localhost”):
    define('DB_NAME', 'blogmirror');
    /** MySQL database username */
    define('DB_USER', 'eli');
    /** MySQL database password */
    define('DB_PASSWORD', '');
  • Change WordPress’ view of the blog’s root (following this post), or it diverts from the allocated port 99. Add the following two lines to wp_config.php:

    Note that there’s no trailing slash. Adding one makes double slashes on the URLs generated by WordPress.

That’s it. At this point the blog worked. Log in with the same user and password as the real blog.

Automatic upgrade of the mirror

Create a new user, sitemirror, but don’t create the user’s home directory. Instead, edit /etc/passwd to set the home directory at the site’s root directory (not the public_html, but where public_html can be found).

Also, change the ownership of that directory to that user, or the modification through ftp won’t work:

# chown -R sitemirror sitemirror/

And start the ftp service (it doesn’t matter that the WordPress has an SFTP option. It goes for regular port 21 anyhow):

# service vsftpd start

Also, make the path accessible to the sitemirror user (in my case, it meant making the home directory accessible to all. Temporarily!)

Now, on the automatic upgrade page, go for localhost and the username/password of the ad-hoc sitemirror user.

And you get something like this:

Screenshot after upgrading


And now revert the damage made above: Shut down vsftpd (and verify port 21 is closed), fix the ownership of the sitemirror directory, and restore the ownership of the home directory.

Then remove the sitemirror user (but not its home directory, obviously).

This is for upgrading the local mirror blog. On the real blog, it was just clicking on the button for upgrading. No questions asked about FTP or anything like that.

But the irony is that after upgrading (to 4.7.2), I attempted to publish this post, but “Publish” button was inactive, and the editor stuck on “Saving Draft…”. To double the irony, I upgraded just because one has to, as a security measure. All was fine.

Oddly enough, I didn’t have a similar problem with the (upgraded) mirrored blog.

I wrote a separate post on how I worked around this issue.

How I love upgrading. Actually, I love downgrading more.

Reader Comments

nice information

Written By build your own pc on May 15th, 2017 @ 11:42

Add a Comment

required, use real name
required, will not be published
optional, your blog address