在阿里云服务器上部署的宝塔主机面板,怎样安装composer来快捷部署项目?阿里云北京分销商北京万维网小编为您分享我司大咖总结的宝塔面板composer.par安装文档,供朋友们参考。
需要先将默认php修改为php5.3以上,否则会报错:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The phar extension is missing.
Install it or recompile php without --disable-phar
Your PHP (5.2.17p1) is too old, you must upgrade to PHP 5.3.2 or higher.
默认Php版本的修改方法:
rm -f /usr/bin/php
ln -sf /www/server/php/71/bin/php /usr/bin/php
如果修改后仍然报错,你就直接调用相应版本php的全路径:
/www/server/php/56/bin/php composer.phar require alibabacloud/darabonba-openapi
注意要从禁用函数里删除putenv()和proc_open()这两个函数,否则会报错:
Warning: putenv() has been disabled for security reasons in phar:///www/wwwroot/hostu.cn/vendor/composer.phar/bin/composer on line 59
The Process class relies on proc_open, which is not available on your PHP installation. Installation failed, deleting ./composer.json. [ErrorException] Undefined index: process
然后安装composer.phar
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
这四句代码的意思是:
Download the installer to the current directory 下载composer安装器到当前目录
Verify the installer SHA-384, which you can also cross-check here 安装器文件可靠性用sha-384秘钥验证
Run the installer运行安装器
Remove the installer删除安装器
一些可以使用的安装参数,也就是第三行代码可以替换为以下代码:
php composer-setup.php --install-dir=bin
这是自定义安装目录
php composer-setup.php --filename=composer
这是自定义安装的文件名
php composer-setup.php --version=1.0.0-alpha8
这是自定义版本
更多介绍请参考官方文档:https://getcomposer.org/download/
完全安装以后,你就可以在安装了composer.phar的文件夹运行composer来安装项目了。比如你如果想安装阿里云的openapi SDK项目,就可以运行以下代码:
/www/server/php/71/bin/php composer.phar require alibabacloud/sdk
北京万维网作为阿里云北京授权代理商,为广大企业用户提供实惠的阿里云服务器价格(低至1折),稳定可靠的OSS对象存储备份等上云解决方案和周到技术支持服务,如果您企业需要在云服务器上部署应用、网站,或迁移上云,欢迎联系北京万维网客服。电话:18601095105、QQ 442956988
微信: