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.

4
  • /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? Commented Dec 29, 2014 at 18:51
  • How to? My script pipes email, so when there's an incoming email, my script is executed. Commented Dec 29, 2014 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? Commented Dec 29, 2014 at 19:19
  • @Meorg: Simply figure out where php 5.4 lives on the server and change the hashbang according like #!/usr/bin/php54. Commented Dec 29, 2014 at 19:19

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.