Alex Moreno

A Drupal Developer in London

Minimal Apache2 modules for Drupal

This days i've been having problems with my server, until i arrived to a point on I was considering seriously disable Apache and install ngnix, a light server I am using in my laptop and some small projects.

The point is that I don't have noticed a real big performance increment in my laptop (difficult with a few users). Anyway, having to install a new server, disable Apache, tuning everything to work correctly is a good challenge... unless you are at the doors of taking a plane and don't want to be all the trip thinking about the server...

Solution? Ok, let's tuning the Apache2 server, very easy because where are only going to use a2dismod to disable the modules and a2enmod to activate if they give us some error... Easy, right?

Let's go, this is my minimal (by now) apache modules list:

actions.conf  alias.conf  authn_file.load authz_host.load  dir.load    fcgid.load  mime.load  php5.load  suexec.load

actions.load  alias.load  authz_groupfile.load dir.conf fcgid.conf  mime.conf php5.conf  rewrite.load

You can disable the rest with a2dismod [MODULENAME], for example:

a2dismod cgi

I recommend you to restart your server once disabled. If apache cannot restart, enable the module again with a2enmod [MODULENAME] and try again the restart.

I have to say that last week I've been having a lot of problems... The last thing I did was to tune in that way Apache... and simply magic, sites load incredibly fast with this simply modification.

Now, I can fly withour worries :-).


Fatal error: require_once() [function.require]: Failed opening required sites/all/ modules/feeds_xpathparser/ FeedsXPathParser

After installing all the updates and changing the core of drupal (main files), you could find this error doing the upgrade (opening upgrade.php).

It's a problem specified here:

Well, simply disable the feeds modules, all, ignore by now the errors and proceed with the upgrade. No errors, right?

You can now put again your website online and proceed to solve the problem (previous link) with feeds, with without having to wait to your users :-).


Error 500 in Drupal (invite module)

Error 500 in your Drupal? Don't panic.... well, a little maybe, but be sure you'll find a way to solve it.

open your index.php in root Drupal and add:


ini_set('display_errors', '1');

Reload the Error 500 page and, evoilá:

Fatal error: Call to undefined function invite_page_title() in /[.....]/httpdocs/includes/ on line 

This is saying that there is a problem with a module. In my case, I disabled invite, and seems to cause problems. Before the show php errors trick I was blind, but I disabled several modules and started to have problems, so I had no way to know which one were giving us problems and, so the, how to solve it.

Ok, if this is the scenario (not able to even login in your site to disable modules), then drush is simply magic. Install it and:

drush enable invite

try now. If the error persists, it is probably that it has changed and now it shows you another module or another kind of problem. That's is, then, another story :-).

Sometimes you'll need to clear your cache or make some other operations, only availabe via admin interface... well, not exactly, drush also can help you, for example, with a "clean drush" For more information visit:


Zend php framework quickstart howto (ubuntu + nginx)

Those days i've been playing with the so known and symfony competence, Zend framework, and the basic installation in ngnix.

I have to say that I love all this php frameworks, and the ruby idea of using the command line.

In ubuntu, installing zend to begin is as easy as:

sudo apt-get install zend-framework

And that's it, you have Zend installed in your machine.... don't believe me?? Create and go to /var/www/zend directory. Inside type: 

zf create project tutorial

Ready.... well, okay, not 100%, you still have to say to your server (apache or nginx in my case) where the project is.

I like to have urls for each project, as if they were living in different servers, so I added a new host in my /etc/hosts file:       zend

and, in /etc/nginx/sites-enabled/default-zend you'll finally have to add:



