Restart vhost conf without restarting Apache

Changing your vhost.conf and working with plesk? There is no need to restart your whole Apache server and bother your users:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.com

Tip of the weekend :-)



Apache not sending changes in js and css (virtual box)

I am using a solution of vbox (virtual box) and shared folders in our windows work environment (yes, unfortunatelly, but the IT team is in his right to decide which machines we have to use).

Everytime the vbox start, it mounts "automagically" one of the shared folders in the linux host (centos and archlinux, one day I will explain why). So then, apache has all what he needs in /var/www/html/ (simply mounted with "mount /var/www/html") (see automatically mount directories in vbox).

So far, everything was working fine... until I started to make small changes in small files. Absolutely surprising because when I deleted the complete code in the css or js file, for example, and I updated the browser, the screen appeared white, so everything seemed ok. But not at all, dealing with small changes, like adding a line in your css simply add no effect, the change is here, but seems that Apache or the browser didn't like it, simply it was being ignored.

After a while struggling about the browsers cache and even restarting the virtual box I finally decided to dig into Google.

I found the problem in the frankooh blog and it seems that it is a vbox problem, exactly a vboxsf problem with Apache.

The solution is simple, go to you apache configuration (in centos /etc/http/conf/httpd.conf) and uncomment the line:

EnableSendfile Off

After restarting Apache all the changes were sended to the browser without problems, even the small ones.

PS: be carefull with case sensitive off != Off 

warning: date(): It is not safe to rely on the system's timezone settings

The error is quite enoying:

warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead

But it is quite simple to correct. It is not a drupal problem, but a linux/apache. Just go to your php.ini, for example /etc/php.ini in CentOS and add this line:

date.timezone = Europe/London

reboot apache and the problem will have dissapeared.


changing vhost.conf without restarting apache

Sometimes you need to change some parameters to your apache virtual host. Then, when you need to check the changes, in plesk you'd probably will have to execute the next command to see the changes:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain exampledomain.com

Otherwise, restarting apache (/etc/init/apache2 restart) could not make the trick.

I allways forgot this little trick... never more, because Programadores Web will remind it me :-).


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 :-).


Cambiar la configuracion en un vps o servidor dedicado sin reiniciar apache

Este es un pequeño truco que uso a veces cuando hago cambios en alguna configuración de alguno de mis sitios con Drupal. Imaginemos que configuramos un nuevo dominio en drupal, usando multisite para que apunte a un único directorio raiz, por ejemplo:


El fichero vhost será algo así (en /var/www/vhosts/dominioorigen.com/conf/vhost.conf):


        ServerAlias  *.crucerista.org
        ServerAdmin  "alejandro.moreno@tdo.es"
        DocumentRoot /var/www/vhosts/crucerista.net/httpdocs/crucerista/

        <Directory /var/www/vhosts/crucerista.net/httpdocs>
        <IfModule mod_php5.c>
                php_admin_flag engine on
                php_admin_flag safe_mode off
                php_admin_value open_basedir "/var/www/vhosts/crucerista.net/httpdocs:/tmp"
                Options +Includes -ExecCGI
        <Directory /var/www/vhosts/crucerista.net/web_users>
        <IfModule sapi_apache2.c>
                php_admin_flag engine off
        <IfModule mod_php5.c>
                php_admin_flag engine off


Y aquí viene el truco. Tras añadir el nuevo vhost no necesitamos ejecutar un apache restart, sino que valdrá con este comando:

/usr/local/psa/admin/bin/websrvmng --reconfigure-all

El truco está hecho sobre Drupal 6 y en un dedicado o un vps sobre Debian. Cualquier configuración alternativa de Drupal o distribución linux sería igualmente válida.

De nada ;-)