Insight | Apr 8, 2016
Getting Set Up for Drupal Development without the Headaches
By Marie Kiryanova
We've all been there: you get a fresh new machine and need to be ready to work as soon as possible. You have a few options:
- Panic and install everything manually, hoping you configure everything properly.
- Run the following script (if you're on OS X or Ubuntu/Debian) and grab a warm beverage of your choice while your machine configures itself for Drupal development.
- If you're not on one of the aforementioned platforms, follow our steps and translate them for use on your platform.
Give me the one-liner
This script was tested on fresh machines with either OS X El Capitan 10.11 or Ubuntu 14.04 LTS. It encompasses steps 0 through 3 outlined below. Skip to step 4 to see how to power up your first VM. Run the following in a bash-compatible shell:
bash <(curl -s https://raw.githubusercontent.com/PavelAK/drupal-setup/master/setup.sh)
Step 0: Platform-specific recommendations
Mac OS X
On OS X we can install many tools through Homebrew, a very useful utility for installing a wide range of open source tools in a *nix-like manner. Install with the following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Follow the on-screen directions to complete this process. After installing Homebrew we can tap into a useful source in Homebrew called Cask. This will allow us to install a wide variety of applications like Vagrant and VirtualBox through the command line instead of clicking through wizards. You can "tap" into Cask with the following:
brew tap caskroom/cask
Debian-based Linux (Ubuntu/Mint)
We need git to be installed for things to run smoothly:
sudo apt-get install git -y
Step 1: Installing Vagrant
Development at Third & Grove is typically started from one of our base Vagrant boxes, which we have for both Drupal 7 and Drupal 8. This makes Vagrant the most important thing for us to install.
Mac OS X
brew cask install virtualbox brew cask install vagrant vagrant plugin install vagrant-hostsupdater
Debian-based Linux (Ubuntu/Mint)
sudo apt-get install virtualbox vagrant -y vagrant plugin install vagrant-hostsupdater
Step 2: Installing PHP and dependencies
We choose to install PHP 5.6, as this matches our target environment of Acquia's servers.
Mac OS X
Through the power of dependencies, we can install the one dependency we need in our local PHP install, and PHP 5.6 is installed for us.
brew install homebrew/php/php56-memcached brew install mysql
Debian-based Linux (Ubuntu/Mint)
sudo apt-get install php5-mysql php5 php5-memcached memcached -y
Step 3: Installing Composer and Drush
Composer and Drush are both valuable tools in a Drupal environment. We use Drush when we set up our local websites and operate on remotes. It makes life easier by allowing you to run commands such user-login or cache-rebuild and more that you use on a daily basis in Drupal development.
OS X and Debian-based Linux
Both platforms share this step. However, on OS X there is no need to sudo for the final command, as the permissions in /usr/local/bin are loosened thanks to Homebrew.
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer composer global require drush/drush:dev-master sudo ln -s $HOME/.composer/vendor/bin/drush /usr/local/bin/drush
After you're done you can check your work by running the following:
parallels@ubuntu:~$ drush status PHP executable : /usr/bin/php PHP configuration : /etc/php5/cli/php.ini PHP OS : Linux Drush script : /home/parallels/.composer/vendor/drush/drush/drush.p hp Drush version : 9.0-dev Drush temp directory : /tmp Drush configuration : Drush alias files :
If your output is similar then you're ready to tackle powering on your first development VM.
Step 4: Powering on the Drupal 8 VM
So we're ready for development. Let's boot our first VM.
OS X and Debian-based Linux
The two platforms work similarly in this step as well.
# Clone the repo. git clone https://github.com/thirdandgrove/tagd8-vagrant.git cd tagd8-vagrant # Download core. drush dl drupal cd drupal-* mv * .* .. cd .. rm -r drupal-* # Configure Vagrant cd private cp example.config.yml config.yml # Optionally edit config.yml nano config.yml # Power up Vagrant vagrant box add ubuntu/trusty64 https://atlas.hashicorp.com/webysther/boxes/gitlab-ce-ubuntu-x64-14.04/versions/1.0/providers/virtualbox.box vagrant up # Once that finishes, complete Drupal set up. cd .. drush site-install --account-name=CLEVERADMINNAME --account-pass=CHANGEMEPLS -y
Now navigate to your domain declared in config.yml, and you should be greeted with vanilla Drupal 8.
Drop us a line
Have a project in mind?
Contacting Third and Grove may cause awesomeness. Side effects include a website too good to ignore. Proceed at your own risk.