- Regolith is designed to work with Apache, but Nginx will also work fine with some minimal modifications.
- You'll also need SSH access to your production server.
- Git and WP-CLI must be installed in all environments. If your host doesn't have Git or WP-CLI installed, check the troubleshooting guide for a workaround.
- PHP 7.0+. If you can't use that, you could make some minor code changes to make it compatible with PHP 5.3.
- Unix-based operating systems (Linux, OS X, etc) in all environments. It may be possible to run on Windows with Cygwin, but I haven't tested it.
If you run into any problems, check the troubleshooting guide.
- Create the database and database user account. Import any existing data.
git clone
this repository to a folder one level above Apache'sDocumentRoot
.- For example, if
DocumentRoot
is/home/jane-development/example.test/public_html
, then clone Regolith to/home/jane-development/example.test
.
- For example, if
- Configure Apache's
DocumentRoot
to be theweb/
folder. - (optional) Configure your web server to store PHP/Apache/etc logs in the
logs/
folder. - Update all the default configuration.
- Copy
config/environment-sample.php
toconfig/environment.php
. - Update the values in
config/*
,.gitignore
, and anything else you want to customize. - Warning: Before enabling the HSTS header in
.htaccess
, make sure the site has an active SSL certificate, and that you understand the consequences of HSTS. You may also need to tweak it to include subdomains, preloading, etc. - Add any plugins and themes you want to install to
.gitignore
. That file acts as the central and canonical list of dependencies, and other scripts (likebin/install-dependencies.sh
) will extract the items from there.- Warning: Make sure all 3rd-party plugins/themes are in
.gitignore
, and that custom ones are not there. See the notes in.gitignore
for details.
- Warning: Make sure all 3rd-party plugins/themes are in
- Update the path in
web/.user-sample.ini
and move it toweb/.user.ini
, then restart php-fpm.
- Copy
- Run
./bin/install-dependencies.sh
to install dependencies and perform other setup tasks. - Visit the site to make sure everything is loading correctly.
- If you're seeing a blank page on the front end, log in to the back end and make sure a valid theme is activated.
- If you're setting up a Multisite install, run through the steps in the Multisite installation notes.
- Once you've verified that everything is setup correctly in your local environment:
- Run
git remote set-url origin {your_repo_url}
and commit your changes.- Alternately, if you want to start with a clean commit history, you can:
rm -rf .git
,git init
,git add .
,git ci -m 'Initial Commit'
.
- Alternately, if you want to start with a clean commit history, you can:
git push
to your site's repository.- At this point, your repo is independent of Regolith. You can manually merge in updates if you want, but it's also fine if you don't want to.
- Run
- Create the production database and database user account. Import any existing data.
- Generate an SSH key pair if you don't already have one, and copy your public key to the server.
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id -i ~/.ssh/mykey user@host
- At this point, you should be able to
ssh user@host
without entering a password.
ssh
to your production server andcd
to the site's root directory (e.g.,cd /home/jane-production/example.org
)git clone
your remote repository to a folder one level above Apache'sDocumentRoot
.- For example, if
DocumentRoot
is/home/jane-production/example.org/public_html
, then clone Regolith to/home/jane-production/example.org
.
- For example, if
- Configure Apache's
DocumentRoot
to be theweb/
folder.- If your host doesn't let you change that, you can replace the existing
DocumentRoot
folder with a symlink to theweb
folder.
- If your host doesn't let you change that, you can replace the existing
- Upload a copy of your local
environment.php
to the production server'sconfig/
folder, and update the values to match production's config.- This is required because
environment.php
is never checked in to source control (because it contains sensitive and machine-specific information).
- This is required because
- Update any paths in
web/.user.ini
. It'll probably take a few minutes for changes to this file to take effect. - Run
bin/install-dependencies.sh
- Visit the site to make sure everything is loading correctly.
- If you're seeing a blank page on the front end, log in to the back end and make sure a valid theme is activated.
- From your local development environment, run
bin/deploy.sh
to test the deployment process.- For added convenience, you can optionally add a
deploy
function to your~/.bashrc
file, and have it automatically call thedeploy
script regardless of which directory you're in. That way you don't have to specify the path to the folder. You can also make it support multiple sites as well, so that you can use a single consistent command for all sites you work on, even if they use different deployment mechanisms. See iandunn/dotfiles/.bashrc for an example.
- For added convenience, you can optionally add a
- Setup HTTP content sensors with a monitoring service -- like Uptime Robot -- to look for the value of
REGOLITH_CONTENT_SENSOR_FLAG
inhttps://example.org/wp-login.php
andhttps://example.org/?s={timestamp}
.- The timestamp serves as a cachebuster. If the monitoring service doesn't allow timestamp tokens, then you can also use Super Cache's
donotcachepage
parameter along with the value ofREGOLITH_WP_SUPER_CACHE_SECRET
.
- The timestamp serves as a cachebuster. If the monitoring service doesn't allow timestamp tokens, then you can also use Super Cache's
- Setup CloudFlare, including Page Rules to cache dynamic content. (write your own blog post about this w/ examples, note about not cahcing logged-in views for security. then link the article here -- https://iandunn.name/?p=2354)
- Configure the SMTP settings in
environment.php
to send outbound email through a transactional mail service.- I like Mailgun, but any service that supports SMTP should work.
- I don't recommend Gmail or other consumer email services, because they're not designed to be used in this way. I've seen Gmail start rejecting messages all of the sudden for various reasons, without any advanced warning or failure notification.
- Don't forget to update your SPF and/or DKIM records too.
- Tweak OPCache settings.
bin/deploy.sh
will reset the OPCache contents, so you should be able to setopcache.validate_timestamps = 0
, to avoid the performance penalty associated with checking the timestamps. I haven't tested that yet, though. If you do, keep in mind that you'll need to manually reset the cache if you ever directly modify production files (while troubleshooting, etc).
- Configure your web server to store PHP/Apache/etc logs in the
logs/
folder. PHP logs should already be going there (seeconfig/wordpress.php
), but it's best to set this viaphp.ini/phprc/.user.ini
to be safe.- It's also a good idea to test and make sure that the logs are actually being populated, since file permissions or other issues could prevent it.
After you have Regolith setup in your local and production environments, you can use a traditional workflow, like this example:
- Make and test your code changes in your local environment.
git add
,git commit
,git push
bin/deploy.sh
- Verify the changes work on production.
Periodically, when you want to refresh the content in your development environment from the production site, you can run bin/sync-production-content.sh
.