Skip to content

Instantly share code, notes, and snippets.

@RyanParsley
Last active May 9, 2017 16:15
Show Gist options
  • Select an option

  • Save RyanParsley/7c0461a28d2b7facfd68a1d5fcb6637a to your computer and use it in GitHub Desktop.

Select an option

Save RyanParsley/7c0461a28d2b7facfd68a1d5fcb6637a to your computer and use it in GitHub Desktop.
Notes on installing Drupal via the command line

Pro tip: Drupal installation

Set up your database

Before running the drush install script, create a mysql database and user with access to it.

Set up a vhost

sudo vim /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName cws.sunrun.dev
  DocumentRoot /Users/ryan.parsley/Sites/sunrun-sunrun-corp/docroot
  ErrorLog "/private/var/log/apache2/cws.sunrun.dev-error_log"
  CustomLog "/private/var/log/apache2/cws.sunrun.dev-access_log" common
  <Directory /Users/ryan.parsley/Sites/sunrun-sunrun-corp>
    AllowOverride All
  </Directory>
</VirtualHost>

Update your hosts file

sudo vim /etc/hosts

Add a new entry like:

127.0.0.1 drupal-test.dev

Download drupal core via composer

composer create-project acquia/lightning-project MY_PROJECT
cd MY_PROJECT/docroot

Use Drush to install the site

Note that I pass flags with db, user and password below. You'll need to customize the site-install line.

drush site-install standard --db-url='mysql://drupalTest:drupalTest@localhost/drupal-test' --site-name=Example --account-name=ryan --account-pass=drupalTest

Tweak config (hopefully optional, but I had to)

Something about my mySQL set up forced me to update the host value in the following file. I had to change localhost to 127.0.0.1 then all was well.

sites/default/settings.php

Update file permissions

chmod -R 777 sites/default/files

May want to clear cache for good measure

Since we have to manually adjust write permission to the files directory, and that's where all sorts of theming goodness is built, you probably have broken website until the next cron job runs.

drush cache-rebuild

Profit

Congratulations, you installed Drupal!

Prerequisites

Here are a few tasks you'll need to do before setting up Drupal if you haven't yet.

Install Drush

Drush is one of the killer features of drupal. Be sure to install that right away if you haven't already.

Raise memory limit for composer

The default is 128M which was not enough. Check your limit with php -r "echo ini_get('memory_limit').PHP_EOL;"

If you haven't adjusted yours in the past, update memory_limit in your php.ini.

My file was found at /usr/local/etc/php/5.6/php.ini

If you don't know where your php.ini file is, run php --ini

Set your timezone in php.ini

See above for how to locate your file, there is a timezone field commented out by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment