composer install cakephp in ubuntu 18.04

ubuntu 18.04上安装 composer

https://blog.csdn.net/u011944141/article/details/79569917

安装 cakephp

 composer create-project --prefer-dist cakephp/app my_php_cake

提示信息如下:

    Installing cakephp/app (3.7.1)
      - Installing cakephp/app (3.7.1): Downloading (100%)         
    Created project in my_php_cake
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    
    
    
    
    
    
    
    
    
    
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - cakephp/cakephp 3.7.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - cakephp/cakephp 3.7.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
        - Installation request for cakephp/cakephp 3.7.* -> satisfiable by cakephp/cakephp[3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7].
    
      To enable extensions, verify that they are enabled in your .ini files:
        - /etc/php/7.2/cli/php.ini
        - /etc/php/7.2/cli/conf.d/10-opcache.ini
        - /etc/php/7.2/cli/conf.d/10-pdo.ini
        - /etc/php/7.2/cli/conf.d/15-xml.ini
        - /etc/php/7.2/cli/conf.d/20-bcmath.ini
        - /etc/php/7.2/cli/conf.d/20-bz2.ini
        - /etc/php/7.2/cli/conf.d/20-calendar.ini
        - /etc/php/7.2/cli/conf.d/20-ctype.ini
        - /etc/php/7.2/cli/conf.d/20-curl.ini
        - /etc/php/7.2/cli/conf.d/20-dom.ini
        - /etc/php/7.2/cli/conf.d/20-exif.ini
        - /etc/php/7.2/cli/conf.d/20-fileinfo.ini
        - /etc/php/7.2/cli/conf.d/20-ftp.ini
        - /etc/php/7.2/cli/conf.d/20-gd.ini
        - /etc/php/7.2/cli/conf.d/20-gettext.ini
        - /etc/php/7.2/cli/conf.d/20-iconv.ini
        - /etc/php/7.2/cli/conf.d/20-igbinary.ini
        - /etc/php/7.2/cli/conf.d/20-json.ini
        - /etc/php/7.2/cli/conf.d/20-mbstring.ini
        - /etc/php/7.2/cli/conf.d/20-msgpack.ini
        - /etc/php/7.2/cli/conf.d/20-pdo_pgsql.ini
        - /etc/php/7.2/cli/conf.d/20-pgsql.ini
        - /etc/php/7.2/cli/conf.d/20-phar.ini
        - /etc/php/7.2/cli/conf.d/20-posix.ini
        - /etc/php/7.2/cli/conf.d/20-readline.ini
        - /etc/php/7.2/cli/conf.d/20-redis.ini
        - /etc/php/7.2/cli/conf.d/20-shmop.ini
        - /etc/php/7.2/cli/conf.d/20-simplexml.ini
        - /etc/php/7.2/cli/conf.d/20-sockets.ini
        - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
        - /etc/php/7.2/cli/conf.d/20-sysvsem.ini
        - /etc/php/7.2/cli/conf.d/20-sysvshm.ini
        - /etc/php/7.2/cli/conf.d/20-tokenizer.ini
        - /etc/php/7.2/cli/conf.d/20-wddx.ini
        - /etc/php/7.2/cli/conf.d/20-xmlreader.ini
        - /etc/php/7.2/cli/conf.d/20-xmlwriter.ini
        - /etc/php/7.2/cli/conf.d/20-xsl.ini
        - /etc/php/7.2/cli/conf.d/20-zip.ini
        - /etc/php/7.2/cli/conf.d/25-memcached.ini
      You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

上边的问题其实从下边这句找出

  Problem 1
        - cakephp/cakephp 3.7.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.

结论缺少 php-intl 扩展

安装缺少的php-intl扩展

$sudo apt-get install php7.2-intl

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-image-4.15.0-47-generic linux-modules-4.15.0-47-generic linux-modules-extra-4.15.0-47-generic linux-tools-4.15.0-47 linux-tools-4.15.0-47-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  php7.2-intl
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 124 kB of archives.
After this operation, 512 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 php7.2-intl amd64 7.2.17-0ubuntu0.18.04.1 [124 kB]
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 php7.2-intl amd64 7.2.17-0ubuntu0.18.04.1 [124 kB]                                                              
Fetched 123 kB in 52s (2,377 B/s)     
Selecting previously unselected package php7.2-intl.
(Reading database ... 316636 files and directories currently installed.)
Preparing to unpack .../php7.2-intl_7.2.17-0ubuntu0.18.04.1_amd64.deb ...
Unpacking php7.2-intl (7.2.17-0ubuntu0.18.04.1) ...
Processing triggers for php7.2-fpm (7.2.17-0ubuntu0.18.04.1) ...
Setting up php7.2-intl (7.2.17-0ubuntu0.18.04.1) ...

Creating config file /etc/php/7.2/mods-available/intl.ini with new version
Processing triggers for libapache2-mod-php7.2 (7.2.17-0ubuntu0.18.04.1) ...
Warning: Could not load Apache 2.4 maintainer script helper.
Processing triggers for php7.2-fpm (7.2.17-0ubuntu0.18.04.1) ...

再次安装

