Home | Topics | Varnish


Printer-friendly versionPDF version

# First make sure the system is up to date.

sudo apt-get update

apt-get update
apt-get dist-upgrade

# A quick and dirty way of setting up a lot of dependencies:

apt-get install phpmyadmin mysql-server
hostname -i

# note your IP address above, and go to http://xxx.xxx.xxx.xxx/ should be if localhost on your laptop for instance!
# It works!


if problem with phpmyadmin, ie http://localhost/phpmyadmin error:

edit the file /etc/phpmyadmin/apache.config

in the bottom part of the doc there is this:

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
Require valid-user

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Require valid-user--------------------here there was as Deny from All---------------
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Require valid-user--------------------same as above--------------------------------


Does /etc/apache2/conf.d/phpmyadmin.conf exist? If not, does /etc/phpmyadmin/apache.conf exist?

If phpmyadmin.conf exists, then you can try to remove it: sudo rm phpmyadlin.conf

If the first doesn't exist and the second does, try:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 restart

cd /var/www
rm index.html
echo '<?php phpinfo();' > info.php
/etc/init.d/apache2 restart

# Now go to http://xxx.xxx.xxx.xxx/info.php
# phpinfo() is cool!
# Now we'll get a git checkout of pressflow

apt-get install git-core
cd /var
rm -Rf www
git clone git://github.com/pressflow/6.git www
cd /var/www
echo '<?php phpinfo();' > info.php

# Restore our phpinfo(); file.

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

apt-get install postfix

# postfix is a mail server; so drupal can email account info to us

mysql -u root or

mysql -h -u root -p




Create a mysql database




mysql> CREATE DATABASE database1;



Create a mysql user

For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

For creating a new user with fewer privileges (should work for most web applications) which can only use the database named "database1", at mysql prompt type:






# In mysql, create a database for the drupal site.
# Then go to http://xxx.xxx.xxx.xxx/install.php
# Use root user, no pass and that database to get an install working.

a2enmod rewrite
/etc/init.d/apache2 restart

# Enabling mod_rewrite for Apache allows us to use clean urls.
# Now let's set up Drush:

apt-get install php5-cli
cd /opt/
git clone --branch 7.x-4.x http://git.drupal.org/project/drush.git
ln -s /opt/drush/drush /usr/local/bin/drush

# Drush lives in /opt, is symlinked into /usr/local/bin so we can use it.

sudo apt-get install drush

cd /var/www/
drush status

# Verify that Drush works by running drush status.

nano /etc/php5/cli/conf.d/mcrypt.ini

# Fix the first comment line in this ini file to get rid of warning message.

cd /var/www/
drush dl devel
drush en -y devel devel_generate

# Now we went back to the Drupal admin interface and used devel_generate.
# We created 50 users, 50 categories and 50 nodes with some comments.

# Now, baseline benchmarking with no caching at all:

ab -n 1000 -c 30 http://xxx.xxx.xxx.xxx/

# Now for APC:
cd /var/www
apt-get install php-apc
cp /usr/share/doc/php-apc/apc.php.gz ./
gunzip apc.php.gz
/etc/init.d/apache2 restart

# Now visit http://xxx.xxx.xxx.xxx/apc.php and be sure it's working.
# Then rerun benchmarks:

ab -n 1000 -c 30 http://xxx.xxx.xxx.xxx

# Now go back into the Drupal admin interface and enable normal page cache.
# http://xxx.xxx.xxx.xxx/admin/settings/performance
# And benchmark again:

ab -n 1000 -c 30 http://xxx.xxx.xxx.xxx

# Should be looking pretty good, but the system will be under heavy load
# if we ask it to consistently deliver 100s of caches pages a second.
# Next level: use Varnish.

apt-get install varnish
cd /etc/apache2/
nano ports.conf

# Change apache to listen on port 8080

nano sites-available/default

# Change the virtualhost to also listen on port 8080

/etc/init.d/apache2 restart

# Now verify that the site is up via Apache at http://xxx.xxx.xxx.xxx:8080/

nano /etc/varnish/default.vcl

# Next change the Varnish configuration to enable and listen on port 80.
# Change the "start" value at the top of the file from "no" to "yes".
# Then check in the "Alternative 2, Configuration with VCL" section. Set the line
# DAEMON_OPTS="-a :6081  to use -a :80

/etc/init.d/varnish restart

# Verify that you get the site via http://xxx.xxx.xxx.xxx/
# Using firebug or Chrome dev tools, or live HTTP Headers you can verify that
# the via-varnish and "age" headers are being set.

# Now go turn the page caching to "external". And run benchmarks again:

ab -n 1000 -c 30 http://xxx.xxx.xxx.xxx/

# Whoops too fast, let's do more requests:

ab -n 10000 -c 30 http://xxx.xxx.xxx.xxx/

# What about a higher amount of concurrency?

ab -n 10000 -c 100 http://xxx.xxx.xxx.xxx/

