Installing and configuring a fresh Ubuntu 14.04 server to host multiple Drupal websites

Here is the procedure that I normally follow for installing and configuring a fresh Ubuntu 14.04 server to host multiple Drupal websites:

Login as root, and run the following commands:

apt-get update
apt-get upgrade
apt-get autoremove
shutdown -r now

Add a new user to host the Drupal websites:

adduser USERNAME

Grant sudo permissions.:

sudo usermod -a -G sudo USERNAME

Then login as that user, and run the rest of the steps listed below.

Install latest git from official PPA:

sudo apt-get remove git git-core git-man
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git-core

Configuring Git

git config --global color.ui true
git config --global user.name "Drupal Admin"
git config --global user.email "drupaladmin@domainname.com"

Then install PHP5 support for Apache:

sudo apt-get install php5

Configure Apache for Drupal:

sudo a2enmod rewrite
sudo a2enmod userdir
sudo service apache2 restart
sudo mkdir -p /etc/skel/public_html
sudo mkdir -p /etc/skel/logs
mkdir ~/public_html
mkdir ~/logs
sudo apt-get install dbconfig-common libaio1 libdbd-mysql-perl libdbi-perl \
  libhtml-template-perl libmysqlclient18 libterm-readkey-perl mysql-client \
  mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server \
  mysql-server-5.5 mysql-server-core-5.5 php5-gd php5-mysql postfix \
  wwwconfig-common phpmyadmin

Give it the following inputs when it asks for these:
MySQL root password: somestrongpassword
Postfix Configuration: Internet Site
Postfix Configuration - System mail name: domainname.com

To install PECL uploadprogress:

sudo apt-get install php-pear
sudo apt-get install build-essential php5-dev
sudo pecl install uploadprogress
sudo sh -c 'echo "; activate and configurate for php uploadprogress module" >>/etc/php5/mods-available/uploadprogress.ini'
sudo sh -c 'echo "extension=uploadprogress.so" >> /etc/php5/mods-available/uploadprogress.ini'
sudo ln -s /etc/php5/mods-available/uploadprogress.ini /etc/php5/apache2/conf.d/20-uploadprogress.ini
sudo service apache2 restart

To fix the error "apache2: Could not reliably determine the server's fully qualified domain name, using..."

... that shows up when restarting apache, do the following:

echo "ServerName DOMAINNAME.COM" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
sudo service apache2 restart

Enable PHP in user directories (such as ~/public_html):

Run the following command to open up the corresponding config file for editing:

sudo vim /etc/apache2/mods-available/php5.conf

and comment out the following lines by adding a hash symbol '#' to the start of each line:

    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_flag engine Off
        </Directory>
    </IfModule>

such that the lines now look as follows:

    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_flag engine Off
    #    </Directory>
    #</IfModule>

Allow .htaccess files to override any apache server option under ~/public_html:

Open up the file for editing:

sudo vim /etc/apache2/mods-available/userdir.conf

and change the line that says:

AllowOverride FileInfo AuthConfig Limit Indexes

to

AllowOverride All

Save and exit.

Restart apache:

sudo service apache2 restart

Install Drush

First install Composer globally:

mkdir -p /tmp/composer/install
cd /tmp/composer/install
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer

then install Drush with it:

sudo git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush
sudo ln -s /usr/local/src/drush/drush /usr/bin/drush
sudo composer install
sudo composer update
drush --version

To add a new Drupal website to host, do the following:

Add apache virtualhost config file.
Add entries to /etc/hosts.

Add new comment

randomness