linux安装及使用composer

上篇日志记录了windows安装及使用composer。

这篇日志记录下linux安装及使用composer,我再说绕口令……

相对而言,还是比较倾向于使用linux,虽然我用不明白。

开始安装:

1:下载composer包:

curl -sS https://getcomposer.org/installer | php

报错内容:

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 suhosin.executor.include.whitelist setting is incorrect.
Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):
    suhosin.executor.include.whitelist = phar
  
The php.ini used by your command-line PHP is: /etc/php.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.
 

报错的原因是我php安装了suhosin扩展,解决方法,报错中已给出,就是在php.ini文件中添加

suhosin.executor.include.whitelist = phar

在这里插入图片描述

2:安装Composer

mv composer.phar /usr/local/bin/composer

3:查看安装Composer是否成功

composer -v

2.png

4:设置中国镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

报错:

Do not run Composer as root/super user! See https://getcomposer.org/root for details

报错原因:使用root用户运行composer是不可以的。

官网给出的解释:

https://getcomposer.org/doc/faqs/how-to-install-untrusted-packages-safely.md
解决方法很容易,给你的服务器添加另一个用户,使用新用户来操作composer

5:安装thinkphp5.1

composer create-project topthink/think tp5

报错:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 3194636 bytes) in phar:///usr/local/bin/composer/src/Composer/Cache.php on line 94
  
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3194636 bytes) in phar:///usr/local/bin/composer/src/Composer/Cache.php on line 94
 

解决方法:

终端报出了Allowed memory size of 134217728 bytes exhausted错误,是因为php默认内存限制是128M,所以需要修改php.ini文件。

1、查找到memory_limit = 128M这一行,将128M改大点,我这里直接是改成了2048M。
2、重启apache
3、重新执行php文件,成功,OK

3.png

更新方法跟windows一样

进入应用根目录,执行:

composer update topthink/framework

更新操作会删除thinkphp目录重新下载安装新版本,但不会影响application目录,因此不要在核心框架目录添加任何应用代码和类库。

安装和更新命令所在的目录是不同的,更新必须在你的应用根目录下面执行

有好的建议,请在下方输入你的评论
欢迎访问个人博客
https://guanchao.site

欢迎访问小程序:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_39708228/article/details/113034605
今日推荐