Skip to content

Instantly share code, notes, and snippets.

@mdrovdahl
Forked from jifalops/_README.md
Last active April 29, 2022 22:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdrovdahl/3e941c129c70d3d0bd1fbc088de1f31b to your computer and use it in GitHub Desktop.
Save mdrovdahl/3e941c129c70d3d0bd1fbc088de1f31b to your computer and use it in GitHub Desktop.
Headless Crostini quick setup script for WordPress development

Headless Crostini quick setup script for WordPress development

WARNING

  • The script appends to the PATH environment variable each time it runs (at the end).

To get the script, use the Terminal app:

user@penguin:~$ mkdir bin && cd $_
user@penguin:~/bin$ curl -O https://gist.githubusercontent.com/mdrovdahl/3e941c129c70d3d0bd1fbc088de1f31b/raw/setup-dev-machine.sh
user@penguin:~/bin$ chmod +x setup-dev-machine.sh 
user@penguin:~/bin$ ./setup-dev-machine.sh 

CHANGELOG 2020-08-18

  • Added git to installed utilities
  • Added directory exists? checks before creating ~/dev and ~/wp
  • Changed the php install to use meta packages php-fpm and php-xml

2022-04-29

  • Added php-gd
#!/bin/bash
# death helper function
die() { echo "$*" 1>&2 ; exit 1; }
echo
echo "###########################################################################"
echo "Setting up this system for WordPress development."
echo "Work in progress"
echo "Last Updated: 2020-08-18"
echo
# Start from our home directory
cd "$HOME"
PATH_CHANGES=""
# Default ~/ folders to create
echo
echo "======================================================="
echo "Creating ~/dev & ~/wp folders if they don't already exist"
echo
for dir in \
"$HOME/dev" \
"$HOME/wp"
do
if ! [ -d "$dir" ]; then
echo "creating $dir"
mkdir $dir
fi
done
PATH_CHANGES+=':$HOME/bin'
# Make sure apt is updated
echo
echo "======================================================="
echo "Running apt update and apt upgrade"
echo
sudo apt update && sudo apt -y upgrade
# Useful utilities
echo
echo "======================================================="
echo "Installing utilities"
echo "git, jq, ssh, keychain, dnsutils (dig), iputils-ping, gnome-terminal, composer, pv"
echo
sudo apt -y install git jq ssh keychain dnsutils iputils-ping gnome-terminal composer pv
sudo mv /etc/ssh/sshd_not_to_be_run /etc/ssh/sshd_not_to_be_run_away
sudo systemctl start ssh.service
# PHP
echo
echo "=========================================================================="
echo "Installing PHP"
echo
sudo apt -y install php-fpm php-mysql php-xml php-gd
# NGINX
echo
echo "=========================================================================="
echo "Installing NGINX"
echo
sudo apt -y install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# MARIADB
echo
echo "=========================================================================="
echo "Installing MariaDB"
echo "Post install, set the root password and answer (y) to everything else"
echo
sudo apt -y install mariadb-server mariadb-client
sudo mysql_secure_installation
# Node and npm (via nvm)
echo
echo "======================================================================"
echo "Installing Node and npm via Node Version Manager (nvm) 0.34.0"
echo "See https://github.com/nvm-sh/nvm/blob/master/README.md for more info."
echo
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.bashrc
nvm install node
# WP-CLI
echo
echo "======================================================================"
echo "Installing wp-cli and bash auto-conmpletion"
echo "See https://wp-cli.org/#installing for more info."
echo
cd "$HOME/bin" && curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
sudo chmod +x /usr/local/bin/wp
wp --info
cd "$HOME/bin" && curl -LO https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash
# ADD THIS TO .bashrc
echo 'source /home/$USER/bin/wp-completion.bash' >> "$HOME/.bashrc"
# pip for Python 3
echo
echo "==========================="
echo "Installing pip for Python 3"
echo
sudo apt-get -y install python3-pip
# NGROK
echo
echo "======================================================================"
echo "Installing ngrok"
echo "See https://ngrok.com/download for more info."
echo
# Adjust this url for whichever platform you're on
cd "$HOME/bin" && curl -O https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
# Finishing up
echo "export PATH=\"\$PATH$PATH_CHANGES\"" >> "$HOME/.bashrc"
echo 'alias la="ls -a"' >> "$HOME/.bashrc"
echo 'alias ll="ls -la"' >> "$HOME/.bashrc"
echo
echo "Setup nearly complete"
echo "Run $ ./ngrok authtoken <YOUR_AUTH_TOKEN> which can be found here https://dashboard.ngrok.com/auth"
echo "And restart your terminal session or source ~/.bashrc."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment