Tune WordPress
Tune the popular blogging and CMS engine WordPress on fortrabbit.
# Adding a custom domain
Your test domain {{app-env-id}}.frbit.app is the first address your WordPress can be reached from. Later on, when you go live, you will add your own custom external domains. Here is the basic setup:
- Register and route the domain to the environment < see domain article
- Connect the domain to your fortrabbit environment, so that requests for a new domain will be delegated
- Once the domain is routed, tell WordPress to use the new domain as well:
# Changing the site_url domain in the wp-admin
In the WordPress admin change the Site URL from your App URL to that new domain. Find this setting in wp-admin under Settings > General: "WordPress Address (URL)" and "Site Address (URL)". Change this to your new domain. More advanced help regarding domains and the vars home_url and site_url can be found in the Wordpress codex article on changing the Site URL.
# Database migration
WordPress consists of code files, the user generated uploads and of course the MySQL database, in which most of the contents are stored. There are various use cases to export and import the database:
- Export the database from your old web hosting
- Export your local database to import it to the fortrabbit database
- Export the remote database from fortrabbit to bring your local installation up-to-date
Read the MySQL export / import guides.
# Deploying WordPress changes with rsync
Sophisticated developers might have a look at rsync. It's many times faster than SFTP. See our rsync article.
# Using the WP-CLI
You can also use the popular and handy WordPress Command Line Interface on your fortrabbit App. When logged in to your fortrabbit App via SSH, you can just issue this command:
wpshell
The first time you call this will install it, next time you can just use it. See a list of commands here.
# Running WordPress in a sub folder
There are two reasons to install WordPress in a sub directory instead of in htdocs:
- WordPress is just the blog-part of the website:
mydomain.com/blog - You want to run multiple WordPress sites in one environment. Please don't.
You can achieve the first option by putting WordPress in a folder and by changing the "Site Address URL" parameter (see above). Also see the official WordPress codex on how to give WordPress it's own directory.