8th of July, 2012
I've collected a set of instructions that I use when setting up a new VPS for running Drupal 7. I use VPS with Debian instead of the standard PHP hosting to gain more control of the hosting setup and also to be able to run other services, such as Apache Solr.
These instructions are for use on a freshly installed Debian Squeeze system. The setup is used for hosting a PHP website using Apache, MySQL and additional instructions for setting up Apache Solr. I run my websites on Drupal 7 and the instructions here should be good for any PHP based site.
Why Debian? I've been using a lot of different Linux distributions, from Slackware in 1999 to SuSE, RedHat, Gentoo etc. I've also been using Ubuntu some years back, and while Ubuntu is good for desktop, I started out with that for my VPS systems. However, the distributions update quite often and I decided to go with what Ubuntu is based on, namely Debian. Debian is a distribution focusing on stability and in-frequent changes, this is exactly what I need since I have limited time to keep the systems up to date.
apt-get update apt-get install patch rsync curl python ssmtp vim php5-curl php5-gd php-apc libapache2-mod-php5 mysql-server php5-mysql
export PATH=$PATH:/root/tools/drush export EDITOR=vim
Add following line to /etc/apache2/httpd.conf:
Edit /etc/apache2/sites-available/default to reflect hosting directory and to remove "AllowOverwrite None" Enable modrewrite:
Now create hosting directories. I keep my site under /var/Sites:
mkdir /var/Sites/yourdomain-prod/www chown www-data:www-data /var/Sites/yourdomain-prod/www
CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'yourpassword'; GRANT ALL PRIVILEGES ON youruser.* TO 'youruser'@localhost IDENTIFIED BY 'yourpassword'; flush privileges; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON yourdb.* TO 'youruser'@'localhost' IDENTIFIED BY 'yourpassword';
memory_limit = 256M allow_call_time_pass_reference = On (for Drupal) Change upload size limit to 20Mb: upload_max_filesize = 20M post_max_size = 20M
edit /etc/php5/conf.d/apc.ini and make it contain:
extensioion=apc.so apc.enabled="1" apc.filters="-/vote/.*" (drupal specific) apc.shm_size="96"
hostname=yourdomain.com FromLineOverride=YES UseTLS=YES UseSTARTTLS=YES AuthUser=
crontab -e:to edit the crontab.
2 * * * * curl --silent --compressed http://yourdomain.com/cron.php?cron_key=
Install Tomcat and download Solr:
apt-get install tomcat6 tomcat6-admin wget http://mirror.nohup.it/apache//lucene/solr/3.6.0/apache-solr-3.6.0.tgz
Then follow the Solr install instructions found here: http://pabloseminario.com/2011/02/22/installing-solr-on-debian-6-0/
Restrict the ip range of the apps to certain ip, make /etc/tomcat6/Catalina/localhost/ROOM.xml contain:
<Context path="/" antiResourceLocking="false"> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.0\.0\.1"/> </Context>
Then copy ROOT.xml to solr.xml and change path to ="/solr". Now, copy schema configuration file from drupal module:
cd /var/lib/tomcat6/solr/conf mv schema.xml schema.bak mv solrconfig.xml solrconfig.bak mv protwords.txt protwords.bak cp /var/Sites/yourdomain-prod/www/sites/all/modules/apachesolr/schema.xml . cp /var/Sites/yourdomain-prod/www/sites/all/modules/apachesolr/solrconfig.xml . cp /var/Sites/yourdomain-prod/www/sites/all/modules/apachesolr/protwords.txt .
# Each day 0 0 * * * /usr/sbin/apticron comments powered by Disqus