server {

      listen 80;

      server_name zend;

      root /var/www/zendlab/tutorial/public; ## <-- Your only path reference.

      index  index.html index.htm index.php;

        location / {

                try_files $uri $uri/ /index.php;


        location ~ \.php$ {

    try_files       $uri /index.php;

    fastcgi_index   index.php;


    include         fastcgi_params;

    fastcgi_param   SCRIPT_FILENAME  /var/www/zendlab/tutorial/public$fastcgi_script_name;

    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;





And you finally can load your new Zend project from: http://zend/

Beauty solution, isn't it?

Well, we have Zend working, but it still doesn't do too much. Let's create our firs controller:

zf create action add Index

One thing which i've liked about Zend. It automatically suposes that you will use PHPUnit:

Note: PHPUnit is required in order to generate controller test stubs.



the steps in refactoring, from the book: "Refactoring: Improving the Design of Existing Code" by Martin Fowler:

  • Identify the code in need of refactoring.
  • Have test coverage for the code.
  • Work in small steps.
  • Run your tests after each step. Code and test in quick iterations — which is much easier
  • in an interpreted language like PHP as compared with compiled languages.
  • Use refactoring to make your more readable and to improve performance.

Problems with mysql 5.5 upgrading ubuntu 12.04

After upgrading ubuntu to 12.04 i have run into problems with mysql.

First of all, if you are going to make an upgrade of "anything", the main tip is to make a backup of the databases and files which you consider important. If you didn't, maybe you still can save something, copy your /var/lib/mysql directory. If you finally have to reinstall your mysql, loosing the databases, maybe you will be lucky and copying again /var/lib/mysql directory could give your data back.

ok, the problem with mysql 5.5 and ubuntu 12.04.

The following packages have unmet dependencies:

 mysql-server : Depends: mysql-server-5.5 but it is not installed

E: Unmet dependencies. Try using -f.

Trying apt-get -f install did not solve anything. Tryied then apt-get install mysql-server-5.5

No luck, but then i saw this:

trying to overwrite '/usr/lib/mysql/plugin/', which is also in package libmysqlclient-dev

And the solution came to my mind: remove the conflictive package:

sudo dpkg -r libmysqlclient-dev

and now, 

apt-get -f install 

finally worked and did the magic. I did backups of my important databases before going to this "party", but anyway, after installing again mysql (apt-get -f intall did) everything was working fine, mysql included.

Hope it helps :-)

backups with screen and ncftp

Do you have a BIG database (or databases) in your server as a result of months and years of working? It use to be a hell to download the sql right? One solution is to get a backup ftp in your hosting provider. They are cheap, and the are going to save you a lot of time.

The trick, do the mysql backup maintenance things. Then, it's time to download your ENORMOUS .sql, but not directly to your computer.

First install screen, a usefull app to launch any console script or commad, and be able to let running while even you close your local computer.

Secondly, install ncftp, a wonderful ftp client (i love it).

And, lastly, some magic. Execute:


  1. screen
  2. put the file on the  ftp: ncftpput -v -R -u USER -p PASS FTPHOST [DIRECTORYWHERECOPY] [FILE(S)TOCOPY]


If file is too big, you can close your terminal with [CONTROL]A+D keys. But, we'll speak in another post about screen.


Drupal slow when saving nodes (content, comments, admin ...)

Drupal slow when saving nodes (content, comments, admin ...)? Maybe the problem is really simple, try to deactivate some modules that you don't use. It is common to test modules that you finally don't use in your production server. Search for them and deactivate, they take a lot of memory, even if you think you are not using them.




varnish in Drupal howto

Installing Varnish is really simple and easy to perform, and is very unlikely to give you problems with your server that any other more complex methods could give you, like using light servers or so. Probably you cannot compare both performances, but to start improving you Drupal server is a good point from where start.

Let's go:

1. Install Varnish. In Ubuntu / Debian is as easy as:

sudo apt-get install varnish

2. Install Varnish module in your Drupal:

Be sure not to make the START=no mistake.

3. Start your Varnish server: sudo /etc/init.d/varnish start

Go to admin/settings/varnish in your Drupal and select enabled.

4. Copy the Varnish Control Key which you´ll find in /etc/varnish/secret (you'll need to be root or read with "sudo vim /etc/varnish/secret").

5. Enjoy :-)

Varnish error: Not starting HTTP accelerator varnishd

Tipical mistake installing varnish accelerator:

* Not starting HTTP accelerator varnishd

Solution? so simple, edit /etc/default/varnish and look for the line:


change to


and restart:

* Starting HTTP accelerator varnishd 

Nice :-)