This is a sample WordPress website with an included configuration for both PHP and NGINX.
- Ubuntu 22.04 LTS
- nginx/1.23.0
- headers-more-nginx-module
- ngx_brotli
- ngx_devel_kit
- set-misc-nginx-module
- PHP 8.1
- php-fpm
- mysql Ver 8.0.29 Distrib 5.7.33
- certbot 1.21.0
Install NGINX and add the following modules to your installation:
- HTTPS://github.com/openresty/headers-more-nginx-module
- HTTPS://github.com/google/ngx_brotli
- HTTPS://github.com/vision5/ngx_devel_kit
- HTTPS://github.com/openresty/set-misc-nginx-module
Replace every occurrence of wordpress.sample in
nginx/sites/wordpress.conf
with yourdomain.com
Generating DH parameters:
mkdir -p /etc/nginx/ssl/
cd /etc/nginx/ssl/
sudo openssl dhparam -out /etc/nginx/ssl/dhparam.pem 4096
Issuing certificates:
sudo apt install certbot -y
certbot certonly -d yourdomain.com --standalone
certbot certonly -d www.yourdomain.com --standalone
Install PHP 7.4 and Composer
.
Create the session folder for PHP-FPM:
mkdir -p /usr/share/nginx/sites/wordpress/tmp/session
Create a new user for the WordPress installation:
adduser --no-create-home --disabled-login --disabled-password wordpress
Install Bedrock
in the
/usr/share/nginx/sites/wordpress/ directory and add the required WordPress
plugins:
composer require roots/soil
composer require wpackagist-plugin/wordpress-seo
composer require wpackagist-plugin/wp-optimize
composer require wpackagist-plugin/wp-super-cache
Configure the WP Super Cache plugin by adding:
/**
* WP Super Cache
*/
Config::define("WP_CACHE", env("WP_CACHE") ?: false);
Config::define("WPCACHEHOME", $root_dir . "/web/app/plugins/wp-super-cache/");
to your config/application.php file and WP_CACHE your to .env file:
WP_CACHE=true
Setup WP CLI
and install WordPress:
alias wp='wp --allow-root'
wp core install \
--title="Sample" \
--admin_user="Administrator" \
--admin_password="Administrator" \
--admin_email="[email protected]" \
--url="HTTPS://WordPress.Sample" \
--skip-email
# Update permalink structure.
wp option update permalink_structure "/%postname%/" --skip-themes --skip-plugins
wp rewrite structure "/%postname%/"
wp plugin activate soil
wp plugin activate wordpress-seo
wp plugin activate wp-optimize
wp plugin activate wp-super-cache