There are a number of ways to setup Drupal on you development box. Below are a list of the steps I use when creating a new project. If you're doing professional work in Drupal, you'll probably be developing for multiple websites. This configuration will allow for multiple sites, Drupal and otherwise. I'll also outline setting up Eclipse, xdebug and various server utilities you may need for testing configurations in your dev environment.
sudo apt-get update
sudo apt-get install lamp-server^
sudo apt-get install apache2
sudo apt-get install mysql-server mysql-client
sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install php5-common php5-mysql
/etc/init.d/apache2 restart
sudo apt-get install php5-gd
sudo apt-get install php-pear
sudo apt-get install php5-cli
cd ~/ wget http://ftp.drupal.org/files/projects/drush-7.x-4.5.tar.gz #extract to home directory tar -zxvf drush-7.x-4.5.tar.gz rm drush-7.x-4.5.tar.gz #add path to your bash profile: echo 'PATH=$PATH:~/drush' >> ~/.bashrc
sudo apt-get install git-core
cd ~/ mkdir www
sudo gedit /etc/hosts
127.0.0.1 localhost.drupal7
cd /etc/apache2/sites-available sudo gedit localhost.drupal7
<VirtualHost *:80> ServerAdmin email_address ServerName localhost.drupal7 DocumentRoot /home/[username]/www/localhost.drupal7 <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost>
sudo a2ensite localhost.drupal7
sudo gedit /etc/apache2/httpd.conf
sudo a2enmod rewrite
sudo /etc/init.d/apache2 reload sudo /etc/init.d/apache2 restart
Create MySQL Database for Drupal Installation
mysql -u root -p create database localhost_drupal7; create user 'drupal7'@'localhost' identified by 'password'; grant all privileges on localhost_drupal7.* to drupal7@localhost; quit
#!/bin/sh if [ ! -d ~/backups ]; then mkdir ~/backups fi mysqldump -u root -p localhost_drupal7 > /tmp/localhost_drupal7.sql cd ~/backups tar --create --gzip --absolute-names --preserve-permissions --file=db-backup-localhost_drupal7-`date +"%b_%d_%Y_%r"`.tar.gz -C /tmp localhost_drupal7.sql
Setting up the PHP Mail Function
sudo apt-get install postfix
sudo pear install mail sudo pear install Net_SMTP sudo pear install Auth_SASL sudo pear install mail_mime
Install Drupal 7 with Drush from Git
cd ~/www drush --package-handler=git_drupalorg --drupal-project-rename=localhost.drupal7 dl drupal-7.12
Create Drupal Site Configuration and Populate Database
cd ~/www/localhost.drupal7 drush site-install standard --site-name="Local Drupal7" --site-mail=yourmail@email.com \ --account-name=root --account-pass=password \ --db-url=mysql://drupal7:password@localhost/localhost_drupal7
drush dl views drush dl cck drush dl zen drush dl devel drush dl entity drush dl ctools
cd ~/www/localhost.drupal7/sites/default chmod 666 files
sudo gedit /etc/apache2/ports.conf
sudo gedit /etc/apache2/sites-available/localhost.drupal7 sudo gedit /etc/apache2/sites-available/default
sudo apt-get install varnish
sudo cp /etc/varnish/default.vcl /etc/varnish/default_vcl.txt sudo cp /etc/default/varnish /etc/default/varnish.txt
sudo mkdir /var/lib/varnish/drupal7 sudo chown -R varnish.varnish /var/lib/varnish/drupal7
sudo gedit /etc/default/varnish
START=yes INSTANCE=drupal7 DAEMON_OPTS="-a :80 \ -T localhost.drupal7:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -u varnish -g varnish \ -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,250MB"
sudo gedit /etc/varnish/default.vcl
backend default {
.host = "localhost.drupal7";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
sudo /etc/init.d/varnish restart
sudo apt-get install memcached libmemcached-dev php-pear php5-dev build-essential apache2-threaded-dev
sudo pecl install memcache sudo pecl install memcached
cd /etc/php5/apache2/ sudo gedit php.ini
[memcache] extension = memcache.so extension = memcached.so memcache.hash_strategy="consistent"
sudo service apache2 restart
memcached -m 24 -p 11211 -d
sudo gedit /var/www/mctest.php
<?php
$memcache = new Memcache;
$memcache->addServer('127.0.0.1', 11211) or die ("Could not connect");
$memcache->set('mytestvariable', "this is the data in my test variable", false, 60) or die ("Unable to save the data to the server");
echo "Data has been stored in the cache";
$result = $memcache->get('mytestvariable');
echo "Retrieved data from the server:";
var_dump($result);
?>
cd ~/www/localhost.drupal7 drush dl memcache
sudo gedit sites/default/settings.php
<?php
// Memcache ----
// the path to the core cache file
include_once('./includes/cache.inc');
// the path to the memcache cache file
include_once('./sites/all/modules/memcache/memcache.inc');
// make MemCacheDrupal the default cache class
$conf = array(
'cache_default_class' => 'MemCacheDrupal',
'memcache_servers' => array('127.0.0.1:11211' => 'default'),
'memcache_bins' => array('cache' => 'default')
);
?>
drush -y en memcache_admin
sudo gedit /etc/php5/cli/php.ini
[memcache] extension=memcache.so
APC (Alternative PHP Cache) Installation
sudo apt-get install php-apc
apache2ctl restart
php -m | grep apc
sudo apt-get update && apt-get upgrade sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples sudo apt-get install libmysql-java
cd ~/ wget -c http://apache.mirrors.pelicantech.com//lucene/solr/3.5.0/apache-solr-3.5.0.zip unzip apache-solr-3.5.0.zip sudo cp ~/apache-solr-3.5.0/dist/apache-solr-3.5.0.war /var/lib/tomcat6/webapps/solr.war sudo cp -R ~/apache-solr-3.5.0/example/solr/ /var/lib/tomcat6/solr/
sudo gedit /etc/tomcat6/Catalina/localhost/solr.xml
<Context docBase="/var/lib/tomcat6/webapps/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/var/lib/tomcat6/solr" override="true" /> </Context>
cd ~/www/localhost.drupal7 drush dl apachesolr
cd ~/www/localhost.drupal7/sites/all/modules/apachesolr/solr-conf sudo cp /var/lib/tomcat6/solr/conf/schema.xml schema_xml.bk sudo cp /var/lib/tomcat6/solr/conf/solrconfig.xml solrconfig.xml.bk
sudo cp schema.xml /var/lib/tomcat6/solr/conf/ sudo cp solrconfig.xml /var/lib/tomcat6/solr/conf/
cd /var/lib/tomcat6/solr/ sudo mkdir data sudo chown -R tomcat6:tomcat6 /var/lib/tomcat6/solr/data/
cd /var/lib/tomcat6/solr/ sudo gedit conf/solrconfig.xml
<dataDir>/var/lib/tomcat6/solr/data</dataDir>
cd /var/lib/tomcat6/conf sudo gedit server.xml
cd ~/www/localhost.drupal7 drush enable apachesolr apachesolr_search search cacherouter drush vset --yes apachesolr_port 8080 drush vset --yes apachesolr_cron_limit 50 drush vset --yes apachesolr_search_make_default 1 drush vset --yes apachesolr_search_spellcheck 1 #Number of items to index per cron run: drush vset --yes search_cron_limit 50
sudo /etc/init.d/tomcat6 restart
cd /tmp wget http://carroll.aset.psu.edu/pub/eclipse/eclipse/downloads/drops/R-3.7.1-201109091335/eclipse-SDK-3.7.1-linux-gtk.tar.gz tar zxvf eclipse-SDK-3.7.1-linux-gtk.tar.gz sudo mkdir /opt/conjunction sudo mkdir /opt/conjunction/php sudo mv /tmp/eclipse /opt/conjunction/php
cd '/opt/conjunction/php/eclipse/plugins/' wget http://iweb.dl.sourceforge.net/project/editbox/plugin/alpha/pm.eclipse.editbox_0.0.22.jar
#!/bin/bash
prog="$0"
if [ -n "$1" ]
then
selection="$1"
else
echo "usage: "`basename "$prog"`" eclipse_configuration"
fi
eclipse_command="/opt/conjunction/${selection}/eclipse/eclipse"
if [ ! -x "${eclipse_command}" ]
then
echo `basename "$prog"`": cannot find ${selection}"
exit 1
fi
eclipse_configuration="${HOME}/.conjunction/${selection}/config"
if [ ! -d "${eclipse_configuration}" ]
then
if [ -e "${eclipse_configuration}" ]
then
echo `basename "$prog"`": cannot create configuration directory ${eclipse_configuration}"
exit 1
else
mkdir -p "${eclipse_configuration}"
fi
if [ ! -d "${eclipse_configuration}" ]
then
echo `basename "$prog"`": failed to create configuration directory ${eclipse_configuration}"
fi
fi
eclipse_data="${HOME}/conjunction/${selection}"
if [ ! -d "${eclipse_data}" ]
then
if [ -e "${eclipse_data}" ]
then
echo `basename "$prog"`": cannot create data directory ${eclipse_data}"
exit 1
else
mkdir -p "${eclipse_data}"
fi
if [ ! -d "${eclipse_data}" ]
then
echo `basename "$prog"`": failed to create data directory ${eclipse_data}"
fi
fi
# start the appropriate eclipse
exec "${eclipse_command}" -configuration "${eclipse_configuration}" -data "${eclipse_data}"
./run_eclipse.sh php
cd ~ wget http://www.xdebug.org/files/xdebug-2.1.2.tgz tar zxvf xdebug-2.1.2.tgz cd xdebug-2.1.2 phpize ./configure --enable-xdebug make #This will produce a file called xdebug.so in the modules directory, so now we'll just copy this to the appropriate path (ls -al /usr/lib/php5/) sudo cp modules/xdebug.so /usr/lib/php5/20090626+lfs/ sudo chmod 644 /usr/lib/php5/20090626+lfs/xdebug.so
sudo gedit /etc/php5/apache2/php.ini #for the command line php: sudo gedit /etc/php5/cli/php.ini
[xdebug] xdebug.remote_enable=1 xdebug.remote_host="localhost" xdebug.remote_port=9000 xdebug.remote_handler="dbgp" zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
sudo /etc/init.d/apache2 restart
sudo gedit xdebug.php
<?php
$address = '127.0.0.1';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Unable to bind');
socket_listen($sock);
$client = socket_accept($sock);
echo "connection established: $client";
socket_close($client);
socket_close($sock);
?>
./run_eclipse.sh php
cd ~/www/localhost.drupal7 drush en syslog
# drupal loging if ($programname == 'drupal') and ($syslogseverity <= '6') and ($msg contains 'localhost.drupal7') then /var/log/websites/localhost.drupal7.log
mkdir /var/log/websites sudo vi /etc/rsyslog.d/drupal.conf sudo service rsyslog restart
$IncludeConfig /etc/rsyslog.d/*.conf
<?php watchdog('type, 'message'); ?>
<?php
try {
module_invoke_all('cron');
} catch (Exception $e) {
watchdog('cron', t('cron failed because ' . $e->getMessage()), WATCHDOG_ERROR);
}
?>