如何强制命令行的PHP版本? [英] How can I force PHP Version for Command Line?

查看:130
本文介绍了如何强制命令行的PHP版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用1and1.com托管,我已使用 .htaccess 设置我的文件以使用php5解析。



但是这只适用于apache,而不是在命令行,默认为服务器默认的php4。



所以目前我无法设置cron作业以php5运行我的代码。任何想法?

解决方案

如果两者都安装,你所需要做的就是使用相关的PHP二进制文件运行脚本。 p>

例如:

  //使用PHP二进制文件/ usr / bin / php 
* * * * * root / usr / bin / php -n/path/to/script.php

  //使用位于/ var / php5 
* * * * * root / var / php5 -n/path/to/script.php


b $ b

您需要知道的是PHP CLI二进制文件的完整文件系统路径,并调用相关代码来运行您的代码。


I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using .htaccess.

But that only works in apache, and not in command line, which defaults to the server default php4.

So currently I can not setup cron jobs to run my code as php5. Any ideas?

解决方案

If both are installed, all you need to do is run the script using the relevant PHP binary.

So for example:

 // Runs using the PHP binary located at /usr/bin/php
 * * * * * root /usr/bin/php -n "/path/to/script.php"

or

 // Runs using the PHP binary located at /var/php5
 * * * * * root /var/php5 -n "/path/to/script.php"

All you need to know is the full file system path of the PHP CLI binaries, and call the relevant one to run your code.

这篇关于如何强制命令行的PHP版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