LOGO
Yutuo

最新的CPanel好像已经支持每个站点使用不同的PHP版本了,不过有些网站还是禁用了PHP版本切换功能。

其实我们可以在.htaccess文件里直接设置PHP版本。

一般来说,CPanel中使用的PHP控制器是EasyApache3或者EasyApache4

EasyApache3的定义一般如下(可能有些版本会没有定义):

application/x-lsphp52 /opt/alt/php52/usr/bin/lsphp
application/x-lsphp53 /opt/alt/php53/usr/bin/lsphp
application/x-lsphp54 /opt/alt/php54/usr/bin/lsphp
application/x-lsphp55 /opt/alt/php55/usr/bin/lsphp
application/x-lsphp56 /opt/alt/php56/usr/bin/lsphp
application/x-lsphp71 /opt/alt/php71/usr/bin/lsphp
application/x-lsphp72 /opt/alt/php72/usr/bin/lsphp

EasyApache4的定义一般如下(可能有些版本会没有定义):

application/x-httpd-ea-php52-lsphp /opt/cpanel/ea-php52/root/usr/bin/lsphp
application/x-httpd-ea-php53-lsphp /opt/cpanel/ea-php53/root/usr/bin/lsphp
application/x-httpd-ea-php54-lsphp /opt/cpanel/ea-php54/root/usr/bin/lsphp
application/x-httpd-ea-php55-lsphp /opt/cpanel/ea-php55/root/usr/bin/lsphp
application/x-httpd-ea-php56-lsphp /opt/cpanel/ea-php56/root/usr/bin/lsphp
application/x-httpd-ea-php70-lsphp /opt/cpanel/ea-php70/root/usr/bin/lsphp
application/x-httpd-ea-php71-lsphp /opt/cpanel/ea-php71/root/usr/bin/lsphp
application/x-httpd-ea-php72-lsphp /opt/cpanel/ea-php72/root/usr/bin/lsphp

在网站设置PHP版本时,只需要在.htaccess文件里添加相应的代码就行。

比如,如果选择PHP5.6,设置方法如下:

EasyApache3时的代码:

Apache
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp56
</FilesMatch>

EasyApache4时的代码:

Apache
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-ea-php56-lsphp
</FilesMatch>
转载请注明:宇托的狗窝 » CPanel中PHP版本选择
上一篇 下一篇
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址