# Wow. Varnish is cool. :)
# Just to be sure, review the old site is still the same/slow:

ab -n 1000 -c 30

# Now let's check it as a logged in user by pulling the session cookie out of
# Firebug, Chrome developer plugin, or Live Http Headers.

ab -C 'SESS3bcc84522751c15bbe6faf2b284d6c5a=gp7fuh9lvui6b86ffr221r6e85' -n 1000 -c 30

# That should be about the same as anonymous users; not too many modules.
# Let's add a module that impacts logged-in user performance.

cd /var/www
drush dl admin_menu
drush en admin_menu
ab -C 'SESS3bcc84522751c15bbe6faf2b284d6c5a=gp7fuh9lvui6b86ffr221r6e85' -n 1000 -c 30 http://xxx.xxx.xxx.xxx/

# Now lets install memcached

apt-get install memcached
apt-get install php5-memcached
cd /var/www
drush dl memcache
cd /var/www/sites/default/
nano settings.php

# Add these lines to the bottom, without the leading #hashmarks of course:
#    $conf['cache_inc'] = 'sites/all/modules/memcache/memcache.inc';
#    $conf['memcache_bins'] = array('cache_form' => 'database');
# Then restart apache and verify the site is still up and running.

/etc/init.d/apache2 restart

# Let's verify that memcached is doing stuff:

apt-get install telnet
telnet localhost 11211

# You can run "stats" to see statistics. Note cache_gets vs cache_hits.
# This is an important ratio.
# Type "quit" to get out.

# Now apachesolr.

cd /var/www
drush dl apachesolr
cd /var/www/sites/all/modules/apachesolr/

# The README file in the module has good instructions.
# This will grab the PHP client, the java server and set up the example solr
# server using the .xml schema file provided by the Drupal module.
cat README.txt
apt-get install subversion
svn export -r22 http://solr-php-client.googlecode.com/svn/trunk/ SolrPhpClient
cd /opt
wget http://download.filehat.com/apache//lucene/solr/1.4.1/apache-solr-1.4.1.tgz
tar -xzvf apache-solr-1.4.1.tgz
cd apache-solr-1.4.1/example/solr/conf/
cp /var/www/sites/all/modules/apachesolr/*.xml ./
cd ../..
nohup java -jar start.jar &
cd /var/www/
drush en apachesolr_search
drush cron

# We should be able to verify that our documents are being indexed now.

# Next up, let's use a better varnish config to allow Google Analytics:
cd /etc/varnish/
mv default.vcl default.vcl.bak
nano default.vcl

# Use the config from :
# https://wiki.fourkitchens.com/display/PF/Configure+Varnish+for+Pressflow
# And test its syntax first:

/usr/sbin/varnishd -d -f default.vcl

# Then restart varnish to have it take effect:

/etc/init.d/varnish restart

# Now debuggging with backtraces

apt-get install php5-xdebug graphviz ghostscript
nano /etc/php5/conf.d/xdebug.ini

# Set xdebug.profiler_enable_trigger = 1 in xdebug.ini

/etc/init.d/apache2 restart
cd /opt/
svn co http://xdebugtoolkit.googlecode.com/svn/tags/0.1.5/xdebugtoolkit/ xdebugtoolkit
ln -s /opt/xdebugtoolkit/cg2dot.py /usr/local/bin/cg2dot.py

# Now we have the tool ready. Hit http://xxx.xxx.xxx.xxx/index.php?XDEBUG_PROFILE=1

ls -l /tmp/

# See that theres's a cachegrind.out fiile in /tmp
# Then make it into an svg file:

cg2dot.py /tmp/cachegrind.out.21700 > /tmp/grind1.dot
dot /tmp/grind1.dot -Tsvg -o /var/www/grind1.svg

# Hit http://xxx.xxx.xxx.xxx/grind1.svg to view
# We can also use webgrind:

cd /var/www/
get clone https://github.com/jokkedk/webgrind.git

# Now: http://xxx.xxx.xxx.xxx/webgrind

# Munin is a nice easy monitoring tool: apt-get install munin

Short URL
Asymptotix on Twitter

Are the key legislative pillars such as Basel II & III, UCITS IV and Solvency II forcing you to re-examine how you identify, measure and manage risk and capital?

Asymptotix work closely with our partners to help clients develop a more proactive, systematic and integrated approach to governance and risk management to deliver proper value.

Asymptotix can offer the support you need to deliver on time. Read more...

Is the goal of your website to sell services or products, educate, or collect data?

A positive customer experience is vital to conversion, no matter what your conversion goals may be. Our designers and developers will create a positive experience to maximize your conversions and deliver the optimal return on your investment. We strive to find the perfect balance between the web site’s design and functionality.

Asymptotix implements interactive solutions for European companies. From corporate websites to social communities, our clients will tell you an investment in building a scalable online experience will deliver long-term tangible benefits.

Based in Luxembourg we can help you all over Europe. Our multi-lingual team can work with projects and speak your language! Read more...