One week later I managed to get it working but in a different way. I stopped messing with the host and started to learn how Docker can save my life.
This post gave me the key:
Docker - Run Apache on host and container for different websites
My iniciatic read about docker was this one: PHP Web Development with Docker
Summarizing, I don't need to install apache2.2 & PHP5.3 in my host server, I can have an isolated container where I can install anything I need (usually one service) and forget about possible incompatibilities with the host OS version. Docker manages it all.
So I can have one container with apache 2.2 + PHP 5.3 as it would be in a debian squeeze OS. Another container with apache 2.2 + PHP 5.4 as it would be in a Wheezy, another with apache 2.4 + PHP7.0 as in stretch and so on. All working as the same time and serving different domains.
To achieve the latter make apache/nginx on the host to work as reverse proxy redirecting each domain to a different apache-php container thanks to docker port mapping.
You don't even need to have apache/nginx on the host, it can be in a container also.
The docker way is to have each (micro)service in a container, so you can have mariaDB in another container, etc.
My steps (summarized): (I can not post more than to links, when i get enough reputation I will edit and add them)
0 - Read about docker (the more the better): how to build images with the Dockerfile, best practices, networking within docker,...
1 - Install Docker: follow official guide always.
2 - Create a dir with your future image name ( /home/user/docker/images/apache22php53 e.g.), inside create your Dockerfile and configs (virtualhost conf in this case) my Dockerfile was:
# squeeze new mirrors
RUN echo "deb http://archive.debian.org/debian/ squeeze contrib main non-free" > /etc/apt/sources.list
RUN apt-get update
# Common packages
RUN apt-get update && \
apt-get install -y --force-yes curl wget
RUN apt-get update && \
apt-get install -y --force-yes \
RUN a2enmod \
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
# RUN chown -R www-data:www-data /var/www
COPY conf/apache/virtualhosts /etc/apache2/sites-enabled
# disable default virtualhost
RUN a2dissite 000-default
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
Inside the dir put your virtualhost conf file inside the path: conf/apache/virtualhosts/
3 - build the image with (previous cd inside the dir):
sudo docker build -t apache22php53 .
4 - launch the container with:
sudo docker run -ti -d -p 2253:80 -v /var/www/html:/var/www --name apache22php53 apache22php53 /bin/bash
Docker will map (-p) 2253 host port to 80 container port. We are mounting (-v) also our host document root (/var/www/html) in the apache-container document root (in squeeze is /var/www ). The are setting also container name (--name).
5 - ssh to container with:
sudo docker exec -ti apache22php53 /bin/bash
and start apache if needed (as in my case). "exit" to get back to host cli.
6 - navigate to ...yourvhostdomain.com:2253 and you should see your apache running with PHP5.3 loaded.
This is the basics. After that you will learn about how to mount host data (www, databases, etc) inside containers, how containers can communicate between them and with the host (privates IPs in docker network), how to use docker-compose to set up multiple containers at once (web, database, etc), reverse proxy for multiple containers webservers, etc.