Drupal

From OLPC
Revision as of 01:12, 7 January 2008 by Grugnog (talk | contribs)
Jump to: navigation, search

Why do this?

Well, here are 3 reasons:

* The XO is cool
* Drupal is cool
* XO + Drupal = righteous!

More seriously, this could let a community of XOers write books, blog, vote, arrange events and store/list structured content and do all the great community centric things that Drupal allows.

This HOWTO uses Lighttpd instead of Apache, because it is much more lightweight. I considered using SQLite instead of MySQL, but after testing found that MySQL was perfectly fast enough (and makes using contributed modules much easier). Having said that, you wouldn't want to use this for serving more than a handful of clients on a regular XO!

Installing software

Start the 'Terminal' activity (on the far right of the menu bar).

Get root access:

su

You should now see a prompt that looks like:

bash-3.2#

Install the various tools we will need:

yum install mysql mysql-server lighttpd lighttpd-fastcgi php php-mysql php-gd

Basic Configuration

Give MySQL a root password:

mysqladmin -u root password YOUR-ROOT-MYSQL-PASSWORD

Go to the /etc directory:

cd /etc/

Edit the php.ini file (with your favorite editor):

nano php.ini

Add the following line to the very bottom of the file:

cgi.fix_pathinfo = 1

Edit the lighttpd configuration file and enable FastCGI:

nano lighttpd/lighttpd.conf
  • Uncomment "mod_fastcgi" line, in the server.modules section
  • Uncomment the fastcgi.server section (all ~8 lines of it)

XO Friendly MySQL Configuration

Copy in the low memory configuration template:

cp /usr/share/mysql/my-small.cnf /etc/my.cnf

Uncomment the following lines:

skip-networking
skip-bdb

In the section [mysqld] add the line:

skip-innodb

Service Startup

It is recommended that you start the services manually when you (or your friends!) want to use Drupal, but it would be easy to adapt this to autostart if you want. This will save some memory, so your system will run faster the rest of the time.

Note: the /var filesystem appears to not persist over reboots (perhaps it is ROM based - there may be a way round this, I haven't found one yet), and so we need to recreate and reown the appropriate directories for these services to start.

Go to the root users home directory:

cd /root

Start editing a new file:

nano start-web.sh

Type the following:

#!/bin/sh
mkdir /var/run/lighttpd /var/log/lighttpd
chown lighttpd:lighttpd /var/run/lighttpd /var/log/lighttpd
mkdir /var/run/mysqld
chown mysql:mysql /var/run/mysqld
/etc/init.d/lighttpd start
/etc/init.d/mysqld start

Make the script executable, and run it to check everything starts up OK:

chmod u+x start-web.sh
./start-web.sh

When you are done, start the 'Browse' activity, and go to the URL 'localhost' - you should see the lighttpd placeholder page.

After a reboot, when you want to use Drupal just type:

su -c /root/start-web.sh

Install Drupal

Switch back to the Terminal activity, and change to the web root directory:

cd /srv/www/lighttpd/

Clean it up, and change ownership:

pwd
rm *
chown olpc:olpc .

Switch back to our regular (non-root) user, and go to our home directory:

exit
cd ~

Download and extract Drupal (replace x.x with the latest Drupal stable version, currently 5.5):

wget http://drupal.org/files/projects/drupal-x.x.tar.gz
tar -zxvf drupal-x.x.tar.gz

Move the contents of the drupal-x-x directory into the webroot:

mv drupal-x.x/* drupal-x.x/.htaccess /srv/www/lighttpd/

Change to the web root directory, create a files directory (for uploads) and adjust permissions on this and the settings.php file:

cd /srv/www/lighttpd/
mkdir files
chmod a+w files
chmod a+w sites/default/settings.php

Follow the regular Drupal installation process:

And you are all set - congratulations!