如果我们在一台服务器、VPS中有不同的项目时候,可能由于程序的特殊性需要不同的PHP版本兼容。一般我们常见的WEB面板是可以同时直接安装PHP版本的,然后在添加站点的时候直接进行不同版本PHP就可以了。但是,我们常用的LNMP、Oneinstack脚本是否可以实现这样的功能呢?
检查当前版本:php -v
一、安装php
查找lnmp的install.sh文件,一般在/root/lnmp1.5/install.sh下执行命令
cd lnmp1.5
安装php
./install.sh mphp

这样安装即可。
安装好后即可看到配置文件多了个 enable-php7.1.conf文件

添加站点选择php版本:include enable-php7.1.conf;
二、站点配置:
server
{
listen 80;
server_name dddd.tpxhm.com;
index index.php index.html index.htm default.html default.htm default.php;
root /www/dddd.tpxhm.com;
include enable-php7.1.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}三、验证:
