Linux使用composer安装TP5.1

配置Linux的环境简直想吐血,我这里进行了重复更新和安装,就是因为环境问题
安装请我之前的文章:

https://blog.csdn.net/qq_42914232/article/details/103011978

一:首先确保PHP环境变量存在,才能执行PHP文件

[root@VM_0_26_centos 129]# php -v
PHP 7.2.18 (cli) (built: May  6 2019 11:33:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

如果执行不成功,需要将PHP位置加入到环境变量或者将PHP链接到环境变量里的目录。
怎么执行百度,我这里成功了的

二:下载composer可执行文件,并移动到环境变量的目录中。注意目录是否存在

[root@VM_0_26_centos ~]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.9.1) successfully installed to: /root/composer.phar
Use it: php composer.phar
[root@VM_0_26_centos 129.28.193.221]# mv composer.phar /usr/local/bin/composer

三:切换到国内镜像

[root@VM_0_26_centos ~]# composer config -g repo.packagist composer https://packagist.phpcomposer.com

四:更新自身

[root@VM_0_26_centos ~]# composer self-update
You are already using composer version 1.9.1 (stable channel).

五:安装TP5.1

[root@VM_0_26_centos ~]# cd /
[root@VM_0_26_centos /]# ll
total 108
lrwxrwxrwx.   1 root root     7 Mar  7  2019 bin -> usr/bin
dr-xr-xr-x.   5 root root  4096 Oct 22 15:59 boot
-rw-r--r--    1 root root     4 Nov  8 17:13 composer.json
drwxr-xr-x    2 root root  4096 Mar 12  2019 data
drwxr-xr-x   19 root root  3000 Nov 12 11:21 dev
drwxr-xr-x.  88 root root  4096 Nov  8 16:24 etc
drwxr-xr-x.   3 root root  4096 Aug  3 15:36 home
-rw-r--r--    1 root root 19788 Aug  3 09:32 install.sh
lrwxrwxrwx.   1 root root     7 Mar  7  2019 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Mar  7  2019 lib64 -> usr/lib64
drwx------.   2 root root 16384 Mar  7  2019 lost+found
drwxr-xr-x.   2 root root  4096 Apr 11  2018 media
drwxr-xr-x.   2 root root  4096 Apr 11  2018 mnt
drwxr-xr-x   15 root root  4096 Nov  8 16:26 node_modules
drwxr-xr-x.   3 root root  4096 Mar  7  2019 opt
drwxr-xr-x    2 root root  4096 Aug  3 15:36 patch
drwxr-xr-x    3 www  www   4096 Nov 12 10:09 path
dr-xr-xr-x  120 root root     0 Nov 12 11:20 proc
drwxr-xr-x    7 root root  4096 Nov  8 15:10 pywebsocket
dr-xr-x---.  10 root root  4096 Nov 12 14:09 root
drwxr-xr-x   25 root root   860 Nov 12 11:27 run
lrwxrwxrwx.   1 root root     8 Mar  7  2019 sbin -> usr/sbin
drwxr-xr-x.   2 root root  4096 Apr 11  2018 srv
dr-xr-xr-x   13 root root     0 Nov 12 11:20 sys
drwxrwxrwt.  10 root root  4096 Nov 12 14:10 tmp
drwxr-xr-x.  13 root root  4096 Mar  7  2019 usr
drwxr-xr-x.  19 root root  4096 Aug  3 15:34 var
drwxr-xr-x    7 root root  4096 Nov  6 14:11 www
[root@VM_0_26_centos /]# cd www
[root@VM_0_26_centos www]# ll
total 1049624
drwxr-xr-x 5 root root       4096 Aug  3 15:34 backup
drwxrwxrwx 6 root root       4096 Nov 12 11:15 Recycle_bin
drwxr-xr-x 9 root root       4096 Oct 23 14:10 server
-rw-r--r-- 1 root root 1074790400 Aug  3 15:29 swap
drwxrwxrwx 3 root root       4096 Nov  1 16:01 wwwlogs
drwxr-xr-x 3 root root       4096 Nov  1 16:01 wwwroot
[root@VM_0_26_centos www]# cd wwwroot
[root@VM_0_26_centos wwwroot]# ll
total 4
drwxr-xr-x 8 www www 4096 Nov 12 11:15 129
[root@VM_0_26_centos wwwroot]# cd 129
[root@VM_0_26_centos 129]# ll
total 1108
-rwxr-xr-x 1 www  www     479 Nov  1 16:01 404.html
-rw-r--r-- 1 root root 960311 Jan  7  2014 composer.phar
-rw-r--r-- 1 root root 139264 Nov 11 16:08 composer-setup.php
-rwxr-xr-x 1 www  www    1558 Nov  8 15:15 GetPost.php
drwxr-xr-x 2 www  www    4096 Nov 11 15:50 Ratchet
drwxr-xr-x 6 root root   4096 Nov 11 15:27 Ratchet-examples
drwxr-xr-x 2 www  www    4096 Nov  8 10:08 shell
drwxr-xr-x 2 www  www    4096 Nov 12 11:13 tp5
drwxr-xr-x 4 root root   4096 Nov 11 14:58 websocket_deemo
drwxr-xr-x 6 root root   4096 Nov 12 09:41 websocket_deemo1
[root@VM_0_26_centos 129]# composer create-project topthink/think tp5
Installing topthink/think (v6.0.0)
  - Installing topthink/think (v6.0.0): Downloading (100%)
Created project in tp5
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 14 installs, 0 updates, 0 removals
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing topthink/think-helper (v3.1.3): Downloading (100%)
  - Installing psr/log (1.1.2): Downloading (100%)
  - Installing psr/simple-cache (1.0.1): Downloading (100%)
  - Installing topthink/think-orm (v2.0.27): Downloading (100%)
  - Installing symfony/polyfill-php72 (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.12.0): Downloading (100%)
  - Installing symfony/var-dumper (v4.3.7): Downloading (100%)
  - Installing opis/closure (3.4.1): Downloading (100%)
  - Installing psr/cache (1.0.1): Downloading (100%)
  - Installing league/flysystem (1.0.46): Downloading (100%)
  - Installing league/flysystem-cached-adapter (1.0.9): Downloading (100%)
  - Installing topthink/framework (v6.0.0): Downloading (100%)
  - Installing topthink/think-trace (v1.2): Downloading (100%)
symfony/var-dumper suggests installing symfony/console (To use the ServerDumpCommand and/or the bin/var-dump-server script)
league/flysystem suggests installing ext-fileinfo (Required for MimeType)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
league/flysystem-cached-adapter suggests installing ext-phpredis (Pure C implemented extension for PHP)
Writing lock file
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
Succeed!
[root@VM_0_26_centos 129]#

好了,下载完成了
其中composer create-project topthink/think tp5这句来自于TP5.1官方文档
剩下的就是将东西移动到根目录mv tp5/ .
然后将权限-所有者,改为wwwchown www.www -R
然后删掉临时目录rm runtime -fr
这样apache指定的www会自动创建,就不会有权限问题了。
六:Apache配置
将网站的apache配置文件中的,DocumentRoot 后面的路径追加/public。
重启apache服务使配置文件生效。

你可能感兴趣的:(linux)