2 Star 14 Fork 6

funadmin / funadmin-docker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

FunAdmin docker版本 默认使用 PHP8+mysql8+nginx

注意注意注意,重要的事说三次,请把 www/funadmin换为最新的版本

1. 卸载之前安装的组件

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

1.安装yum-utils

sudo yum install -y yum-utils

2.设置稳定的存储库

sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

##下面是官网的, 上面使用阿里云的 国内比较快

https://download.docker.com/linux/centos/docker-ce.repo

# 1. 直接安装最新docker版本

sudo yum -y install docker-ce docker-ce-cli containerd.io

2. 安装完成后查看版本

docker -v

设置为开机启动

systemctl enable docker
启动
systemctl start docker
查看启动状态
systemctl status docker

安装docker-compose

 curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

 chmod +x /usr/local/bin/docker-compose

设置docker用户组

- 1. 创建docker用户组

 sudo groupadd docker

- 2. 应用用户加入docker用户组

 sudo usermod -aG docker ${USER}

 - 3. 重启docker服务

 sudo systemctl restart docker

-  4. 切换或者退出当前账户再从新登入

   su root             切换到root用户
su ${USER}          再切换到原来的应用用户以上配置才生效

安装docker 和docker-compose

修改 .env 数据库密码 默认为root 123456

进入 funadmin-docker 目录 并使用docker-compose up 安装

进入services/nginx/conf.d/funadmin.conf 修改域名配置 即可安装

域名+8080 即可访问数据库

访问域名进行安装 主机名字请填写mysql 切记不要填写127.0.0.1

Host中使用php命令行(php-cli)

  1. 参考bash.alias.sample示例文件,将对应 php cli 函数拷贝到主机的 ~/.bashrc文件。
  2. 让文件起效:
    source ~/.bashrc
  3. 然后就可以在主机中执行php命令了:
    ~ php -v
    PHP 7.2.13 (cli) (built: Dec 21 2018 02:22:47) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.2.13, Copyright (c) 1999-2018, by Zend Technologies
        with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

使用composer

方法1:主机中使用composer命令

  1. 确定composer缓存的路径。比如,我的funadmin-docker下载在~/funadmin-docker目录,那composer的缓存路径就是~/funadmin-docker/data/composer
  2. 参考bash.alias.sample示例文件,将对应 php composer 函数拷贝到主机的 ~/.bashrc文件。

    这里需要注意的是,示例文件中的~/funadmin-docker/data/composer目录需是第一步确定的目录。

  3. 让文件起效:
    source ~/.bashrc
  4. 在主机的任何目录下就能用composer了:
    cd ~/funadmin-docker/www/
    composer create-project funadmin/funadmin project --no-dev
  5. (可选)第一次使用 composer 会在 ~/funadmin-docker/data/composer 目录下生成一个config.json文件,可以在这个文件中指定国内仓库,例如:
    {
        "config": {},
        "repositories": {
            "packagist": {
                "type": "composer",
                "url": "https://mirrors.aliyun.com/composer/"
            }
        }
    }
    

方法二:容器内使用composer命令

还有另外一种方式,就是进入容器,再执行composer命令,以PHP7容器为例:

docker exec -it php /bin/sh
cd /www/localhost
composer update

4.管理命令

4.1 服务器启动和构建命令

如需管理服务,请在命令后面加上服务器名称,例如:

$ docker-compose up                         # 创建并且启动所有容器
$ docker-compose up -d                      # 创建并且后台运行方式启动所有容器
$ docker-compose up nginx php mysql         # 创建并且启动nginx、php、mysql的多个容器
$ docker-compose up -d nginx php  mysql     # 创建并且已后台运行的方式启动nginx、php、mysql容器


$ docker-compose start php                  # 启动服务
$ docker-compose stop php                   # 停止服务
$ docker-compose restart php                # 重启服务
$ docker-compose build php                  # 构建或者重新构建服务

$ docker-compose rm php                     # 删除并且停止php容器
$ docker-compose down                       # 停止并删除容器,网络,图像和挂载卷

添加快捷命令

在开发的时候,我们可能经常使用docker exec -it进入到容器中,把常用的做成命令别名是个省事的方法。

首先,在主机中查看可用的容器:

$ docker ps           # 查看所有运行中的容器
$ docker ps -a        # 所有容器

