There is an incredible amount of information out there about installing WordPress – a Google search for “WordPress install” yields 488,000 results as of this writing. Yet among those results are very few tutorials that comprehensively explain how to install both WordPress and the underlying operating system in a way that’s maintainable in the long term. Perhaps that’s because the right configuration varies so much depending on specific needs, or perhaps it’s because a comprehensive guide doesn’t make for an easy-to-read article.
In this post we’re trying to combine the best of both worlds, by providing a bash script that automates WordPress installation on Ubuntu and walking through it to explain what each section does and the design trade‑offs we made. (If you are an advanced user, you may want to skip this post and go directly to the script, downloading and modifying it for your environment.) The resulting WordPress installation is scriptable, supports Let’s Encrypt, uses NGINX Unit, and has production‑ready settings.
We’re building on the architecture for deploying WordPress with NGINX Unit that’s described in an earlier post on our blog, while also installing and configuring features not covered there (or in many other tutorials):
This post describes setting up WordPress on a single node where the static asset web server, PHP processing server, and database are co‑located. Installation of a multi‑host, multi‑service WordPress configuration is a potential future topic. What else would you like us to cover in a future post? Let us know in the comments section at the end of the blog!
root
privileges or equivalent access via sudo
The application architecture is the same as described in the previous blog post: a three‑tier web application. It includes PHP scripts that must be executed by a PHP processor and static files that have to be delivered by a web server.
if
statements), for idempotency: the script can run multiple times without risk of changing settings that are already correct.apt
upgrade
).root
because they change the core system configuration, but in the runtime state WordPress runs under a regular user identity.Before running the script, set the following environment variables.
WORDPRESS_DB_PASSWORD
– The password for the WordPress database.WORDPRESS_ADMIN_USER
– The username of the WordPress administrator.WORDPRESS_ADMIN_PASSWORD
– The password for the WordPress administrator.WORDPRESS_ADMIN_EMAIL
– The email address of the WordPress administrator.WORDPRESS_URL
– The full URL for the WordPress site, starting with https://.LETS_ENCRYPT_STAGING
– Blank by default, but set to 1
if you are using staging Let’s Encrypt servers, which is necessary when frequently testing new deployments of your configuration. Otherwise, Let’s Encrypt might block your IP address temporarily for making excessive requests.The script checks that the WordPress‑related variables are set and exits if any are not (lines 8–42, not shown here). Lines 572–576 check the value of LETS_ENCRYPT_STAGING
.
#blog #tech #wordpress #nginx unit #ubuntu