Can I run two versions of php?

I have a Wordpress plugin which is using depreciated functions

The developer says I should just run PHP 7.4 instead of PHP 8.0.

Can I run PHP 7.4 for scripts in one directory
for example /var/www/mysite1

and then run PHP 8.0 for a different directory:
for example /var/www/mysite2 ?

Both would be running on the same apache server and using same version of MariaDB

Probably the answer is no !!

May be I should just go back to 7.4 until the developer updates the plugin.

What do you think?


You should probably ask your host. Some will allow this, with others it won’t be possible.

PHP 7.4 has nearly a year left of security fixes before it is end of life.
Probably best to spend that time updating your code for version 8. Then make the switch when you are ready.

Many web hosts allow you to specify a PHP version per directory. For instance I know Siteground does this and probably bluehost as well. Usually in the control panel of your host you will see something like “PHP version manager”. In there they let you select the directory and then the version of PHP to run all scripts in that directory as.

Now having said that, as others have stated, you might want to look at finding a replacement plugin if the developer doesn’t want to upgrade their script. That or wait. While some hosts will keep legacy versions around for a bit longer (even if no more security updates are made by the PHP community) it is good to make sure you can keep up on the version out of best practice and for optimal security.

1 Like

Docker would be the simplest solution if you have shell access to the host. Roll up two php-fpm containers with different PHP versions, mount site folders as volumes and add single nginx container to route requests for each site. They can share the database as well.

More than that, it is even possible to run different parts of the same site with different PHP versions, if URLs of these parts can be strictly distincted. In that case you just add multiple Location blocks to the nginx config.

I can make a sample docker-compose.yml file, if you’re interested.

1 Like

Thanks for your input - knowing the time-line is great.

I should have mentioned that I am using a dedicated
Full access to all resources.

Running ubuntu 20.05, Apache/2.4.41, MariaDB 10.3.32 and PHP 8.0
I think PHP 7.4 is also installed

So there is no host to talk to, I would have to configure it myself.

I just found this article …

Doesn’t look too difficult :slight_smile:

No, i think its not possible to run two versions of PHP at same time.

@jhonalbert have you read the answers before yours?

@Gandalf yes ofcourse…!

so why did you decide that is not possible?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.