linux下安装composer

Composer 是一个新的安装包管理工具,服务于 PHP 生态系统。
简单来说,能拉取别人的东西


[root@VM_0_26_centos 129]#wget https://getcomposer.org/download/1.0.0-alpha8/composer.phar  #下载包,下面会显示下载进度条

wget https://getcomposer.org/download/1.0.0-alpha8/composer.phar
--2019-11-11 16:16:55--  https://getcomposer.org/download//1.0.0-alpha8/composer.phar
100%[==========================================================>] 960,311     26.7KB/s   in 30s

2019-11-11 16:17:27 (30.9 KB/s) - ‘composer.phar’ saved [960311/960311]

[root@VM_0_26_centos 129]# mv composer.phar /usr/local/bin/composer#记得查看路径是否存在
[root@VM_0_26_centos 129]# chmod +x /usr/local/bin/composer#给权限
[root@VM_0_26_centos 129]# composer config -g repo.packagist composer https://packagist.phpcomposer.com #由于某些不能说的原因,魔法上网成本太高,只好切回国内源,另外这里可能出现安全警告,关闭某些东西的报错,不用管
[root@VM_0_26_centos 129]# composer #输入此命令,出现下面的东西说明安装成功
[root@VM_0_26_centos 129]# composer
PHP Warning:  putenv() has been disabled for security reasons in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149

Warning: putenv() has been disabled for security reasons in phar:///usr/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149
PHP Warning:  putenv() has been disabled for security reasons in phar:///usr/bin/composer/bin/composer on line 57

Warning: putenv() has been disabled for security reasons in phar:///usr/bin/composer/bin/composer on line 57
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.8.5 2019-04-09 17:46:47

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about                Shows the short information about Composer.
  archive              Creates an archive of this composer package.
  browse               Opens the package's repository URL or homepage in your browser.
  check-platform-reqs  Check that platform requirements are satisfied.
  clear-cache          Clears composer's internal package cache.
  clearcache           Clears composer's internal package cache.
  config               Sets config options.
  create-project       Creates new project from a package into given directory.
  depends              Shows which packages cause the given package to be installed.
  diagnose             Diagnoses the system to identify common errors.
  dump-autoload        Dumps the autoloader.
  dumpautoload         Dumps the autoloader.
  exec                 Executes a vendored binary/script.
  global               Allows running commands in the global composer dir ($COMPOSER_HOME).
  help                 Displays help for a command
  home                 Opens the package's repository URL or homepage in your browser.
  i                    Installs the project dependencies from the composer.lock file if present, orfalls back on the composer.json.
  info                 Shows information about packages.
  init                 Creates a basic composer.json file in current directory.
  install              Installs the project dependencies from the composer.lock file if present, orfalls back on the composer.json.
  licenses             Shows information about licenses of dependencies.
  list                 Lists commands
  outdated             Shows a list of installed packages that have updates available, including their latest version.
  prohibits            Shows which packages prevent the given package from being installed.
  remove               Removes a package from the require or require-dev.
  require              Adds required packages to your composer.json and installs them.
  run-script           Runs the scripts defined in composer.json.
  search               Searches for packages.
  self-update          Updates composer.phar to the latest version.
  selfupdate           Updates composer.phar to the latest version.
  show                 Shows information about packages.
  status               Shows a list of locally modified packages, for packages installed from source.
  suggests             Shows package suggestions.
  u                    Upgrades your dependencies to the latest version according to composer.json,and updates the composer.lock file.
  update               Upgrades your dependencies to the latest version according to composer.json,and updates the composer.lock file.
  upgrade              Upgrades your dependencies to the latest version according to composer.json,and updates the composer.lock file.
  validate             Validates a composer.json and composer.lock.
  why                  Shows which packages cause the given package to be installed.
  why-not              Shows which packages prevent the given package from being installed.

成功


如果遇上

PHP Fatal error: Uncaught PharException: phar "/usr/local/bin/composer" has a broken signature in /usr/Local/bin/composer:23
/usr/local/bin/composer(23): Phar: :mapPhar( i composer .phar')
#l {main}
thrown in /usr/local/bin/composer on line 23

的话,说明下载的包有问题,删了重下再给权限运行


另外如果安装composer时,出现了我上面的PHP Warning: putenv()报错问题,这是因为安全考虑,禁用了某些危险函数,我是Linux+Nginx+MySQL+PHP的环境,如果要开启这项函数,那么就要到PHP安装目录找到php.ini(我是宝塔面板+PHP-7.2),该配置文件在 /www/server/php/72/etc/php.ini下,

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,proc_ope     n,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

将“disable_functions”中的putenv删除即可,并保存php.ini文件,重启服务,刷新。即可解决报错问题。

### 部署 Stable Diffusion 的准备工作 为了成功部署 Stable Diffusion,在本地环境中需完成几个关键准备事项。确保安装了 Python 和 Git 工具,因为这些对于获取源码和管理依赖项至关重要。 #### 安装必要的软件包和支持库 建议创建一个新的虚拟环境来隔离项目的依赖关系。这可以通过 Anaconda 或者 venv 实现: ```bash conda create -n sd python=3.9 conda activate sd ``` 或者使用 `venv`: ```bash python -m venv sd-env source sd-env/bin/activate # Unix or macOS sd-env\Scripts\activate # Windows ``` ### 下载预训练模型 Stable Diffusion 要求有预先训练好的模型权重文件以便能够正常工作。可以从官方资源或者其他可信赖的地方获得这些权重文件[^2]。 ### 获取并配置项目代码 接着要做的就是把最新的 Stable Diffusion WebUI 版本拉取下来。在命令行工具里执行如下指令可以实现这一点;这里假设目标路径为桌面下的特定位置[^3]: ```bash git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git ~/Desktop/stable-diffusion-webui cd ~/Desktop/stable-diffusion-webui ``` ### 设置 GPU 支持 (如果适用) 当打算利用 NVIDIA 显卡加速推理速度时,则需要确认 PyTorch 及 CUDA 是否已经正确设置好。下面这段简单的测试脚本可以帮助验证这一情况[^4]: ```python import torch print(f"Torch version: {torch.__version__}") if torch.cuda.is_available(): print("CUDA is available!") else: print("No CUDA detected.") ``` 一旦上述步骤都顺利完成之后,就可以按照具体文档中的指导进一步操作,比如调整参数、启动服务端口等等。整个过程中遇到任何疑问都可以查阅相关资料或社区支持寻求帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值