How to Deploy a WordPress Site
Types of Deployment
- Totally new project on local development site.
- Deploy development site to production production.
- Migrate/clone production site to development (local) site.
- Migrate/clone development site to new production site.
- Push changes from development site to an existing production site.
Components of WordPress Site
- Core WordPress files.
- Third-Party Plugin Files.
- Third-Party Theme Files.
- Local Plugin Files.
- Local Theme Files.
- Uploaded Content
- Database
Manually Cloning a WordPress Site
Note, I have not successfully cloned a WordPress Site, though the problem maybe with Apache2 instead of WordPress. For some reason, the URL Rewrite rules are giving bogus results causing the request to fail with “/var/www/html/index.php” not found.
- Export database from Master Website
- Include option to drop existing tables during the import before loading data.
- Copy all files from Master Website to Clone Website.
- Make sure all clone files have 664 and all clone directories have 775 permissions.
- find . -type f -exec chmod 664 {} \;
- find . -type d -exec chmod 775 {} \;
- Make sure all clone files and directories are owned by the web server and are assigned to the same group as the web server.
- If web server is in the same group as the owner, that works too.
- Make sure all clone files have 664 and all clone directories have 775 permissions.
- Import database to Clone Website.
- Manually update Clone Database so that all references to the Site URL are changed to the Clone Website.
- My script, update.php, does that.
- In wp_posts, update GUID column.
- In wp_postmeta, update meta_value column.
- In wp_options, update option_value column.
- Make sure to unserialize values before switching URLs.
- UPDATE wp_options SET meta_value = ” WHERE meta_key = ‘recently_edited’;
- In wp_usermeta, check all the meta_values where the meta_key = ‘home_path’. If the path does not reflect the clone website.
- NoMoreCaptchas uses the home_path to save log data.
- Edit wp-config.php
- Make sure the following constants are properly defined:
- DB_USER
- DB_PASSWORD
- DB_NAME
- DB_HOST
- table_prefix
- Make sure the following constants are properly defined:
- Make sure Clone Database is “repaired”
- Edit wp-config.php — Add “define(‘WP_ALLOW_REPAIR’, true);”
- In browser, go to http://{website}/wp-admin/maint/repair.php
- Run database repair
- Edit wp-config.php — Remove “define(‘WP_ALLOW_REPAIR’, true);”
- Rebuild the Permalink cache
- Click on the dashboard -> Appearance -> Permalink menu item.
- Select a different method of permalink format (radio buttons) than the one currently being used.
- Save new selection.
- Select the original method of permalink format.
- Save original selection.
- If everything is correct, the Clone Website should be functional.