0

We have a legacy web application running php 5.4.10 and another application running the latest version of php ver 7.1

We would like to host both of these applications using apache on one instance of a redhat 7.3 server.

Here are the virtual hosts configured for each web app:

<VirtualHost *:80> DocumentRoot /var/www/app1.local.com/public_html ServerName www.app1.local.com ServerAlias app1.local.com ErrorLog /etc/var/www/app1.local.com/error.log CustomLog /var/www/app1.local.com/requests.log </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/app2.local.com/public_html ServerName www.app2.local.com ServerAlias app2.local.com ErrorLog /etc/var/www/app2.local.com/error.log CustomLog /var/www/app2.local.com/requests.log </VirtualHost> 

According to this guide: https://webtatic.com/packages/php71/ I know I can use "sudo yum install php71w php71w-mysql" to install the latest version of php and get app 2 working, but how can I also install php ver 5.4.10, and configure app1 to use php version 5.4.10? What are the steps?

Forgive me if the question seems silly, I'm more or less new to linux. I haven't been able to find a reliable and up to date tutorial explaining how to get this done.

    2 Answers 2

    1

    You can try using docker for this, but you may need to have it installed on your machine first. Then you can try

    sudo docker run --name=myphp5 -p 8080:80 -v /var/www/html/:/var/www/html -d eboraas/apache-php 

    This will download eboraas/apache-php docker image and run a docker container named "myphp5" with apache/php5 installed in it. The -v switch will mount your local /var/www/html directory into the container's /var/www/html and it will expose apache on port 8080 (so it doesn't clash with your local apache running at 80).

    You can stop the container by running

    sudo docker stop myphp5 

    Similarly, you can start it by running

    sudo docker start myphp5 

    To check the status of all your containers, you can run

    docker ps -a 

    Please note that there are other images with apache/php5 on dockerhub which you can use for this purpose - https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=php5&starCount=0

    The only limitation of this approach is that each docker container needs to expose the http on a different port so you can't have them running on 80. This is however solvable by using the local apache (the one listening on port 80) as a reverse proxy for the docker based apache.

    3
    • Thank You, I did not know about Docker before seeing this post. I ended up implementing this solution, and after a bit of tweaking, I managed to get it to work perfectly. I used a reverse proxy provided by apache to redirect the requests for app2 to port 8080 of the docker container.
      – hervens
      CommentedApr 17, 2017 at 0:02
    • You're welcome. I'm glad that worked for you.
      – Sava
      CommentedApr 17, 2017 at 8:23
    • Update: the specific docker instance given in this answer has been updated to run PHP 7. If you require an older PHP version, you'll need to find (or make) a Docker that contains the specific version you need.CommentedAug 9, 2019 at 19:23
    0

    Software Collections are ideal for this. The official description says:

    Software collections allow you to concurrently install multiple versions of the same software components on your system. Packages built using software collections do not overwrite the versions included with Red Hat Enterprise Linux.

    The current version, RHSCL 2.3, provides packages with PHP 5.6 and 7.0. See the Installation chapter of the RHSCL Release Notes to learn how to get access to RHSCL repos and install the packages.

    See Apache with various PHP versions, using SCL on the RH Developer Blog for instructions on how to use the different installed SCL versions of PHP with one Apache server. (Note that the instructions assume RHEL6, but the same method works on RHEL7 as well -- just skip the installation advice.)

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.