#!/bin/bash ############################################################## # # # Digital Ocean / Forge Recipe for CraftCMS websites # # # #============================================================# # # # Assumptions: # # # # - Stock Ubuntu 16.04 Digital Ocean droplet # # - You are running this recipe as root # # # #============================================================# # # # References & Credits: # # # # Thanks to Andrew Welch & @nystudio107 folks. This recipe # # rely heavily on their articles. # # # # Much of this was lifted from Rodrigo Passos: # # https://gist.github.com/webrgp/ # # fe13d7c61420632f85d5d81e76538fce # # # ############################################################## # Exit immediately if a simple command exits with a non-zero status (https://ss64.com/bash/set.html) set -e perform_craftcms_server_setup() { # Check if the user is root user="$(id -un 2>/dev/null || true)" if [ "$user" != 'root' ]; then cat >&2 <<-'EOF' Error: this installer needs the ability to run commands as root. We are unable to find either "sudo" or "su" available to make this happen. EOF exit 1 fi # Create a playground directory to be remove at the end mkdir ~/playground cd ~/playground # Install Digital Ocean Monitoring tools curl -sSL https://agent.digitalocean.com/install.sh | sh # Make sure you have tools in place apt-get -y install autoconf automake libtool nasm make pkg-config git build-essential # Install the latest Node.js (version 8.x as of writing) # https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04 curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt-get install nodejs # Install Yarn curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list apt-get update && apt-get -y install yarn # Install the PHP ImageMagick Extension # https://serverpilot.io/community/articles/how-to-install-the-php-imagemagick-extension.html # Replace version number in commands below accordingly (version 7.1 as of writing) apt-get -y install gcc make autoconf libc-dev pkg-config apt-get -y install libmagickwand-dev printf "\n" | pecl7.1-sp install imagick # When prompted with: # Please provide the prefix of Imagemagick installation [autodetect] : # just press Enter; do not type a prefix (that is, allow autodetect). # adding the prefix: printf "\n" will do this automatically. Example: # printf "\n" | pecl7.1-sp install imagick # Now tell PHP about it: sudo bash -c "echo extension=imagick.so > /etc/php7.1-sp/conf.d/imagick.ini" sudo service php7.1-fpm-sp restart # Install jpegoptim, optipng, gifsicle, svgo & webp ( https://nystudio107.com/blog/creating-optimized-images-in-craft-cms ) apt-get -y install jpegoptim apt-get -y install optipng apt-get -y install gifsicle apt-get -y install webp npm install -g svgo # Install Gulp for running build process npm install gulp -g # FOR REVIEW/MODIFICATIONS LATER: # Install the nginx partials from https://github.com/nystudio107/nginx-craft # git clone https://github.com/nystudio107/nginx-craft.git nginx-craft # cp -R nginx-craft/nginx-partials /etc/nginx # Clean up playground cd ~ rm -rf ~/playground }