Moving WordPress

Moving WordPress

Whether you are moving WordPress to a new server or to a different location on your server, you don't need to reinstall. WordPress is flexible enough to handle all of these situations.

Moving to a New Server

If you are moving WordPress from one server to another, begin by backing up your WordPress directory, images, plugins, and other files on your site as well as the database. See WordPress Backups and Backing Up Your Database.

Keeping Your Domain Name and URLs

Moving your domain without changing the Home and Site URLs of your WordPress site is very simple, and in most cases can be done by moving the files.

  • If database and URL remain the same, you can move by just copying your files and database.
  • If database name or user changes, edit wp-config.php to have the correct values.
  • If you want to test before you switch, you must temporarily change "siteurl" and "home" in the database table "wp_options" (through phpMyAdmin or similar).
  • If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.

Changing Your Domain Name and URLs

Moving a website and changing your domain name or URLs (i.e. from http://example.com/site to http://example.com, orhttp://example.com to http://example.net) requires the following steps - in sequence.

  1. Download your existing site files.
  2. Export your database - go in to MySQL and export the database.
  3. Move the backed up files and database into a new folder - somewhere safe - this is your site backup.
  4. Log in to the site you want to move and go to Settings > General, then change the URLs. (ie from http://example.com/ tohttp://example.net ) - save the settings and expect to see a 404 page.
  5. Download your site files again.
  6. Export the database again.
  7. Edit wp-config.php with the new server's MySQL database name, user and password.
  8. Upload the files.
  9. Import the database on the new server.

When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.

If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have four options:

  1. Use the Velvet Blues Update URLs plugin if you can access your WP Admin Dashboard.
  2. Use the Better Search Replace plugin if you can access your WP Admin Dashboard.
  3. Use WP-CLI's search-replace if your hosting provider (or you) have installed WP-CLI.
  4. Use the Search and Replace for WordPress Databases Script to safely change all instances on your old domain or path to your new one. (** only use this option if you are comfortable with database administration ** )

Note: Only perform a search and replace on the wp_posts table.
Note: Search and Replace from Interconnectit is a 3rd party script

Moving Directories On Your Existing Server

Moving the WordPress files from one location on your server to another - i.e. changing its URL - requires some special care. If you want to move WordPress to its own folder, but have it run from the root of your domain, please read Giving WordPress Its Own Directory for detailed instructions.

Here are the step-by-step instructions to move your WordPress site to a new location on the same server:

  1. Create the new location using one of these two options:
    1. If you will be moving your WordPress core files to a new directory, create the new directory.
    2. If you want to move WordPress to your root directory, make sure all index.php, .htaccess, and other files that might be copied over are backed up and/or moved, and that the root directory is ready for the new WordPress files.
  2. Log in to your site.
  3. Go to the Administration > Settings > General panel.
  4. In the box for WordPress Address (URL): change the address to the new location of your main WordPress core files.
  5. In the box for Site Address (URL): change the address to the new location, which should match the WordPress (your public site) address.
  6. Click Save Changes.
  7. (Do not try to open/view your site now!)
  8. Move your WordPress core files to the new location. This includes the files found within the original directory, such ashttp://example.com/wordpress, and all the sub-directories, to the new location.
  9. Now, try to open your site by going to yourdomain.com/wp-admin. Note, you may need to go to yourdomain.com/wp-login.php
  10. If you are using Permalinks, go to the Administration > Settings > Permalinks panel and update your Permalink structure to your.htaccess file, which should be in the same directory as the main index.php file.
  11. Existing image/media links uploaded media will refer to the old folder and must be updated with the new location. You can do this with the Velvet Blues Update URLs or Better Search Replace plugins, WP-CLI's search-replace if your hosting provider (or you) have installed WP-CLI, manually in your SQL database, or by using the 3rd party database updating tool Search and Replace Databases Script * Note: this script is best used by experienced developers.
  12. In some cases your permissions may have changed, depending on your ISP. Watch for any files with "0000" permissions and change them back to "0644".
  13. If your theme supports menus, links to your home page may still have the old subdirectory embedded in them. Go to Appearance > Menus and update them.
  14. Sometimes you would need to restart your server, otherwise your server may give out an error. (happens in MAMP software (Mac)).

It is important that you set the URI locations BEFORE you move the files.

If You Forget to Change the Locations

If you accidentally moved the files before you changed the URIs: you have two options.

  1. Suppose the files were originally in /path/to/old/ and you moved them to /path/to/new before changing the URIs. The way to fix this would be to make /path/to/old/ a symlink (for Windows users, "symlink" is equivalent to "shortcut") to/path/to/new/, i.e. ln -s /path/to/new /path/to/old and then follow the steps above as normal. Afterwards, delete the symlink if you want.
  2. If you forget to change the WordPress Address and Blog Address, you will be unable to change it using the wordpress interface. However, you can fix it if you have access to the database. Go to the database of your site and find the wp_options table. This table stores all the options that you can set in the interface. The WordPress Address and Blog Address are stored as siteurl and home (the option_name field). All you have to do is change the option_value field to the correct URL for the records withoption_name=’siteurl‘ or option_name=’home‘.

If You Have Accidentally Changed your WordPress Site URL

Suppose you accidentally changed the URIs where you cannot move the files (but can still access the login page, through a redirection or something).

wp-login.php can be used to (re-)set the URIs. Find this line:

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

and insert the following lines below:

//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' );

You're done. Test your site to make sure that it works right. If the change involves a new address for your site, make sure you let people know the new address, and consider adding some redirection instructions in your .htaccess file to guide visitors to the new location.

Changing The Site URL also provides the details of this process.

Managing Your Old Site

Shutting It Down

  1. Download a copy of the main wordpress files from your OLD site to your hard drive and edit wp-config.php to suit the new server.
  2. Go back to your OLD site and go to Administration > Settings > General and change the URL (both of them) to that of your new site.
  3. Login on your server, go to phpMyAdmin, export as file, and save your database (but keep the old one just in case). Now, upload this new database and the copy of the wordpress core files with the edited wp-config.php to your new server. That's it!

Keeping it Running

Caution: Make sure you have a backup of your old site's WordPress database before proceeding!

Part A - Activating Your New Site

  1. Download your entire WordPress installation to your hard drive. Name the folder appropriately to indicate that this is your OLD site's installation.
  2. Download your database.
  3. Go back to your OLD site and go to options and change the url (both of them) to that of your new site.
  4. Again, download your entire WordPress installation to your hard drive. Name the folder appropriately to indicate that this is your NEW site's installation.
  5. Download your database once again (but keep the old one). Upload this database to your new server. It will be easiest if you use the same database name and you create a user with the same login credentials on your new server as on your old server.
  6. If you used a different database name and/or user (see previous step), edit wp-config.php in your NEW site's installation folder appropriately.
  7. Upload the NEW site's installation folder to your new site. Presto, your NEW site should be working!

Part B - Restoring Your Old Site

  1. On the original server, delete your OLD site's database (remember, you should have a copy on your local computer that you made at the very beginning).
  2. Upload your OLD site's installation folder to your original server, overwriting the files that are currently there (you may also delete the installation folder on the server and simply re-upload the OLD site's files).
  3. Upload your OLD site's database from your local computer to the server. That should do it!

Another procedure for making copies of posts, comments, pages, categories and custom field (post status, data, permalinks, ping status, etc.) easy to follow:

  1. Install a new WordPress site
  2. Go on old site Admin panel. Here, in Manage > Export select "all" in menu Restrict Author.
  3. Click on Download Export File
  4. In new site go on Manage > Import, choose WordPress item.
  5. In the page that will be shown, select the file just exported. Click on Upload file and Import
  6. It will appear a page. In Assign Authors, assign the author to users that already exist or create new ones.
  7. Click on Submit
  8. At the end, click on Have fun

Note: using this method, if there are some articles in the new site (like Hello World, Info Page, etc.), these will not be erased. Articles are only added. Using the former procedure, the articles in new site will be deleted.

Moving WordPress Multisite

Multisite is somewhat more complicated to move, as the database itself has multiple references to the server name as well as the folder locations. If you're simply moving to a new server with the same domain name, you can copy the files and database over, exactly as you would a traditional install.

If, instead, you are changing domains, then the best way to move Multisite is to move the files, edit the .htaccess and wp-config.php (change DOMAIN_CURRENT_SITE and, if the folder name containing Multisite changed, PATH_CURRENT_SITE), and then manually edit the database. Search for all instances of your domain name, and change them as needed. This step cannot yet be easily automated. It's safe to search/replace any of the wp_x_posts tables, however do not attempt blanket search/replace without the Search and Replace for WordPress Databases script (aka the interconnectit script).

If you're moving Multisite from one folder to another, you will need to make sure you edit the wp_blogs entries to change the folder name correctly. You should manually review both wp_site and wp_blogs regardless, to ensure all sites were changed correctly.

Also, manually review all the wp_x_options tables and look for three fields and edit them as needed:

  • home
  • siteurl
  • fileupload_url

If you are moving from subdomains to subfolders, or vice-versa, remember to adjust the .htaccess file and the value forSUBDOMAIN_INSTALL in your wp-config.php file accordingly.


A Step By Step Guide to Migrating Your WordPress Website To A New Web Host

A Step By Step Guide to Migrating Your WordPress Website To A New Web Host

Moving your website to a new host can be a daunting and stressful experience, but it doesn’t need to be.Many people are faced with the need to move to a new host because of problems with their current provider and have just had enough. But all too often, migrating to a more reliable host is delayed time and again for fear of making a mistake and damaging your site(s).To get around the problem, people will either pay a professional to move their site for them, find a new host that offers the service as part of a new hosting package, or take the third option of having a go at it themselves.

If you spend a little time preparing your own website, migrating is nothing to be concerned about. It can be a very straightforward project if approached correctly and can easily be reversed out of should any problems occur.

Let’s run through the steps required to move your WordPress website to a new host.

Step 1: Back Up Your Website’s Files

The very first step of any project such as this is to back up every aspect of your site. This step is good practice before any major change but it is also a requirement of migrating your WordPress installation.

There are many plugins out there that will completely backup your site for you. This backup however, requires a more manual approach. Using an FTP program (such as FileZilla), connect to your web host and copy all files under your website’s directory to a folder on your local computer.

This includes the .htaccess file that is set to be hidden. Consult your FTP program’s help file to have it display hidden files if you are unable to see this file.

Depending on the number of media uploads you have in your site, this could take some time. While this download is underway we can begin step two and make a copy of your database.

Step 2: Export The WordPress Database

Exporting your database is a simple process that only requires a few steps to complete. Login to the cPanel account of your web server and open the phpMyAdmin application. Select the database that contains your WordPress installation from the list on the left hand sidebar and once selected click on the Export tab on the navigation menu.

The default settings of a Quick export and the SQL format for the export are sufficient for what we need. Click the Go button and the database export process will begin and a file will be downloaded to your local computer.

Once the database export and the FTP transfer of your files have both completed, you are ready to move onto the next stage.

Step 3: Create The WordPress Database On Your New Host Server

Before we can begin the migration to the new web host, we need to create an environment for a WordPress installation. To do this you must create a database that you can import your SQL data into.

Login to your new web host with the user credentials they have supplied you and connect to the cPanel software. For our guide we will be using the MySQL Databases application. If your web host doesn’t have that application running then you will should contact their support team to discover their method of creating new databases.

The steps to create a database are quite simple:

  • Open MySQL Database and create a new database with an appropriate name for your website.
  • Create a new MySQL user (with a secure password).
  • Add this user account to the new database and grant it All Privileges.

Write down the database name, the new MySQL username and its password. You will need them soon.

Step 4: Edit the wp-config.php File

Browse to the folder on your local computer where you downloaded your website files to. In that folder there is a file called wp-config.php that controls the access between WordPress and your database.

Make a copy of this file and store it in another folder on your local computer. This is necessary for restoring the changes we are about to make should something go wrong later.

Open the original version of the file with your favorite text editor and make the following three changes:

1. Change The Database Name

Locate the following line:

define('DB_NAME', 'db_name');

The db_name portion of this line will currently be set to the MySQL database name of your old web host. This must be changed to the name of the new database you have just created.

2. Change the Database Username

Below this you will find the line:

define('DB_USER', 'db_user');

In this line you need to change the db_user portion from the username of your old host to match the new username you have just created.

3. Change The Database User Password

Finally, edit the third line:

define('DB_PASSWORD', 'db_pass');

As with the others the db_pass section of this line must be changed to the new secure password you created for your MySQL user.

Save wp-config.php and close the file.

Step 5: Import Your Database

Now that you have a new database to work with we can begin the import process.

Launch phpMyAdmin from the cPanel software on your new server and select your new database from the list on the left hands sidebar. Once it opens select the Import tab from the navigation menu.

In the File to Import section click the Choose File button and select the SQL file you exported previously.

Un-tick the Partial Import check box, make sure the format is set to SQL and then click the Gobutton. The database import will now begin.

The time this import takes varies depending on the size of your database. You should receive a message informing you of the success of the import when it has finished.

Step 6: Upload The WordPress Files To Your New Host

Now that you have the new database prepared and you’ve reconfigured the wp-config.php file, it is time to begin uploading your website’s files.

Connect to your new web host using your FTP program and browse to the folder that your website is going to be held. If this is the primary, or only site being installed on this web server then uploading the files to the public_html folder is the usual directory.

With the remote directory selected you can upload your website files that should now include the updated version of wp-config.php. As with the earlier download, this process can take some time.

Don’t delete these files from your local computer once the upload finishes. They are still needed until the final steps have been completed.

Step 7: Linking to New URL & Defining New Domain

One issue people always seem to have when moving their site is that they’ve added links to other posts on their site or inserted images directly by pointing to a URL on the server, causing these to break when moved over to a new domain. If you want to quickly and easily search for any instances of your old domain name and replace with the new name I (AJ Clarke) suggest you take a look at the Search Replace DB script on github. This will allow you to do this with great ease. Just make sure you DELETE it when your are done (for security reasons).

Make sure you are running the search and replace on the new domain you are transferring the site to not the old one.

Changing Site URL: By doing a search and replace for the old domain and replacing with the new domain you’ll also be altering the site_url and home url values in the database (Changing the Site URL) which will ensure that when you try to log into your site on the new domain it doesn’t try and redirect you over to the old domain.

* This small subsection was an added note by AJ Clarke.

Step 8: The Final Touches

This step actually includes two separate things with (potentially) several days between them.

Before you can use the site on your new host you will need to reconfigure your domain’s DNS settings. They will be set to point to your old host and you will need to point the correct records to the new server IP address.

This process will depend on where you have your domain registered. The details of completing this process are too varied to discuss in this post, but your domain registrar should have all of the details you need to make this change.

DNS changes can take up to 48 hours to fully propagate. It’s best to do this at a period when you expect lower levels of traffic. During this 48 hour window you should avoid making any changes to your website as you may be changing the old version of the site.

After the 48-hour period has expired you should now be accessing the new web host when you go to your website. It’s at this point you can connect to your old web host to delete the files and database. You should still have a local backup copy of these files and the database export, along with the original wp-config.php file in case you need to roll back the migration. It can be a good idea to hold onto these files for a an extended period just to be on the safe side.

Conclusion

As you can see, when broken down into the above simple steps, the process isn’t that difficult.All it really requires is for you to be careful at each step and give yourself the option to go back to the original version until the last possible moment (in case of any problems).

Have you migrated your WordPress website recently? Let us know your experience with the process in the comments section below!


I am receiving “500 Internal Server Error” in my WordPress

I am receiving “500 Internal Server Error” in my WordPress

If you receive that error when trying to access your WordPress installation, you can use the following steps to try to find out the reason for it:

1. Check your WordPress files for permissions above 755. Our servers run in SuExec mode so the maximum allowed permissions are 755, all permissions above 755 will result in Internal Server Error. You can find which files exactly give the error from your cPanel > Error log.

After that, you can change the permissions from cPanel > File Manager or with your favorite FTP client.

2. Check your WordPress .htaccess file for bad directives. It is located in your WordPress installation directory. If the error is caused by such a directive, it should be displayed inside the cPanel --> Error log as well.

Such error message can also occur if there is high load on the hosting server.


Custom DNS in cPanel

How do I add a custom DNS record?

  • DNS records can be added from either cPanel or WHM. It is recommended to add domain-related DNS records through cPanel, and only add server-related DNS records through WHM (ie: name server records, hostname records, etc)

To enter DNS records with in cPanel:

1.  Under Domains click on Simple DNS Editor

  • If you have more than one domain added, select the domain for which you wish to create records from the dropdown box
  • If you only have one domain, there will not be a dropbox

2.  Enter under Name what is being directed to through the IP. You can also use a wildcard(*) if necessary. Wildcards will cover anything under the domain such as testing.testingwebsites.com.

cPanel20

3.  Enter the IP address for your record,

cPanel25

4.  And click Add A Record

    • There is also the option below to create canonical (CNAME) records, with a Add a CNAME Record button to submit.

Advanced DNS Zone Editor

DNS (Domain Name Service) is the component of the Internet that converts human-readable domain names (for example, example.com) into computer-readable IP addresses (for example, 123.456.789). DNS uses zone files that reside on your server to map domain names to IP addresses.  There are several different types of records in a domain’s zone file. This feature allows you to create, edit, and delete A, AAAA, CNAME (Canonical Name Record), SRV (Service Record), and TXT (Text Record) records. Enabling or Disabling the Advanced DNS Editor for cPanels in WHM Please ensure the feature list with the “Advanced DNS Zone Editor” option enabled is the same feature list assigned to the package used by the account. You can edit the package to determine which feature list is assigned to it via:  “WHM >> Packages >> Edit a Package”

Log into your WHM dashboard.   Once you are in the WHM, located under the Packages category
WHM-Packages1
look for the Feature Manager tool.
WHM-Feature-Manager
This leads you to a page where you can select the feature template list you want to edit. In this case, there is not one, so we can create one by giving a name to the list we want to create. For example, we name this list Default. Click Add to create the feature template.
WHM-Feature-Manager-2
The new list name will appear under the Edit a Feature List section. Make sure it is selected in the dropdown and click the Edit button. From here you will see a long lost of Features that are offered for accounts with this list. Select or Deselect the checkbox next to the Advanced DNS Zone Editor field. Scroll to the bottom and click on the Save button. This saves your configuration and all accounts that use that configuration will have/ not have the Advanced DNS Zone Editor according to your configuration.
enable_adv_dns_zone

To enter Advanced DNS records with in cPanel:

1.  Under Domains click on Advanced Zone Editor There are 3 differences in the advanced editor from the simple one. Please note that if you are not 100% sure what changes you are making it is always better to use the Simple DNS Zone Editor in order to avoid any major issues with the DNS zone for your domain name and the accessibility of your website.The first difference is the option to completely reset your DNS records to the default ones. Note that this option should not be used in cases you need custom setup for your domain name DNS. It is only safe to use this option if you would like the DNS reset to default.

advanced_dns_zone

To reset the DNS Zone for the chosen domain name click “More”.

Advanced101

To reset your DNS zone files to the defaults that your hosting provider specifies, perform the following steps:

  1. If this account owns more than one domain, select the domain that you wish to manage from the Domain menu.
  2. Click more.
  3. Select the Are you sure that you wish to erase all of your entries and revert to the default state? checkbox.

Advancde22

 Edit a record

To edit a record, perform the following steps:
  1. If this account owns more than one domain, select the domain that you wish to manage from the Domain menu.
  2. Click Edit next to the record that you wish to edit.
  3. Change the information in the text boxes as necessary.
  4. Click Edit Record to save your changes, or click Cancel to discard them.

Delete a record

To delete a record, perform the following steps:

  1. If this account owns more than one domain, select the domain that you wish to manage from the Domain menu.
  2. Click Delete next to the record that you wish to remove.
  3. Click Delete.

To enter DNS records with WHM:

If editing a record to an existing domain/zone

  1. Under DNS Functions

click Edit DNS ZoneSelect your domain name from the list and click the Edit button.In the image above you will see a read out of all the current records listed for the domain newreseller.com as an example. To add new entries for any domain you might be editing DNS records for, you will scroll down the page a little more to see the following image: Here you see the default fields: Name, TTL and then a drop down to select which record you would like to add. Once complete with the information you are adding, you will select Save and the entries will be added to that domain. Email routing will normally stay default to Local Mail Exchanger as this ensures email is routed through the server. Unless you are utilizing 3rd party mail services, only then you will select a different email route such as Remote Mail Exchanger.


How to backup a database in PHPMyAdmin

How to backup a database in PHPMyAdmin

This tutorial is going to show you how to export data from your MySQL database using phpMyAdmin. You can find a link to phpMyAdmin in your control panel. It depends on your hosting package, so the directions may differ from the ones you may have in your Cpanel.

In order to export your database,

    1. Login to cPanel with the usernale and password you hosting provider gave you.
    2. Find an icon for phpMyAdmin and click on it.
    1. It is going to take you to phpMyAdmin. The list of available databases will be listed on the left hand side once you get into phpMyAdmin.
    2. Using Ctrl+F you can easily highlight the one you are going to export. Click on it.
    3. Click Export at the top.
    1. Under Export Method you will be suggested to choose between the two options.
  1. Quick export that when clicked allows you to download an .sql file to your computer right away after you click "Go".
  2. Custom export will display all options possible to export the file. Here are the most important ones:
    • under the Tables you can export all tables of your database or select particular ones from the list
    • Under Output you can give a name to your file, choose its character set and compression.
    • Under Format-specific options, make sure structure and data is selected.
    • In Object creation options, check Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement
    • You may leave all other settings as they are by default.
    • At the bottom of the page, click Go.
    • You will be prompted to save a file on your computer. Once you do, the backup will be created and saved. It may take several minutes, depending on the size of the database.

That’s it.You can keep the backup and re-import it at any time to restore your database, on this server or any other MySQL server.


How to create a database

How to create a database

This tutorial shows how to create a database using hosting control panel.

1. Open MySQL Databases.

2. Specify database name.

3. Add new database user.

4. Assign database user to your database.

4.1. Select user and database, click Add.

4.2. Set all privileges for database user.

5. In order to access database you should open phpmyadmin database management tool.

6. Open your database.


How to check PHP version on the server with info.php

How to check PHP version on the server with info.php

The only actions required form you are the following:

  1. Download info.zip script. Unzip the archive.
  2. Upload info.php script file to the root directory of your hosting server.
  3. Run the website URL in the browser plus /info.php at the end of it.

How to modify php.ini on localhost

How to modify php.ini on localhost


How to upload files to a server

How to upload files to a server


How to check whether mod_rewrite is enabled on server?

How to check whether mod_rewrite is enabled on server?

  1. Open your website root directory, create a php file mod_rewrite.php.
  2. Add the following line of code to it:
    <?php echo "Mod_rewrite is activated!"; ?>
  3. Create .htaccess file (rename the original file to .htacess_original if you have it).
  4. Add the following content to the file:
    RewriteEngine On
             RewriteRule ^.*$ mod_rewrite.php
  5. Open your site. If you see a message “Mod_rewrite is activated!”, it is enabled on your server. If you see anything else – mod_rewrite is disabled.
  6. Make sure to delete the .htaccess file you created and rename the original file back: