Due to a better understanding of what I wish to achieve thanks to Mark and his previous answer, I am posting a (hopefully) clearer and slightly different variation of my previous question as that thread has reached saturation;
I am trying to have multiple WordPress sites run on an nginx server, where each site requires a different version of PHP. I wish to achieve this by using multiple versions of PHP-FPM each running a different version of PHP, separate to nginx.
I then want to use .conf
files to control which PHP-FPM server each site uses, allowing that site to run on the desired PHP version. (As per the comments section)
Currently my server block for testsite1 looks like this, running the default PHP version.
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html/testsite1;
index index.php index.html index.htm;
server_name local.testsite1.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
This is located in /var/nginx/sites-available/testsite1
and is sym linked to /var/nginx/sites-enabled/testsite1
. Each server block is location in a separate file within sites-available
testsite1
testsite2
testsite3
I have compiled a different version of PHP (5.3.3), but I am unsure how to set up multiple PHP-FPM servers and how to make each 'point' to a different version of PHP. I also need guidance on how to set up multiple .conf
files to define which PHP-FPM server each WordPress site will use.
(essentially, I need hand holding throughout the entire process…)
Best Answer
In my experience, a simple server structure as follows, which is enough for your case.
Assumption
Server Environment Assumption
Public Network, which means can be accessed by people who have internet.
Private Network, which can be seen in a specific network group. (Class A, Class B, Class C. Ex, 192.xx.xx.xx or 10.xx.xx.xx or 172.xxx.xxx.xxx)
If you are using VPS on Linode and DigitalOcean, both of them provide private network IP, you can follow the instruction given by them to set it up.
If not, you can set up your own VPN(Virtual Private Network) or use your router to build one, it's easy, you can GOOGLE all what you need.
If you are using Ubuntu, making a VPN with configuration only costs you less than 5 minutes.
Before next step, suggest you to set up the firewall rules to prevent potential attacks. (By using IPTABLES or its wrapper, FirewallD)
Although we make PHP-FPM as dedicated from Nginx, however, the PHP files of websites can't be passed through both TCP Port and Unix Socket.
Thus, you have to manage your root folder for web server.
Options to manage website folder
If you are using *nix system, I suggest the forth option to do due to,
Some people may consider using NFS cause network latency, however, as for multiple websites waiting to be managed, NFS is an efficient and simple way.
You can GOOGLE "NFS on Linux" to finish installing and configuring this step, costs you about 1 hour for newer.
However, be aware that NFS server should be in a Private Network as well.
When NFS, PHP-FPM and Nginx are both in the same Private Network, the network latency should be less.
Then let's config the
nginx.conf
Assumption
Then, go creating a folder called
vhosts
inside the folder ofnginx.conf
Assumption
For PHP 5.6 (vhosts/app1.conf)
For HHVM (vhosts/app2.conf)
In this way, you can even add different SSL certificates for your vhosts.
Restart your server, and enjoy!
EDITED
To install different versions of PHP-FPM, you can compile it yourself, or using existing stack.
Recommend
https://github.com/centos-bz/EZHTTP/archive/master.zip
to save your timeUsing method, (Assumed your machine has installed WGET and UNZIP)