Skip to content

Instantly share code, notes, and snippets.

@jameslutley
Forked from mikestecker/server-setup.sh
Created April 16, 2019 04:35
Show Gist options
  • Select an option

  • Save jameslutley/c6f4a260fe656606f8090a839576024f to your computer and use it in GitHub Desktop.

Select an option

Save jameslutley/c6f4a260fe656606f8090a839576024f to your computer and use it in GitHub Desktop.

Revisions

  1. @mikestecker mikestecker revised this gist Nov 13, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -55,6 +55,11 @@ EOF
    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)
  2. @mikestecker mikestecker revised this gist Nov 10, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    For Buddy to be able to update NGINX and run other commands as root, you need to follow these steps to give the user buddy access.

    If no user has been created, follow the guide here to create a user for Buddy:
    https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-ubuntu-16-04

    1. On ubuntu based systems, run " $ sudo visudo "
    2. this will open /etc/sudoers file.
    3. If your buddy user is already in that file, then modify to look like this:
  3. @mikestecker mikestecker revised this gist Nov 10, 2017. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    For Buddy to be able to update NGINX and run other commands as root, you need to follow these steps to give the user buddy access.

    1. On ubuntu based systems, run " $ sudo visudo "
    2. this will open /etc/sudoers file.
    3. If your buddy user is already in that file, then modify to look like this:

    buddy ALL=(ALL) NOPASSWD: ALL
    4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite)
    5. Exit by doing Ctrl+X
    6. Relaunch your buddy job
    7. you shouldnt see that error message again :)
  4. @mikestecker mikestecker revised this gist Nov 10, 2017. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -45,12 +45,6 @@ EOF

    # Install Digital Ocean Monitoring tools
    curl -sSL https://agent.digitalocean.com/install.sh | sh

    # Create a new user, give it sudo and put in serverpilot + sp-sysusers group
    # CAREFUL!
    usermod -aG sudo ubuntu
    usermod -aG serverpilot ubuntu
    usermod -aG sp-sysusers ubuntu

    # Make sure you have tools in place
    apt-get -y install autoconf automake libtool nasm make pkg-config git build-essential
  5. @mikestecker mikestecker revised this gist Nov 10, 2017. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -46,9 +46,11 @@ EOF
    # Install Digital Ocean Monitoring tools
    curl -sSL https://agent.digitalocean.com/install.sh | sh

    # Let's give the serverpilot user sudo
    # BE CAREFUL WITH THIS!
    sudo usermod -aG sudo serverpilot
    # Create a new user, give it sudo and put in serverpilot + sp-sysusers group
    # CAREFUL!
    usermod -aG sudo ubuntu
    usermod -aG serverpilot ubuntu
    usermod -aG sp-sysusers ubuntu

    # Make sure you have tools in place
    apt-get -y install autoconf automake libtool nasm make pkg-config git build-essential
  6. @mikestecker mikestecker revised this gist Nov 9, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ EOF

    # Let's give the serverpilot user sudo
    # BE CAREFUL WITH THIS!
    sudo usermod -a -G sudo serverpilot
    sudo usermod -aG sudo serverpilot

    # Make sure you have tools in place
    apt-get -y install autoconf automake libtool nasm make pkg-config git build-essential
  7. @mikestecker mikestecker revised this gist Nov 9, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -45,6 +45,10 @@ EOF

    # Install Digital Ocean Monitoring tools
    curl -sSL https://agent.digitalocean.com/install.sh | sh

    # Let's give the serverpilot user sudo
    # BE CAREFUL WITH THIS!
    sudo usermod -a -G sudo serverpilot

    # Make sure you have tools in place
    apt-get -y install autoconf automake libtool nasm make pkg-config git build-essential
  8. @mikestecker mikestecker revised this gist Nov 9, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -82,7 +82,7 @@ EOF
    # Install Gulp for running build process
    npm install gulp -g

    # FOR REVIEW/MODIFACTIONS LATER:
    # 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
  9. @mikestecker mikestecker created this gist Nov 9, 2017.
    94 changes: 94 additions & 0 deletions server-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    #!/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 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/MODIFACTIONS 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
    }