LNMP安装多版本PHP共存的方法及站点配置

2019-09-02   阅读:2389   分类:后端    标签: 服务器

如果我们在一台服务器、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

image.png

这样安装即可。

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

image.png

添加站点选择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;
    }

三、验证:

image.png

【腾讯云】 爆款2核2G3M云服务器首年 61元,2核2G4M云服务器新老同享 99元/年,续费同价

‘简忆博客’微信公众号 扫码关注‘简忆博客’微信公众号,获取最新文章动态
转载:请说明文章出处“来源简忆博客”。http://www.tpxhm.com/adetail/209.html

×
觉得文章有用就打赏一下文章作者
微信扫一扫打赏 微信扫一扫打赏
支付宝扫一扫打赏 支付宝扫一扫打赏

文章评论(0)

登录
简忆博客壁纸一
简忆博客壁纸二
简忆博客壁纸三
简忆博客壁纸四
简忆博客壁纸五
简忆博客壁纸六
简忆博客壁纸七
简忆博客壁纸八
头像

简忆博客
勤于学习,乐于分享

置顶推荐

打赏本站

如果你觉得本站很棒,可以通过扫码支付打赏哦!
微信扫码:你说多少就多少~
微信扫码
支付宝扫码:你说多少就多少~
支付宝扫码
×