Crazy lens

Docker 安装 FastAdmin 开发环境踩坑
直接下载我准备好的 docker 镜像git clone

Docker 安装 FastAdmin 开发环境踩坑

直接下载我准备好的 docker 镜像

git clone

安装 centos 7 操作系统 内部的 DockerFile yum 及 编译一些基础库

cd centos 
cd ..


cd php-build 
cd .. 

docker compose 构建开发环境

cd 进入 2.lnmp-example 找到 docker-compose.yml 就可以构建了

# 构建
docker-compose up -d --build 

# down
docker-compose down

先看下 docker-compose.yml 配置

version: "3.3"

    build: ./nginx
      - "8899:80"
      - ./nginx/logs:/var/logs/nginx/:rw
      - backend

    build: ./cgi
      - "9000"
    tty: true
      - ./cgi/MyAdmin:/var/www
       - backend

    image: "mysql:5.7"
      - "3306:3306"
      - ./mysql:/data/mysql 
      - ./mysql/conf:/etc/mysql/conf.d
      - ./mysql/logs:/logs
      - ./mysql/data:/var/lib/mysql 
      - MYSQL_ROOT_PASSWORD=123456
      - backend
    image: "redis"
      - "6379:6379"
      - backend


上面的配置参数可以在我其他docker相关文章中找到注释, 这里不详细介绍了.

开始搞起 FastAdmin

官方文档 :

1. 克隆FastAdmin到你本地

mkdir -p 2.lnmp-example/cgi/MyAdmin
cd 2.lnmp-example/cgi/MyAdmin

# git 拉取代码
git clone

