如何在HostGator上使用PHP Composer [英] How to use PHP Composer on HostGator
问题描述
我最近决定在Zend Framework 2中启动一个项目,无法让它在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.
默认情况下,HostGator的共享服务器运行在PHP 5.2.2中,如果你上传ZF2框架应用程序,它将不会开箱。
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.
此外,如果你碰巧有SSH访问你的HG共享帐户(您通常需要请求),您将无法运行.PHAR文件,因为CLI的CLI版本也是5.2.2。
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.
推荐答案
首先,你可以在HostGator上启用PHP 5.3水平基础。只需将以下行添加到您的公共目录中的 .htaccess
文件:
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
参考链接
Ba-Da-Bing!现在你可以运行你的PHP 5.3应用程序了!
Ba-Da-Bing! Now you can run your PHP 5.3 applications!
哦,但等等!您有SSH访问权并想要使用PHP Composer?
如果您通过SSH登录并尝试以下命令:#php composer.phar install
您将会得到以下错误:致命错误:在...中找不到类'Phar'
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...
HostGator的#php
命令在5.2.2中运行。要在5.3中运行,您需要提供5.3二进制文件的完整路径。
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.
这是工作命令:
#/ opt / php53 / bin / php composer.phar install
我很高兴能得到这个工作, !
I was so excited that I got this working that I figured I would share!
这篇关于如何在HostGator上使用PHP Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!