Isolate PHP versions on AWS EC2

I’m actually using PHP 5.3 on all my projects. But for all the reasons you know, I want to update to PHP 5.4 (or 5.5).

We’re also going to migrate on AWS EC2 soon, on a “normal” Linux, Debian Wheezy for example.

  • AWS EC2 Container Service / Elastic Beanstalk Docker Container Port udp binding
  • Elastic Beanstalk CLI - Not replacing instance on deploy
  • Deploying Docker Data Volumes
  • aws cli cannot read from dynamodb docker container
  • Updating rather than replacing ECS Task Definition with CloudFormation
  • Pulling AWS EC2 container results in “image no found”
  • But the problem is that we’ve got some old projects we can’t migrate to PHP 5.3 for some reasons, and we can’t remove them either for some other reasons.

    So I was wondering what would be the best way to isolate those projects on our AWS EC2 instance, to use multiple versions of PHP/Apache.

    I was thinking about using Docker, so we can easily install an other PHP/Apache than on the main system. Plus knowing that it’s kind of a VM sounds good, so it won’t have any impact on the main “server”.

    Is it the best solution ?

    EDIT : Also, we can’t afford another EC2 instance for some cost reasons

  • Init Layer in Docker
  • can't run a pull queue handler inside a custom vm
  • replica Set mongo docker-compose
  • Can I transport just the image changes/layers i'm concerned with?
  • Docker jwilder/nginx-proxy location configuration
  • Docker-compose daemon exiting
  • 2 Solutions collect form web for “Isolate PHP versions on AWS EC2”

    You did not mentioned OS but assuming that it is linux based best solution would be
    to create multiple applicative users and install different versions of php by compiling
    in the respective app user’s home directory.

    For example create users user1 (home directory:/home/user1/) and user2 (home directory:/home/user2/). Now switch to user1 and install php5.3 and apache by
    compilations under the path /home/user1/app/php and /home/user1/app/apache
    respectively. Do same for user2 but this time with another version of php.
    Remember apache must run on different ports to avoid port conflicts. You can
    install third apache to as a reverse proxy with multiple vhosts which will
    accept traffic on port 80 and will send them to different backend apaches
    based on request.

    Traffic will be like this

    client http request <--> apache rp <--->  app1 based on apache1 or app2 based on apache2


    Rajarshi Haldar

    Why not using php-fpm and install two of them ? Then you can decide which one to use with which vhost. So each vhost can have it’s own php version. And in that case, you have only 1 apache server running.

    It should be pretty easy to find tutorial on google about that.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.