How can I force PHP Version for Command Line?

前端 未结 7 1641
说谎
说谎 2020-12-17 17:01

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, wh

相关标签:
7条回答
  • 2020-12-17 17:38

    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.

    0 讨论(0)
提交回复
热议问题