How to log drush commands

Here's a way I came up with for logging drush commands. This might be useful for troubleshooting server slowness.

Add the following block of code to the start of the drush command:

# Rangi: Log all drush commands
LOG_STR=`date --rfc-3339=seconds`
LOG_STR="$LOG_STR drush"
for a in ${BASH_ARGV[*]} ; do
LOG_STR="$LOG_STR $PARAMS (`whoami`)"
echo $LOG_STR >>/var/log/drush

This will add lines like this to /var/log/drush:

ELK server setup



Install Compass and Sass on Ubuntu

Here are the commands to install both Compass and Sass.

sudo apt-get install curl

gpg2 --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

curl -sSL | bash -s stable

source /etc/profile.d/

rvm requirements

rvm install ruby-latest

gem install compass

gem install sass

gem install bootstrap-sass


Set up Redis

Installing Redis

In Ubuntu, you can run the following command to install Redis.

tar xvzf redis-stable.tar.gz
cd redis-stable

It is a good idea to copy both the Redis server and the command line interface in proper places, either manually using the following commands:

How To Add Swap on Ubuntu

When you run some composer commands, you may see an error message like "The following exception is caused by a lack of memory or swap, or not having swap configured". So how to config swap? Here is a few steps you can follow to config and switch on swap.

step1: there are commands to check if any swap exists.

Multiple git accounts require different ssh keys

If you have 2 BitBucket git accounts, you are not allowed to use the same ssh key in both accounts. As we know, you will keep receiving an error message without ssh key set up correctly.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

To fix it, you need config ssh and git remote. Here are the steps:

step1: you need create a config file under .ssh

Enabling Clean URLs for Drupal in Ubuntu 14.04 LTS

In the newer versions of Ubuntu, the Apache config has changed just enough to make me re-do a bunch of stuff when setting up a new Drupal install. Here is the way I was able to enable Clean URLs from a base Ubuntu 14.04 LTS LAMP install:

  • Enable mod_rewrite for Apache
    # a2enmod rewrite
  • Add AllowOverride within the default website configuration
    # vi /etc/apache2/sites-available/000-default.conf

    Add just under DocumentRoot /var/www/html

Screen commands

In Linux, screen commands help a lot. Here is some common commands about it.

1. Create a new screen


2. Show all existed screens

screen -list

3. Recover screen

screen -r [screen_id]

4. Leave screen shortcut: Ctrl + A +D

5. Kill screen

screen -X -S [session # you want to kill] quit


Set up drupal with git

You can now provision your other tiers with this code from the repository.

Log into your server and provision a development environment from the code you’ve committed:

git clone --branch fooproject ssh:// fooproject_dev