$  composer create-project --prefer-dist cakephp/app my_php_cake

Installing cakephp/app (3.7.1)

In ProjectInstaller.php line 65:
                                                
  Project directory my_php_cake/ is not empty.  
                                                

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

出现这个是因为在my_php_cake 目录下已经有 composer.jon 文件了,故而只需 命令行只需 composer install 即可

执行composer install --no-dev

$ composer install --no-dev
Loading composer repositories with package information
Updating dependencies
Package operations: 18 installs, 0 updates, 0 removals
  - Installing cakephp/plugin-installer (1.1.0): Downloading (100%)         
  - Installing aura/intl (3.0.0): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing zendframework/zend-diactoros (1.8.6): Downloading (100%)         
  - Installing psr/simple-cache (1.0.1): Downloading (100%)         
  - Installing psr/log (1.1.0): Downloading (100%)         
  - Installing cakephp/chronos (1.2.5): Downloading (100%)         
  - Installing cakephp/cakephp (3.7.7): Downloading (100%)         
  - Installing symfony/polyfill-ctype (v1.11.0): Downloading (100%)         
  - Installing symfony/yaml (v4.2.8): Downloading (100%)         
  - Installing symfony/filesystem (v4.2.8): Downloading (100%)         
  - Installing symfony/config (v4.2.8): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.11.0): Downloading (100%)         
  - Installing symfony/contracts (v1.1.0): Downloading (100%)         
  - Installing symfony/console (v4.2.8): Downloading (100%)         
  - Installing robmorgan/phinx (0.10.7): Downloading (100%)         
  - Installing cakephp/migrations (2.1.1): Downloading (100%)         
  - Installing mobiledetect/mobiledetectlib (2.8.33): Downloading (100%)         
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump

执行cake官方命令

    HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
    setfacl -R -m u:${HTTPDUSER}:rwx tmp
    setfacl -R -d -m u:${HTTPDUSER}:rwx tmp
    setfacl -R -m u:${HTTPDUSER}:rwx logs
    setfacl -R -d -m u:${HTTPDUSER}:rwx logs
	chmod +x bin/cake
php bin/cake.php

#提示信息
$ php bin/cake.php
Exception: Plugin DebugKit\Plugin could not be found. in [/var/www/my_php_cake/vendor/cakephp/cakephp/src/Core/PluginCollection.php, line 127]

然后安装 cakephp/debug_kit

composer require cakephp/debug_kit

$ composer require cakephp/debug_kit
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
^C
jinbo@jinbo-Latitude-E5440:/var/www/my_php_cake$ composer require cakephp/debug_kit --prefer-dist
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
^C
jinbo@jinbo-Latitude-E5440:/var/www/my_php_cake$ composer require cakephp/debug_kit
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 59 installs, 0 updates, 0 removals
  - Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)         
  - Installing symfony/process (v4.2.8): Downloading (100%)         
  - Installing symfony/finder (v4.2.8): Downloading (100%)         
  - Installing seld/phar-utils (1.0.1): Downloading (100%)         
  - Installing seld/jsonlint (1.7.1): Downloading (100%)         
  - Installing justinrainbow/json-schema (5.2.8): Downloading (100%)         
  - Installing composer/xdebug-handler (1.3.2): Downloading (100%)         
  - Installing composer/spdx-licenses (1.5.1): Downloading (100%)         
  - Installing composer/semver (1.5.0): Downloading (100%)         
  - Installing composer/ca-bundle (1.1.4): Downloading (100%)         
  - Installing composer/composer (1.8.5): Downloading (100%)         
  - Installing cakephp/debug_kit (3.18.0): Downloading (100%)         
  - Installing twig/twig (v1.41.0): Downloading (100%)         
  - Installing umpirsky/twig-php-function (v0.1): Downloading (100%)         
  - Installing jasny/twig-extensions (v1.2.0): Downloading (100%)         
  - Installing asm89/twig-cache-extension (1.3.2): Downloading (100%)         
  - Installing aptoma/twig-markdown (2.0.0): Downloading (100%)         
  - Installing ajgl/breakpoint-twig-extension (0.3.4): Downloading (100%)         
  - Installing wyrihaximus/twig-view (4.3.8): Downloading (100%)         
  - Installing cakephp/bake (1.9.6): Downloading (100%)         
  - Installing squizlabs/php_codesniffer (3.4.2): Downloading (100%)         
  - Installing cakephp/cakephp-codesniffer (3.1.1): Downloading (100%)         
  - Installing m1/env (2.1.2): Downloading (100%)         
  - Installing josegonzalez/dotenv (3.2.0): Downloading (100%)         
  - Installing sebastian/version (2.0.1): Downloading (100%)         
  - Installing sebastian/resource-operations (1.0.0): Downloading (100%)         
  - Installing sebastian/recursion-context (3.0.0): Downloading (100%)         
  - Installing sebastian/object-reflector (1.1.1): Downloading (100%)         
  - Installing sebastian/object-enumerator (3.0.3): Downloading (100%)         
  - Installing sebastian/global-state (2.0.0): Downloading (100%)         
  - Installing sebastian/exporter (3.1.0): Downloading (100%)         
  - Installing sebastian/environment (3.1.0): Downloading (100%)         
  - Installing sebastian/diff (2.0.1): Downloading (100%)         
  - Installing sebastian/comparator (2.1.3): Downloading (100%)         
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)         
  - Installing doctrine/instantiator (1.2.0): Downloading (100%)         
  - Installing phpunit/phpunit-mock-objects (5.0.10): Downloading (100%)         
  - Installing phpunit/php-timer (1.0.9): Downloading (100%)         
  - Installing phpunit/php-file-iterator (1.4.5): Downloading (100%)         
  - Installing theseer/tokenizer (1.1.2): Downloading (100%)         
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)         
  - Installing phpunit/php-token-stream (2.0.2): Downloading (100%)         
  - Installing phpunit/php-code-coverage (5.3.2): Downloading (100%)         
  - Installing webmozart/assert (1.4.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (4.3.1): Downloading (100%)         
  - Installing phpspec/prophecy (1.8.0): Downloading (100%)         
  - Installing phar-io/version (1.0.1): Downloading (100%)         
  - Installing phar-io/manifest (1.0.1): Downloading (100%)         
  - Installing myclabs/deep-copy (1.9.1): Downloading (100%)         
  - Installing phpunit/phpunit (6.5.14): Downloading (100%)         
  - Installing jakub-onderka/php-console-color (v0.2): Downloading (100%)         
  - Installing jakub-onderka/php-console-highlighter (v0.4): Downloading (100%)         
  - Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)         
  - Installing nikic/php-parser (v4.2.1): Downloading (100%)         
  - Installing symfony/polyfill-php72 (v1.11.0): Downloading (100%)         
  - Installing symfony/var-dumper (v4.2.8): Downloading (100%)         
  - Installing psy/psysh (v0.9.9): Downloading (100%)         
