Can I run php 5.6 in a specific directory?


#1

Hello,

I have a wordpress website that I recently updated to PHP 7. I have a directory that hosts another older webapp in the same directory as the WordPress site. Is there a way I can run php 5.6 for that specific directory but PHP 7 for the rest of the website?


#2

It would be easy if you create different a site for both using easyengine, one with new php7 and another with legacy PHP versions.

Create first site using sudo ee site create example.com --wp --php7 and create another site using sudo ee site create example.com --php5


#3

Did you ever try creating two sites with the same domain?

Of course it won’t work.

@lancey, what you want is possible but I don’t think it is easy to achieve using standard EasyEngine. You’d need to write your own server blocks with specific per location backend configuration.


#4

Thanks @portofacil, Yes that is what I figured. I would rather not move the directory to its own site, and have been googling for server block configurations to do what I need, but unfortunately I have come up empty.


#5

I assume you used EE to set up the wordpress site. You just need a separate location block for the old site.

Here’s an example.

This is the content of the file /etc/nginx/sites-available/mbt.192.168.0.210.xip.io

server {
    server_name mbt.192.168.0.210.xip.io   www.mbt.192.168.0.210.xip.io;
    access_log /var/log/nginx/mbt.192.168.0.210.xip.io.access.log rt_cache;
    error_log /var/log/nginx/mbt.192.168.0.210.xip.io.error.log;
    root /var/www/mbt.192.168.0.210.xip.io/htdocs;
    index index.php index.html index.htm;
    include common/php7.conf;
    include common/wpcommon-php7.conf;
    include common/locations-php7.conf;
    include /var/www/mbt.192.168.0.210.xip.io/conf/nginx/*.conf;
}


server {
    server_name test.192.168.0.210.xip.io   www.test.192.168.0.210.xip.io;
    access_log /var/log/nginx/test.192.168.0.210.xip.io.access.log rt_cache;
    error_log /var/log/nginx/test.192.168.0.210.xip.io.error.log;
    root /var/www/mbt.192.168.0.210.xip.io/htdocs/old;
    index index.php index.html index.htm;
    include common/php.conf;
    include common/locations.conf;
}

These three lines are the important ones.

server_name test.192.168.0.210.xip.io www.test.192.168.0.210.xip.io; root /var/www/mbt.192.168.0.210.xip.io/htdocs/old include common/php.conf;

Let me know if you need further help.


#6