linux(ubuntu 20.10):安装composer 2.0.8及thinkphp 6.0.5(php 7.4.9)

一,安装前的准备工作 

1,查看当前的php版本:
root@ku:/data/php# php --version
PHP 7.4.9 (cli) (built: Oct 26 2020 15:17:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies
 
2,安装curl
检查是否已安装curl
root@ku:/data/php# whereis curl
curl:
用apt-get 安装curl
root@ku:/data/php# apt-get install curl
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列【新】软件包将被安装:
  curl
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 1 个软件包未被升级。
需要下载 161 kB 的归档。
解压缩后会消耗 411 kB 的额外空间。
获取:1 http://mirrors.aliyun.com/ubuntu groovy-updates/main amd64 curl amd64 7.68.0-1ubuntu4.2 [161 kB]
已下载 161 kB,耗时 0秒 (863 kB/s)
正在选中未选择的软件包 curl。
(正在读取数据库 ... 系统当前共安装有 287815 个文件和目录。)
准备解压 .../curl_7.68.0-1ubuntu4.2_amd64.deb  ...
正在解压 curl (7.68.0-1ubuntu4.2) ...
正在设置 curl (7.68.0-1ubuntu4.2) ...
正在处理用于 man-db (2.9.3-2) 的触发器 ...

 

说明:刘宏缔的架构森林是一个专注架构的博客,

网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/26/ubuntu-20-10-linux-an-zhuang-composer-2-8-ji-thinkphp-6-5/

         对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,下载/安装composer

1,查看是否已安装composer
root@ku:/data/php# composer -version
Command 'composer' not found, but can be installed with:
apt install composer

 

2,下载composer
root@ku:/data/php# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
 
Composer (version 2.0.8) successfully installed to: /data/php/composer.phar
Use it: php composer.phar
从提示可以看到:下载后文件保存到了 /data/php目录,也就是当前目录下
root@ku:/data/php# ls
composer.phar

 

3,移动到 /usr/local/bin目录下
root@ku:/data/php# mv composer.phar /usr/local/bin/composer

 

4,测试安装效果:
root@ku:/data/php# composer --version
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Composer version 2.0.8 2020-12-03 17:20:38
说明:实际应用composer时,应该不使用root账号
演示用普通用户账号查看composer的版本:
liuhongdi@ku:~$ composer --version
Composer version 2.0.8 2020-12-03 17:20:38

 

三,测试使用composer:

1,配置composer使用国内源:
liuhongdi@ku:~$ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
查看当前composer的所有配置:
liuhongdi@ku:~$ composer config -l -g
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (/home/liuhongdi/vendor)
[bin-dir] {$vendor-dir}/bin (/home/liuhongdi/vendor/bin)
[cache-dir] /home/liuhongdi/.cache/composer
[data-dir] /home/liuhongdi/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/home/liuhongdi/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/home/liuhongdi/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/home/liuhongdi/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[cache-read-only] false
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[platform-check] php-only
[home] /home/liuhongdi/.config/composer

 

2,更新composer:
root@ku:/data/php# composer selfupdate
You are already using composer version 2.0.8 (stable channel).

 

3,测试安装thinkphp6:
liuhongdi@ku:/data/php$ composer create-project topthink/think mytp
Creating a "topthink/think" project at "./mytp"
Installing topthink/think (v6.0.5)
  - Downloading topthink/think (v6.0.5)
  - Installing topthink/think (v6.0.5): Extracting archive
Created project in /data/php/mytp
Loading composer repositories with package information
Updating dependencies
Lock file operations: 15 installs, 0 updates, 0 removals
  - Locking league/flysystem (1.1.3)
  - Locking league/flysystem-cached-adapter (1.1.0)
  - Locking league/mime-type-detection (1.5.1)
  - Locking psr/cache (1.0.1)
  - Locking psr/container (1.0.0)
  - Locking psr/log (1.1.3)
  - Locking psr/simple-cache (1.0.1)
  - Locking symfony/polyfill-mbstring (v1.20.0)
  - Locking symfony/polyfill-php72 (v1.20.0)
  - Locking symfony/polyfill-php80 (v1.20.0)
  - Locking symfony/var-dumper (v4.4.18)
  - Locking topthink/framework (v6.0.5)
  - Locking topthink/think-helper (v3.1.4)
  - Locking topthink/think-orm (v2.0.34)
  - Locking topthink/think-trace (v1.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 15 installs, 0 updates, 0 removals
  - Downloading psr/cache (1.0.1)
  - Downloading league/mime-type-detection (1.5.1)
  - Downloading league/flysystem (1.1.3)
  - Downloading league/flysystem-cached-adapter (1.1.0)
  - Downloading psr/container (1.0.0)
  - Downloading symfony/polyfill-php80 (v1.20.0)
  - Downloading symfony/polyfill-php72 (v1.20.0)
  - Downloading symfony/polyfill-mbstring (v1.20.0)
  - Downloading symfony/var-dumper (v4.4.18)
  - Downloading topthink/think-helper (v3.1.4)
  - Downloading psr/simple-cache (1.0.1)
  - Downloading psr/log (1.1.3)
  - Downloading topthink/think-orm (v2.0.34)
  - Downloading topthink/framework (v6.0.5)
  - Downloading topthink/think-trace (v1.4)
  - Installing psr/cache (1.0.1): Extracting archive
  - Installing league/mime-type-detection (1.5.1): Extracting archive
  - Installing league/flysystem (1.1.3): Extracting archive
  - Installing league/flysystem-cached-adapter (1.1.0): Extracting archive
  - Installing psr/container (1.0.0): Extracting archive
  - Installing symfony/polyfill-php80 (v1.20.0): Extracting archive
  - Installing symfony/polyfill-php72 (v1.20.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.20.0): Extracting archive
  - Installing symfony/var-dumper (v4.4.18): Extracting archive
  - Installing topthink/think-helper (v3.1.4): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing psr/log (1.1.3): Extracting archive
  - Installing topthink/think-orm (v2.0.34): Extracting archive
  - Installing topthink/framework (v6.0.5): Extracting archive
  - Installing topthink/think-trace (v1.4): Extracting archive
13 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
Succeed!
6 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

 

查看已安装的thinkphp
liuhongdi@ku:/data/php$ cd mytp
liuhongdi@ku:/data/php/mytp$ ls
app  composer.json  composer.lock  config  extend  LICENSE.txt  public  README.md  route  runtime  think  vendor  view
测试运行thinkphp6
root@ku:/etc/nginx/sites-enabled# cd /data/php/mytp/
root@ku:/data/php/mytp# php think run
ThinkPHP Development server is started On <http://127.0.0.1:8000/>
You can exit with `CTRL-C`
Document root is: /data/php/mytp/public
[Tue Dec 22 15:44:01 2020] PHP 7.4.9 Development Server (http://0.0.0.0:8000) started
从浏览器访问:
http://127.0.0.1:8000/
返回:
 

四,查看linux的版本:

root@ku:/data/php# more /etc/os-release
NAME="Ubuntu Kylin"
VERSION="20.10 (Groovy Gorilla)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.10"
VERSION_ID="20.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy 

 

posted @ 2020-12-22 16:07  刘宏缔的架构森林  阅读(1234)  评论(0编辑  收藏  举报