Monday, October 11, 2010

Installing Drupal 7 on a fresh Ubuntu 10.10 (Maverick Meerkat) box

This is a simple step by step instruction for installing Drupal 7 on a clean Ubuntu server edition slate. Canonical let's you try those out for an hour for free on Amazons cloud.

Configure Server  

After you have logged in via SSH (use Putty on Windows) go ahead and install some stuff:

sudo apt-get install apache2 php5-gd libapache2-mod-php5 mysql-server mysql-client php5-mysql cvs

You will be prompted for the MySQL root password. Type one and remember it, for example supersecretpw, which you can then use to log in to mysql:

mysql -uroot -psupersecretpw

Now it's time to create a database and a user who can access it, what you have to type is highlighted:

mysql> create database d7db;
Query OK, 0 rows affected (0.00 sec)
mysql> create user d7user identified by 'd7password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on d7db.* to 'd7user'@'localhost' identified by 'd7password';
Query OK, 0 rows affected (0.00 sec)
mysql> exit;

Alright, the webserver and database server are up and running now. Sweet. You can check the webserver by going to your domain or IP in a browser and you'll see the default apache index.html which we don't need, so we can delete it (replace ubuntu in line 4 with your username from line 2):

cd /var
sudo chown -R ubuntu:www-data www
rm www/index.html

Install Drupal 

We can get the latest and greatest Drupal version from CVS (Replace DRUPAL-7-0-BETA1 with the version you want):

cd /var
cvs -z6 co -r DRUPAL-7-0-BETA1 -P -d www/ drupal

Well done! Configure the Drupal settings to use the database we created (also create the server writeable files directory):

cd /var/www/sites/default/
cp default.settings.php settings.php
mkdir files
sudo chown www-data files

Edit settings.php for exmaple with pico or vim:

pico settings.php

replace this line

$databases = array();

with this:

$databases['default']['default'] = array(
   'driver' => 'mysql',
   'database' => 'd7db',
   'username' => 'd7user',
   'password' => 'd7password',
   'host' => 'localhost',
   'prefix' => '',
   'collation' => 'utf8_general_ci',

Save the file. I had to reload apache so it would handle the php files correctly:

sudo apachectl restart

That's about it. you can now run the drupal install script by going to the ip or domain and opening install.php for example:

Bonus points - enable clean URLs

sudo a2enmod rewrite
sudo pico /etc/apache2/sites-available/default

in this section:
<directory /var/www/>
AllowOverride None
AllowOverride All

Restart apache: 

sudo apachectl restart

Now you can enable clean URLs at: 

More bonus points - use APC

sudo apt-get install apache2-threaded-dev php5-dev php-pear make
sudo pecl install apc
sudo echo "" >> /etc/php5/apache2/php.ini
sudo apachectl restart


Anonymous said...

"in this section:

AllowOverride None
AllowOverride All"

Which section?

Eike Send said...

Thx, fixed, the editor interpreted the line as html and thus it was not displayed...

Anonymous said...

great stuff, thx...

Unknown said...

Just wanted to say thank for a great write up. As someone new to Ubuntu 10.10, it helped me a lot.

f4jrin said...

thank you very much for this helpfull tutorial....

Daffie said...

Thank you! This solved my problem :)

Anonymous said...

I'm tempted to kiss you... thanks for including APC. been fighting with it all day.

Anonymous said...

Thanks for your work
Its a good stuff


Eats Wombats said...

You may not want to bother with APC unless you can find better info first:

Anonymous said...

Thank you!

Siegfried Grimbeek said...

Very Helpful Thanks a lot man!!!

Anonymous said...

Thousand thanks! Could you include phpmyadmin in the tutorial?