How to run multiple websites with mix of php 5 and php 7 on Ubuntu 16 Nginx 64bit on a single droplet?

Posted September 3, 2016 6.4k views
NginxPHPUbuntu 16.04

I have already setup multiple websites on 64bit Ubuntu 16 Nginx server with php 7
Now I’d like to add another website to the same droplet to use php 5, (this premade site need ionCube loader, ionCube doesn’t support php7) Please help

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

For adding multiple sites on nginx server you should utilize Nginx Server Blocks (Virtual Hosts). More about Nginx Server Blocks you can read in this DigitalOcean tutorial.

The main idea is to have one VH to point on php-5, while another will point to php-7.
This could be done by setting correct php path under ~.php$ location in Server Block config file.
Taken from Ubuntu 14.04 LEMP tutorial your php config should be something like…

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

For php-7 we will reefer to Ubuntu 16.04 LEMP tutorial, here it should look like

   location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;

For full guide reefer to links I given you, they’re pretty good-written tutorials. :)
I hope this will fix problem

by Justin Ellingwood
A LEMP stack (Linux, Nginx, MySQL, and PHP) is a powerful set of software that can be configured to serve dynamic sites and web apps from your server. In this guide, we will discuss how to install a LEMP stack on an Ubuntu 14.04 server.
  • Setting the Nginx virtual hosts is probably the easy part (at least I hope) but what I don’t know is how to install php 5.6 if I already have up and running Ubuntu 16.04 with php-7.0 and Nginx? Can you give me some link for that? I read somewhere that I should compile it somehow…

Hey i am trying to install prosper202 app. And my site is already working with php7 ubuntu 16…But the prosper usses some deprecated functions which will run below php 5.3…I used the method you said but a error is coming up..

“ Package ‘php5-fpm’ has no installation candidate ”
What to do, i google can came to know that now in ubuntu 16..php7 is standard …Can you guide a bit plz