Archive for February 17th, 2010

Solution to a problem with VirtualHosts on Debian Lenny (Default Virtualhost opening by default overwritting the rest of the configured VirtualHosts)

Wednesday, February 17th, 2010

Configuring some Virtualhosts on a Debian server I administrate has led me to a really shitty problem. The problem itself consisted in that nomatter what kind of the configured VirtualHosts on the server I try to access the default one or the first one listed among Virtualhosts gets accessed. Believe me such an Apache behaviour is a real pain in the ass! I went through the VirtualHosts configurations many without finding any fault in them, everything seemed perfectly fine there. I started doubting something might prevent VirtualHosts to be served by the Webserver. Therefore to check if VirtualHosts configurations are properly loadedI used the following command:

debian-server:~# /usr/sbin/apache2ctl -S

Guess what, All was perfectly fine there as well. The command returned, my webserver configured VirtualHosts as enabled (linked) in: /etc/apache2/sites-enabled I took some time to ask in irc.freenode.net #debian channel if somebody has encountered the same weirdness, but unfortunately noobody could help there. I thinked over and over the problem and I started experimenting with various stuff in configurations until I got the problem.

The issue with non-working Virtualhosts in Debian lenny was caused by;
wrong NameVirtualHost *:80 directive
It’s really odd because enabling the directive as NameVirtualHost *:80 would report a warning just like there are more than one NameVirtualHost variable in configuration, on the other hand completely removing it won’t report any warnings during Apache start/restart but same time VirtualHosts would still be non-working.

So to fix the whole mess-up with VirtualHosts not working I had to modify in; my /etc/apache2/sites-enabled/000-default as follows;

NameVirtualHost *:80 changes toNameVirtualHost *

The rest of the Virtualhost stays the same;
This simple thing eradicated the f*cking issue which tortured me
for almost 3 hours! ghhh

Installing eAccelerator for PHP5 on Debian Lenny (5.04)

Wednesday, February 17th, 2010

 

Here is a quick way step by step instructions on installing Eaccelerator (the PHP the accelerator & optimizer).

1. Add the following lines to /etc/apt/sources.list:

deb http://debian.mcmillan.net.nz/debian lenny awm deb-src http://debian.mcmillan.net.nz/debian lenny awm
deb http://debian.schnuckelig.eu/ lenny main contrib non-free

2. Import the repository keys to prevent missing gpg key warnings.

server:~# gpg –keyserver keyring.debian.org –recv-keys 0x8f068012;
server:~# gpg –export –armor 0x8f068012 | apt-key add –
server:~# wget -O – http://debian.schnuckelig.eu/repository-key.gpg | apt-key add –

3. Install the eaccelearor from the debian repository

server:~ # apt-get update
server:~# apt-get install php5-eaccelerator

An alternative way for installation is the canonical way from source:

 

 

Eventhough installing eaccelerator from this Debian repositories sounds like a good idea I don’t want to risk using unofficial Debian repositories.
Therefore I decided to install it personally that way to prevent some possible security threats.

Here is once again a step by step installing walk through:

1. Install some packages required for compilation of eAccelerator on Debian platform.

server:~ # apt-get install build-essential php5-dev bzip2

2. Download, compile and install from source eaccelerator as a PHP5 module

server:~# cd /usr/local/src server
server:~# wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
server:~# tar xvfj eaccelerator-0.9.5.3.tar.bz2 server # cd eaccelerator-0.9.5.3 server
server:~# phpize
server:~# ./configure
server:~# make
server:~# make install

3. Create eaccelerator disk cache directory server

server:~# mkdir -p /var/cache/eaccelerator
server:~# chmod 0777 /var/cache/eaccelerator

4. Edit php.ini to enable eaccelerator module in PHP

Put the following after the last line in php.ini

extension=”eaccelerator.so”
eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/var/cache/eaccelerator” eaccelerator.enable=”1″ eaccelerator.optimizer=”1″ eaccelerator.check_mtime=”1″ eaccelerator.debug=”0″ eaccelerator.filter=”” eaccelerator.shm_max=”0″ eaccelerator.shm_ttl=”0″ eaccelerator.shm_prune_period=”0″ eaccelerator.shm_only=”0″ eaccelerator.compress=”1″ eaccelerator.compress_level=”9″

Nevertheless, which way to install is used after the eaccelerator installation is compileted it is necessery to restart apache in order to load the new php.ini settings in the php module; So we now, let’s check apache for errors in configurations and restart it:

server:~# /usr/sbin/apache2ctl -t
Syntax OK

server# /etc/init.d/apache2 restart Now try your apache with some apache benchmarking tool to check about performance of php execution in apache.
See for yourself how eacceleator makes PHP script execution a way faster.