How to use PHP Composer on HostGator
Asked Answered
E

4

33

I recently decided to start a project in Zend Framework 2 and was having trouble getting it to run on a HostGator shared server.

By default, HostGator's shared servers run in PHP 5.2.2 and if you upload the ZF2 Skeleton Application, it will not run out of the box.

Also, if you happen to have SSH access to your HG Shared account (You usually have to request it), you won't be able to run .PHAR files because the CLI version of PHP is also 5.2.2.

Luckily, I got it to work... see below.

Eudosia answered 14/12, 2012 at 23:27 Comment(2)
NOT completely obvious. It's not immediately apparent that HostGator is running 5.2.2, and even if you do switch to 5.3, it would be common to assume that the CLI would also run 5.3. This guide is to help those who have not run across this yet. I suggest that you make comments that are constructive, not demeaning.Eudosia
It worked for me #20895018Donnelly
P
1

There is an option in Hostgator CPanel. Just go to PHP Configuration and choose one of PHP versions. Now you can choose between 5.2, 5.3, 5.4 and 5.5.

Publisher answered 25/11, 2015 at 9:25 Comment(0)
E
65

First off, you can enable PHP 5.3 on HostGator on a directory level basis. Simply add the following line to the .htaccess file in your public directory:

AddType application/x-httpd-php53 .php reference link

Ba-Da-Bing! Now you can run your PHP 5.3 applications!

Oh, but wait! You have SSH access and want to use PHP Composer?
If you log in via SSH and try the following command: # php composer.phar install you will get the following error: Fatal error: Class 'Phar' not found in...

This is because HostGator's # php command runs in 5.2.2. To run in 5.3, you need to provide the full path to the 5.3 binary.

Here's the working command:
# /opt/php53/bin/php composer.phar install

I was so excited that I got this working that I figured I would share!

Eudosia answered 14/12, 2012 at 23:27 Comment(2)
alias php='/opt/php53/bin/php' to your .bashrc file to save typing.Billington
Depending on the HostGator server this may not work sadly, but thanks for the info!Vasiliki
P
1

There is an option in Hostgator CPanel. Just go to PHP Configuration and choose one of PHP versions. Now you can choose between 5.2, 5.3, 5.4 and 5.5.

Publisher answered 25/11, 2015 at 9:25 Comment(0)
I
0

Please note that composer is already installed on the dedicated servers package (Hostgator plans). You may check if it already installed by typing in the command line:

composer -V

If it already installed you should get something like:

Composer version 2.0.6 2020-11-07 11:21:17
Ibbie answered 1/6, 2021 at 13:29 Comment(0)
D
-1

If you still get errors just put this lini in your php.ini:

suhosin.executor.include.whitelist = phar
Doubleteam answered 8/1, 2014 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.