Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

zend framework2 - How to use PHP Composer on HostGator

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...