文章851
标签121
分类10

Docker 安装 FastAdmin 开发环境踩坑

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

git clone https://github.com/libenfu/docker-example.git

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

cd centos 
sh build.sh 
cd ..

构建php

cd php-build 
sh build.sh
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"

services:
  nginx:
    build: ./nginx
    ports:
      - "8899:80"
    volumes:
      - ./nginx/logs:/var/logs/nginx/:rw
    networks:
      - backend

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

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

networks:
  backend:

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

开始搞起 FastAdmin

官方文档 : https://doc.fastadmin.net/doc/install.html

1. 克隆FastAdmin到你本地

#创建项目目录
mkdir -p 2.lnmp-example/cgi/MyAdmin
cd 2.lnmp-example/cgi/MyAdmin

# git 拉取代码
git clone https://gitee.com/karson/fastadmin.git

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

cgi 和 `nginx 中配置 已经将默认工作目录指定为 /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": "https://packagist.phpcomposer.com"
    }
  }
}

也可以在项目目录下 使用指令 composer config repo.packagist composer https://packagist.phpcomposer.com 会追加在 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 自己配置对我来说有些困难 从网上找都不靠谱 还是看官方文档 例子如下: ...
https://doc.fastadmin.net/docs/faq.html#toc-18

server {
        listen       80;
        server_name  www.fa.com *.fa.com;
        root   "C:/phpstudy/WWW/fastadmin/public";
        location / {
            index  index.html index.htm index.php;
            #主要是这一段一定要确保存在
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
            #结束
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            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;
        }
}

解决 configure: WARNING: unrecognized options: `--with-mcrypt`, `--enable-gd-native-ttf`

解决 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf

在进行软件编译和安装时,有时会遇到类似 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf 这样的警告信息,提示一些配置选项未被识别。本文将介绍如何解决这个警告以及可能导致它出现的原因。

原因分析

出现 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf 警告的原因可能是:

  1. 配置选项已被弃用:一些配置选项可能已经被弃用或不再支持,导致 configure 脚本无法识别。
  2. 软件版本差异:某些配置选项可能只适用于特定版本的软件,而当前使用的版本可能不支持这些选项。
  3. 错误的配置选项:可能是由于手动指定了错误的配置选项,或者错字导致的无法识别。

解决方法

针对 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf 警告,我们可以尝试以下解决方法:

  1. 查看文档:查阅相关软件的官方文档,了解当前版本支持的配置选项,确认所使用的配置是否合法。
  2. 更新软件:如果是因为版本问题导致的警告,可以尝试更新软件到最新版本,查看是否支持所需配置选项。
  3. 移除无效选项:将警告中提到的无法识别的选项从配置命令中移除,然后重新运行 configure 脚本。
  4. 查找替代方案:如果所需的选项已经被弃用或不再支持,可以尝试查找替代方案来实现相同的功能。

文献引用

在解决类似问题时,以下资源可能会提供帮助:

  1. 软件官方文档:查阅相关软件的官方文档,了解支持的配置选项和最佳实践。
  2. Stack Overflow:在开发者社区中搜索类似问题,查看其他开发者的解决方案和经验分享。

这些资源提供了关于软件配置和解决警告的一些实用信息和建议。

通过合理利用这些解决方法,我们可以有效地解决 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf 警告,顺利进行软件的编译和安装。


通过分析和解决 configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf 警告,我们可以更好地处理软件编译过程中遇到的问题,提高开发效率和软件质量。

解决 MySQL "Table doesn't exist" 错误

解决 MySQL "Table doesn't exist" 错误

在使用 MySQL 数据库时,有时会遇到 "Table doesn't exist"(表不存在)的错误。这个错误通常是由于尝试访问不存在的表而引起的。本文将介绍可能导致这个错误的原因以及如何解决它。

原因分析

出现 "Table doesn't exist" 错误的原因可能有多种,包括但不限于:

  1. 表名拼写错误:可能是由于表名拼写错误导致的,例如大小写不匹配、多余的空格等。
  2. 表被删除或重命名:可能是由于表被意外删除或重命名,导致无法访问。
  3. 数据库选择问题:可能是因为没有选择正确的数据库,导致无法找到相应的表。
  4. 权限问题:可能是由于当前用户没有权限访问表,导致无法找到。

解决方法

针对 "Table doesn't exist" 错误,可以尝试以下解决方法:

  1. 检查表名拼写:确保表名的拼写与实际表名完全一致,包括大小写和空格。
  2. 检查数据库:确认当前选择的数据库是否正确,使用 USE 命令切换到正确的数据库。
  3. 查看表是否存在:使用 SHOW TABLES 命令查看当前数据库中是否存在相应的表。
  4. 恢复表:如果表被意外删除或重命名,可以尝试从备份中恢复表,或者重新创建表。
  5. 检查权限:确保当前用户具有访问表的权限,可以使用 GRANT 命令赋予相应的权限。

文献引用

在解决 "Table doesn't exist" 错误时,以下资源可能会提供帮助:

  1. MySQL 官方文档:SHOW TABLES Statement
  2. Stack Overflow:MySQL Error 1146 (Table doesn't exist)

这些资源提供了关于解决类似问题的一些实用信息和经验分享。

通过合理利用这些解决方法,我们可以有效地解决 "Table doesn't exist" 错误,恢复对数据库表的访问,并确保数据库操作的顺利进行。


通过分析和解决 "Table doesn't exist" 错误,我们可以更好地处理在 MySQL 数据库操作过程中遇到的问题,提高数据库操作的效率和准确性。

">