From 5a0fd0f172251bde6d3da47b53f87e58137dcb69 Mon Sep 17 00:00:00 2001 From: Jon Spriggs Date: Tue, 30 Jun 2020 09:44:52 +0100 Subject: [PATCH] Added Vagrant based development environment --- DevelopmentEnvironment/Vagrantfile | 16 ++++++++++++++ DevelopmentEnvironment/customise_wordpress.sh | 4 ++++ .../root_install_wordpress.sh | 21 +++++++++++++++++++ .../user_install_wordpress.sh | 14 +++++++++++++ 4 files changed, 55 insertions(+) create mode 100755 DevelopmentEnvironment/Vagrantfile create mode 100755 DevelopmentEnvironment/customise_wordpress.sh create mode 100755 DevelopmentEnvironment/root_install_wordpress.sh create mode 100755 DevelopmentEnvironment/user_install_wordpress.sh diff --git a/DevelopmentEnvironment/Vagrantfile b/DevelopmentEnvironment/Vagrantfile new file mode 100755 index 0000000..c65368f --- /dev/null +++ b/DevelopmentEnvironment/Vagrantfile @@ -0,0 +1,16 @@ +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/bionic64" + config.vm.network "forwarded_port", guest: 80, host: 80 + + config.vm.provision "shell", inline: <<-SHELL + # Install Dependencies + apt-get update + apt-get install -y apache2 libapache2-mod-fcgid php-fpm mysql-server php-mysql git + # Set up Apache + a2enmod proxy_fcgi setenvif + a2enconf php7.2-fpm + systemctl restart apache2 + # Set up Wordpress + /vagrant/root_install_wordpress.sh + SHELL +end diff --git a/DevelopmentEnvironment/customise_wordpress.sh b/DevelopmentEnvironment/customise_wordpress.sh new file mode 100755 index 0000000..5ceabfa --- /dev/null +++ b/DevelopmentEnvironment/customise_wordpress.sh @@ -0,0 +1,4 @@ +#! /bin/bash +cd /var/www/html/wp-content/plugins +git clone https://github.com/aaroncampbell/presenter --recurse-submodules +wp plugin activate presenter diff --git a/DevelopmentEnvironment/root_install_wordpress.sh b/DevelopmentEnvironment/root_install_wordpress.sh new file mode 100755 index 0000000..01890c3 --- /dev/null +++ b/DevelopmentEnvironment/root_install_wordpress.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +# Allow us to run commands as www-data +chsh -s /bin/bash www-data +# Let www-data access files in the web-root. +chown -R www-data:www-data /var/www + +# wp-cli +curl -s -S -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar +mv wp-cli.phar /usr/local/bin/wp +chmod +x /usr/local/bin/wp + +# Slightly based on +# https://www.a2hosting.co.uk/kb/developer-corner/mysql/managing-mysql-databases-and-users-from-the-command-line +echo "CREATE DATABASE wp;" | mysql -u root +echo "GRANT ALL PRIVILEGES ON wp.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';" | mysql -u root +echo "FLUSH PRIVILEGES;" | mysql -u root + +su - www-data -c /vagrant/user_install_wordpress.sh + +su - www-data -c /vagrant/customise_wordpress.sh \ No newline at end of file diff --git a/DevelopmentEnvironment/user_install_wordpress.sh b/DevelopmentEnvironment/user_install_wordpress.sh new file mode 100755 index 0000000..d276eb9 --- /dev/null +++ b/DevelopmentEnvironment/user_install_wordpress.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +# Largely based on https://d9.hosting/blog/wp-cli-install-wordpress-from-the-command-line/ +cd /var/www/html +# Install the latest WP into this directory +wp core download --locale=en_GB +# Configure the database with the credentials set up in root_install_wordpress.sh +wp config create --dbname=wp --dbuser=wp --dbpass=wp --locale=en_GB +# Skip the first-run-wizard +wp core install --url=localhost --title=Test --admin_user=admin --admin_password=password --admin_email=example@example.com --skip-email +# Setup basic permalinks +wp option update permalink_structure "" +# Flush the rewrite schema based on the permalink structure +wp rewrite structure "" \ No newline at end of file