4

I would like to load a specific PHP version (5.4), I use Bluehost shared hosting which uses Apache and support PHP 5.4.

I have a .htaccess file and a php.ini file in a subdirectory (/api) with that line:

AddHandler application/x-httpd-php54 .php to specify to server to use PHP 5.4.

I have in /public_html another htaccess which uses single php.ini file which is located in that directory.

I have a file called by Shell, with that hashbang line:

#!/usr/bin/php -c/homex/xx/public_html/api/php.ini

I've looked at PHP version at runtime (when called by hashbang line), it shows 5.2 (default version) despite of the fact that I specified to use PHP 5.4 and the usage of php.ini in /api.

In the other hand, if I call my script by a browser, PHP version used is 5.4.

What's wrong? Do I need to add something else?

How could I use PHP 5.4 with my hashbang called file?

I've deleted php.ini file from /api and deleted that line from AddHandler application/x-httpd-php54 .php.htaccess file. So the php.ini file used is the single one from /public_html.

I've alo added that line to .htaccess from /public_html : AddHandler application/x-httpd-php54s .php s which mean single php.ini file.

Kevin Brown-Silva
  • 40,873
  • 40
  • 203
  • 237
Mathieu Smith
  • 378
  • 1
  • 13
  • `/user/bin/php` is just an executable, right? That is the whole idea behind that hashbang-fu at the beginning of the file. I am assuming it is symlinked to the 5.2 version? Why don't you change the hashbang line to the php 5.4 executable? – Sumurai8 Dec 29 '14 at 18:51
  • How to? My script pipes email, so when there's an incoming email, my script is executed. – Mathieu Smith Dec 29 '14 at 18:55
  • the main question is what kind of hosting plan do you have? is it shared? virtual dedicated? dedicated? do you have ssh access with root permission? – unixmiah Dec 29 '14 at 19:19
  • @Meorg: Simply figure out where php 5.4 lives on the server and change the hashbang according like `#!/usr/bin/php54`. – prodigitalson Dec 29 '14 at 19:19

1 Answers1

2

According to Bluehost, you have to select your PHP version in the control panel. Depending how they set Apache up, you may not be able to select what version of PHP you run via .htaccess

All our servers support (i.e. are capable of running) PHP 5.2 and PHP 5.4. The default version is 5.4.x but you can follow the directions below to use PHP 5.2.X instead. However we are working on phasing out PHP 5.2.x from our servers as it is no longer supported by its developers.

Machavity
  • 30,841
  • 27
  • 92
  • 100
  • This only gives instructions for what version of PHP is used by the WebServer (ie. Apache) and not what version is the default on the CLI which is what the OP wants. – prodigitalson Dec 30 '14 at 02:08