cakephp/debug_kit suggests installing ext-pdo_sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
asm89/twig-cache-extension suggests installing psr/cache-implementation (To make use of PSR-6 cache implementation via PsrCacheAdapter.)
aptoma/twig-markdown suggests installing michelf/php-markdown (Original Markdown engine with MarkdownExtra.)
aptoma/twig-markdown suggests installing knplabs/github-api (Needed for using GitHub's Markdown engine provided through their API.)
ajgl/breakpoint-twig-extension suggests installing ext-xdebug (The Xdebug extension is required for the breakpoint to work)
ajgl/breakpoint-twig-extension suggests installing symfony/framework-bundle (The framework bundle to integrate the extension into Symfony)
ajgl/breakpoint-twig-extension suggests installing symfony/twig-bundle (The twig bundle to integrate the extension into Symfony)
m1/env suggests installing m1/vars (For loading of configs)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump

在执行 php bin/cake.php

php bin/cake.php
No command provided. Choose one of the available commands.

Current Paths:

* app:  src/
* root: /var/www/my_php_cake/
* core: /var/www/my_php_cake/vendor/cakephp/cakephp/

Available Commands:

- bake
- benchmark
- cache
- compile
- completion
- console
- whitespace
- help
- i18n
- migrations
- orm_cache
- plugin
- routes
- schema_cache
- server
- version

To run a command, type `cake command_name [args|options]`
To get help on a specific command, type `cake command_name --help`

执行 bin/cake server

$ bin/cake server

Welcome to CakePHP v3.7.7 Console
---------------------------------------------------------------
App : src
Path: /var/www/my_php_cake/src/
DocumentRoot: /var/www/my_php_cake/webroot
Ini Path: 
---------------------------------------------------------------
built-in server is running in http://localhost:8765/
You can exit with `CTRL-C`
[Fri May 17 16:18:11 2019] 127.0.0.1:38072 [200]: /css/base.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38076 [200]: /css/style.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38080 [200]: /css/home.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38084 [200]: /img/cake.logo.svg
[Fri May 17 16:18:11 2019] 127.0.0.1:38090 [200]: /font/cakedingbats-webfont.woff2
[Fri May 17 16:18:12 2019] 127.0.0.1:38096 [200]: /favicon.ico

浏览器访问 http://localhost:8765/

在这里插入图片描述
出现这个就标志成功啦

nginx 配置域名访问

$ cat cakephp.conf 
server {
    charset UTF-8;

    listen  	 80;
    #listen 	 443 ssl;
    server_name	 cake.php.com;

    if ( $http_cookie ~* "(.*)$") {
    	set $qcookie $1;
    }

    root   /var/www/my_php_cake/webroot;
    index  index.php;

    access_log /var/www/my_php_cake/logs/access.log;
    error_log /var/www/my_php_cake/logs/error.log;
    
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    if ( $fastcgi_script_name ~ \..*\/.*php ) {
        return 403;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_pass   unix:/run/php/php7.2-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_intercept_errors on;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

配置 host

127.0.0.1 cake.php.com

访问 https://cake.php.com

成功的出现了上边的截图

参考文献

https://book.cakephp.org/3.0/en/installation.html
https://pkg.phpcomposer.com/
https://docs.phpcomposer.com/03-cli.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值