# 文件移动上来
mv fastadmin/* ./ 

cginginx 中配置 已经将默认工作目录指定为 /var/www , 在 docker-compose.yml 中已经共享文件的方式 cgi/MyAdmin:/var/www

2. 下载前端插件依赖包

# bower install 指令抛错 提示可以授权root

root@123: bower install --allow-root​

Unable to find a suitable version for jspdf, please choose one by typing one of the numbers below:
    1) jspdf#~1.0.178 which resolved to 1.0.272 and is required by jspdf-autotable#2.0.17
    2) jspdf#1.3.2 - 1.3.4 which resolved to 1.3.4 and is required by tableExport.jquery.plugin#1.10.14

Prefix the choice with ! to persist it to bower.json

? Answer 1
bower install       jquery.cookie#1.4.1
bower install       toastr#2.1.3
bower install       fastadmin-addtabs#1.0.4
bower install       bootstrap-select#1.11.2
bower install       require-css#0.1.10
bower install       fastadmin-layer#3.1.3
bower install       jcrop#2.0.4
bower install       bootstrap-table#1.11.3
bower install       nice-validator#1.1.4
bower install       art-template#3.1.3
bower install       bootstrap-slider#879a98dcd0
bower install       fastadmin-dragsort#1.0.0
bower install       fastadmin-cxselect#1.4.1
bower install       jquery-slimscroll#1.3.8
bower install       fastadmin-selectpage#1.0.2
bower install       bootstrap-daterangepicker#2.1.27
bower install       plupload#2.2.1
bower install       requirejs-plugins#1.0.3
bower install       jquery#2.2.4
bower install       fastadmin-citypicker#1.3.2
bower install       Sortable#1.10.2
bower install       jstree#3.3.8
bower install       moment#2.24.0
bower install       less#2.7.3
bower install       eonasdan-bootstrap-datetimepicker#4.17.47
bower install       tableExport.jquery.plugin#1.10.14
bower install       file-saver#2.0.2
bower install       es6-promise#4.2.4
bower install       html2canvas#0.4.1
bower install       jspdf-autotable#2.0.17
bower install       font-awesome#4.7.0
bower install       jspdf#1.0.272
bower install       bootstrap#3.4.1

jquery.cookie#1.4.1 bower_components/jquery.cookie
└── jquery#2.2.4

toastr#2.1.3 bower_components/toastr
└── jquery#2.2.4

fastadmin-addtabs#1.0.4 bower_components/fastadmin-addtabs

bootstrap-select#1.11.2 bower_components/bootstrap-select
└── jquery#2.2.4

require-css#0.1.10 bower_components/require-css

fastadmin-layer#3.1.3 bower_components/fastadmin-layer

jcrop#2.0.4 bower_components/jcrop

bootstrap-table#1.11.3 bower_components/bootstrap-table

nice-validator#1.1.4 bower_components/nice-validator
└── jquery#2.2.4

art-template#3.1.3 bower_components/art-template

bootstrap-slider#879a98dcd0 bower_components/bootstrap-slider

fastadmin-dragsort#1.0.0 bower_components/fastadmin-dragsort
└── jquery#2.2.4

fastadmin-cxselect#1.4.1 bower_components/fastadmin-cxselect

jquery-slimscroll#1.3.8 bower_components/jquery-slimscroll

fastadmin-selectpage#1.0.2 bower_components/fastadmin-selectpage

bootstrap-daterangepicker#2.1.27 bower_components/bootstrap-daterangepicker
├── jquery#2.2.4
└── moment#2.24.0

plupload#2.2.1 bower_components/plupload

requirejs-plugins#1.0.3 bower_components/requirejs-plugins

jquery#2.2.4 bower_components/jquery

fastadmin-citypicker#1.3.2 bower_components/fastadmin-citypicker
└── jquery#2.2.4

Sortable#1.10.2 bower_components/Sortable

jstree#3.3.8 bower_components/jstree
└── jquery#2.2.4

moment#2.24.0 bower_components/moment

less#2.7.3 bower_components/less

eonasdan-bootstrap-datetimepicker#4.17.47 bower_components/eonasdan-bootstrap-datetimepicker
├── jquery#2.2.4
└── moment#2.24.0

tableExport.jquery.plugin#1.10.14 bower_components/tableExport.jquery.plugin
├── es6-promise#4.2.4
├── file-saver#2.0.2
├── html2canvas#0.4.1
├── jquery#2.2.4
├── jspdf#1.0.272
└── jspdf-autotable#2.0.17

file-saver#2.0.2 bower_components/file-saver

es6-promise#4.2.4 bower_components/es6-promise

html2canvas#0.4.1 bower_components/html2canvas

jspdf-autotable#2.0.17 bower_components/jspdf-autotable
└── jspdf#1.0.272

font-awesome#4.7.0 bower_components/font-awesome

jspdf#1.0.272 bower_components/jspdf

bootstrap#3.4.1 bower_components/bootstrap
└── jquery#2.2.4

3. 下载PHP依赖包 composer install

composer 用过的朋友们都知道国内非常慢. 通过修改 composer.json 添加

  "repositories": {
    "packagist": {
      "type": "composer",
      "url": ""

也可以在项目目录下 使用指令 `
composer config repo.packagist composer 会追加在 composer.json` 文件中.

诶 这个依赖库太夸张了 太多了.... 老家网速也不给力快1小时了...... 用国内加速也是很给力....

[root@95fe8e8bf9b4 www]# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

Package operations: 30 installs, 0 updates, 0 removals
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
  - Installing topthink/think-installer (v1.0.12): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.13.1): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing paragonie/random_compat (v9.99.99): Downloading (100%)         
  - Installing symfony/polyfill-php70 (v1.13.1): Downloading (100%)         
  - Installing symfony/http-foundation (v3.4.37): Downloading (100%)         
  - Installing symfony/psr-http-message-bridge (v1.2.0): Downloading (100%)         
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.5.2): Downloading (100%)         
  - Installing doctrine/cache (v1.4.4): Downloading (100%)         
  - Installing overtrue/socialite (1.3.0): Downloading (100%)         
  - Installing psr/log (1.1.2): Downloading (100%)         
  - Installing monolog/monolog (1.25.3): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing pimple/pimple (v3.2.3): Downloading (100%)         
  - Installing overtrue/wechat (3.3.33): Downloading (100%)         
  - Installing symfony/options-resolver (v3.4.37): Downloading (100%)         
  - Installing endroid/qr-code (1.9.3): Downloading (100%)         
  - Installing topthink/framework (v5.0.24): Downloading (100%)         
  - Installing topthink/think-captcha (v1.0.8): Downloading (connecting...)

Downloading (100%)         
  - Installing mtdowling/cron-expression (v1.2.3): Downloading (100%)         
  - Installing phpmailer/phpmailer (v5.2.27): Downloading (100%)         
  - Installing karsonzhang/fastadmin-addons (1.1.10): Downloading (100%)         
  - Installing overtrue/pinyin (3.0.6): Downloading (100%)         
  - Installing psr/simple-cache (1.0.1): Downloading (100%)         
  - Installing markbaker/matrix (1.2.0): Downloading (100%)         
  - Installing markbaker/complex (1.4.7): Downloading (100%)         
  - Installing phpoffice/phpspreadsheet (1.10.1): Downloading (60%)          

Downloading (100%)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/psr-http-message-bridge suggests installing nyholm/psr7 (For a super lightweight PSR-7/17 implementation)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
guzzlehttp/guzzle suggests installing ext-intl (Required for Internationalized Domain Name (IDN) support)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
phpmailer/phpmailer suggests installing league/oauth2-google (Needed for Google XOAUTH2 authentication)
phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing dompdf/dompdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing tecnickcom/tcpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for rendering charts, or including charts with PDF or HTML Writers)
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Writing lock file
Generating autoload files

4. 一键创建数据库并导入数据

 php think install -u 数据库用户名 -p 数据库密码

不懂就 php think help install



对了有个很坑的地方 如果使用 nginx 自己配置对我来说有些困难 从网上找都不靠谱 还是看官方文档 例子如下: ...

server {
        listen       80;
        server_name *;
        root   "C:/phpstudy/WWW/fastadmin/public";
        location / {
            index  index.html index.htm index.php;
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
            #autoindex  on;
        location ~ \.php(.*)$ {
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
最后修改:2020 年 01 月 28 日 10 : 11 AM


1 条评论

  1. 刘打野