输出的NAMES那一列就是容器的名称,如果使用默认配置,那么名称就是nginxphpphp56mysql等。

然后,打开~/.bashrc或者~/.zshrc文件,加上:

alias dnginx='docker exec -it nginx /bin/sh'
alias dphp='docker exec -it php /bin/sh'
alias dphp56='docker exec -it php56 /bin/sh'
alias dphp54='docker exec -it php54 /bin/sh'
alias dmysql='docker exec -it mysql /bin/bash'
alias dredis='docker exec -it redis /bin/sh'

下次进入容器就非常快捷了,如进入php容器:

$ dphp

查看docker网络

ifconfig docker0

用于填写extra_hosts容器访问宿主机的hosts地址

5.使用Log

Log文件生成的位置依赖于conf下各log配置的值。

5.1 Nginx日志

Nginx日志是我们用得最多的日志,所以我们单独放在根目录log下。

log会目录映射Nginx容器的/var/log/nginx目录,所以在Nginx配置文件中,需要输出log的位置,我们需要配置到/var/log/nginx目录,如:

error_log  /var/log/nginx/nginx.localhost.error.log  warn;

PHP-FPM日志

大部分情况下,PHP-FPM的日志都会输出到Nginx的日志中,所以不需要额外配置。

另外,建议直接在PHP中打开错误日志:

error_reporting(E_ALL);
ini_set('error_reporting', 'on');
ini_set('display_errors', 'on');

如果确实需要,可按一下步骤开启(在容器中)。

  1. 进入容器,创建日志文件并修改权限:
    $ docker exec -it php /bin/sh
    $ mkdir /var/log/php
    $ cd /var/log/php
    $ touch php-fpm.error.log
    $ chmod a+w php-fpm.error.log
  2. 主机上打开并修改PHP-FPM的配置文件conf/php-fpm.conf,找到如下一行,删除注释,并改值为:
    php_admin_value[error_log] = /var/log/php/php-fpm.error.log
  3. 重启PHP-FPM容器。

MySQL日志

因为MySQL容器中的MySQL使用的是mysql用户启动,它无法自行在/var/log下的增加日志文件。所以,我们把MySQL的日志放在与data一样的目录,即项目的mysql目录下,对应容器中的/var/lib/mysql/目录。

slow-query-log-file     = /var/lib/mysql/mysql.slow.log
log-error               = /var/lib/mysql/mysql.error.log

以上是mysql.conf中的日志文件的配置。

.数据库管理

本项目默认在docker-compose.yml中不开启了用于MySQL在线管理的phpMyAdmin,以及用于redis在线管理的phpRedisAdmin,可以根据需要修改或删除。

phpMyAdmin

phpMyAdmin容器映射到主机的端口地址是:8080,所以主机上访问phpMyAdmin的地址是:

http://localhost:8080

MySQL连接信息:

  • host:(本项目的MySQL容器网络)
  • port:3306
  • username:(手动在phpmyadmin界面输入)
  • password:(手动在phpmyadmin界面输入)

phpRedisAdmin

phpRedisAdmin容器映射到主机的端口地址是:8081,所以主机上访问phpMyAdmin的地址是:

http://localhost:8081

Redis连接信息如下:

  • host: (本项目的Redis容器网络)
  • port: 6379

.在正式环境中安全使用

要在正式环境中使用,请:

  1. 在php.ini中关闭XDebug调试
  2. 增强MySQL数据库访问的安全策略
  3. 增强redis访问的安全策略
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS HOW TO APPLY THE APACHE LICENSE TO YOUR WORK You should include a copy of the Apache License, typically in a file called LICENSE, in your work, and consider also including a NOTICE file. To apply the Apache License to specific files in your work, attach the following boilerplate declaration, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2020 Yuege FunAdmin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

docker版本安装funadmin 一键安装docker lnmp环境 强烈推荐🔥🔥🔥FunAdmin是基于ThinkPHP6+Layui开发的轻量级有颜值后台开发系统,集成Layui常用组件、CRUD生成快速模块,让开发变的简单,CMS免费商用 ,非常适合二开, 开源不易,点击Star支持下 展开 收起
PHP 等 4 种语言
Apache-2.0
取消

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/funadmin/funadmin-docker.git
git@gitee.com:funadmin/funadmin-docker.git
funadmin
funadmin-docker
funadmin-docker
main

搜索帮助