Docker LNMP (Nginx, PHP7/PHP5, MySQL, Redis)

DNMP(Docker + Nginx + MySQL + PHP7/5 + Redis)是一款全功能的LNMP一键安装程序

使用前最好提前阅读一遍目录,以便快速上手,遇到问题也能及时排除。交流QQ一群:572041090(已满),二群:300723526

[ENGLISH] - [GitHub地址] - [Gitee地址]

DNMP项目特点:

  1. 100%开源
  2. 100%遵循Docker标准
  3. 支持多版本PHP共存,可任意切换(PHP5.4、PHP5.6、PHP7.1、PHP7.2、PHP7.3)
  4. 支持绑定任意多个域名
  5. 支持HTTPS和HTTP/2
  6. PHP源代码、MySQL数据、配置文件、日志文件都可在Host中直接修改查看
  7. 内置完整PHP扩展安装命令
  8. 默认支持pdo_mysqlmysqlimbstringgdcurlopcache等常用热门扩展,根据环境灵活配置
  9. 可一键选配常用服务:
    • 多PHP版本:PHP5.4、PHP5.6、PHP7.1-7.3
    • Web服务:Nginx、Openresty
    • 数据库:MySQL5、MySQL8、Redis、memcached、MongoDB、ElasticSearch
    • 消息队列:RabbitMQ
    • 辅助工具:Kibana、Logstash、phpMyAdmin、phpRedisAdmin、AdminMongo
  10. 实际项目中应用,确保100%可用
  11. 所有镜像源于Docker官方仓库,安全可靠
  12. 一次配置,Windows、Linux、MacOs皆可用
  13. 支持快速安装扩展命令 install-php-extensions apcu

目录

1.目录结构

/
├── data                        数据库数据目录
│   ├── esdata                  ElasticSearch 数据目录
│   ├── mongo                   MongoDB 数据目录
│   ├── mysql                   MySQL8 数据目录
│   └── mysql5                  MySQL5 数据目录
├── services                    服务构建文件和配置文件目录
│   ├── elasticsearch           ElasticSearch 配置文件目录
│   ├── mysql                   MySQL8 配置文件目录
│   ├── mysql5                  MySQL5 配置文件目录
│   ├── nginx                   Nginx 配置文件目录
│   ├── php                     PHP5.6 - PHP7.3 配置目录
│   ├── php54                   PHP5.4 配置目录
│   └── redis                   Redis 配置目录
├── logs                        日志目录
├── docker-compose.sample.yml   Docker 服务配置示例文件
├── env.smaple                  环境配置示例文件
└── www                         PHP 代码目录

2.快速使用

  1. 本地安装
    • git
    • Docker(系统需为Linux,Windows 10 Build 15063+,或MacOS 10.12+,且必须要64位)
    • docker-compose 1.7.0+
  2. clone项目:
    $ git clone https://github.com/yeszao/dnmp.git
    
  3. 如果不是root用户,还需将当前用户加入docker用户组:
    $ sudo gpasswd -a ${USER} docker
    
  4. 拷贝并命名配置文件(Windows系统请用copy命令),启动:
    $ cd dnmp                                           # 进入项目目录
    $ cp env.sample .env                                # 复制环境变量文件
    $ cp docker-compose.sample.yml docker-compose.yml   # 复制 docker-compose 配置文件。默认启动3个服务:
                                                        # Nginx、PHP7和MySQL8。要开启更多其他服务,如Redis、
                                                        # PHP5.6、PHP5.4、MongoDB,ElasticSearch等,请删
                                                        # 除服务块前的注释
    $ docker-compose up                                 # 启动
    
  5. 在浏览器中访问:http://localhosthttps://localhost(自签名HTTPS演示)就能看到效果,PHP代码在文件./www/localhost/index.php

3.PHP和扩展

3.1 切换Nginx使用的PHP版本

首先,需要启动其他版本的PHP,比如PHP5.4,那就先在docker-compose.yml文件中删除PHP5.4前面的注释,再启动PHP5.4容器。

PHP5.4启动后,打开Nginx 配置,修改fastcgi_pass的主机地址,由php改为php54,如下:

    fastcgi_pass   php:9000;

为:

    fastcgi_pass   php54:9000;

其中 phpphp54docker-compose.yml文件中服务器的名称。

最后,重启 Nginx 生效。

$ docker exec -it nginx nginx -s reload

这里两个nginx,第一个是容器名,第二个是容器中的nginx程序。

3.2 安装PHP扩展

PHP的很多功能都是通过扩展实现,而安装扩展是一个略费时间的过程, 所以,除PHP内置扩展外,在env.sample文件中我们仅默认安装少量扩展, 如果要安装更多扩展,请打开你的.env文件修改如下的PHP配置, 增加需要的PHP扩展:

PHP_EXTENSIONS=pdo_mysql,opcache,redis       # PHP 要安装的扩展列表,英文逗号隔开
PHP54_EXTENSIONS=opcache,redis                 # PHP 5.4要安装的扩展列表,英文逗号隔开

然后重新build PHP镜像。

docker-compose build php

可用的扩展请看同文件的env.sample注释块说明。

3.3 快速安装php扩展

1.进入容器:

docker exec -it php /bin/sh

install-php-extensions apcu 

2.支持快速安装扩展列表

Extension PHP 5.5 PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2 PHP 7.3 PHP 7.4 PHP 8.0
amqp
apcu
apcu_bc
bcmath
bz2
calendar
cmark
dba
decimal
enchant*
ev
exif
ffi
gd
gettext
gmagick
gmp
gnupg
grpc
http
igbinary
imagick
imap
interbase
intl
ioncube_loader
ldap
mailparse
maxminddb
mcrypt
memcache
memcached
mongo
mongodb
mosquitto
msgpack
mssql
mysql
mysqli
oauth
oci8
odbc
opcache
opencensus
parallel*
pcntl
pcov
pdo_dblib
pdo_firebird
pdo_mysql
pdo_oci
pdo_odbc
pdo_pgsql
pdo_sqlsrv
pgsql
propro
protobuf
pspell
pthreads*
raphf
rdkafka
recode
redis
shmop
smbclient
snmp
snuffleupagus
soap
sockets
solr
sqlsrv
ssh2
swoole
sybase_ct
sysvmsg
sysvsem
sysvshm
tdlib*
tidy
timezonedb
uopz
uuid
wddx
xdebug
xhprof
xlswriter
xmlrpc
xsl
yaml
yar
zip
zookeeper

此扩展来自https://github.com/mlocati/docker-php-extension-installer 参考示例文件

3.4 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

3.5 使用composer

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

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

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

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

方法二:容器内使用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                       # 停止并删除容器,网络,图像和挂载卷

4.2 添加快捷命令

在开发的时候,我们可能经常使用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

4.3 查看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;

5.2 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容器。

5.3 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中的日志文件的配置。

6.数据库管理

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

6.1 phpMyAdmin

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

http://localhost:8080

MySQL连接信息:

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

6.2 phpRedisAdmin

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

http://localhost:8081

Redis连接信息如下:

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

7.在正式环境中安全使用

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

  1. 在php.ini中关闭XDebug调试
  2. 增强MySQL数据库访问的安全策略
  3. 增强redis访问的安全策略

8 常见问题

8.1 如何在PHP代码中使用curl?

参考这个issue:https://github.com/yeszao/dnmp/issues/91

8.2 Docker使用cron定时任务

Docker使用cron定时任务

8.3 Docker容器时间

容器时间在.env文件中配置TZ变量,所有支持的时区请看时区列表·维基百科或者PHP所支持的时区列表·PHP官网

8.4 如何连接MySQL和Redis服务器

这要分两种情况,

第一种情况,在PHP代码中

// 连接MySQL
$dbh = new PDO('mysql:host=mysql;dbname=mysql', 'root', '123456');

// 连接Redis
$redis = new Redis();
$redis->connect('redis', 6379);

因为容器与容器是expose端口联通的,而且在同一个networks下,所以连接的host参数直接用容器名称,port参数就是容器内部的端口。更多请参考《docker-compose ports和expose的区别》

第二种情况,在主机中通过命令行或者Navicat等工具连接。主机要连接mysql和redis的话,要求容器必须经过ports把端口映射到主机了。以 mysql 为例,docker-compose.yml文件中有这样的ports配置:3306:3306,就是主机的3306和容器的3306端口形成了映射,所以我们可以这样连接:

$ mysql -h127.0.0.1 -uroot -p123456 -P3306
$ redis-cli -h127.0.0.1

这里host参数不能用localhost是因为它默认是通过sock文件与mysql通信,而容器与主机文件系统已经隔离,所以需要通过TCP方式连接,所以需要指定IP。

8.5 容器内的php如何连接宿主机MySQL

1.宿主机执行ifconfig docker0得到inet就是要连接的ip地址

$ ifconfig docker0
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ...

2.运行宿主机Mysql命令行

 mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
 mysql>flush privileges;
// 其中各字符的含义:
// *.* 对任意数据库任意表有效
// "root" "123456" 是数据库用户名和密码
// '%' 允许访问数据库的IP地址,%意思是任意IP,也可以指定IP
// flush privileges 刷新权限信息

3.接着直接php容器使用172.0.17.1:3306连接即可

License

MIT

Comments
  • 错误: No releases available for package

    错误: No releases available for package "pecl.php.net/redis"解决

    pecl -vvv install redis-3.1.4

    `Warning: file_exists(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1511

    Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1521

    Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1521

    Warning: fsockopen(): Failed to enable crypto in PEAR/Proxy.php on line 179

    Warning: fsockopen(): unable to connect to ssl://pecl.php.net:443 (Unknown error) in PEAR/Proxy.php on line 179 No releases available for package "pecl.php.net/redis" Cannot initialize 'channel://pecl.php.net/redis-3.1.4', invalid or missing package file Package "channel://pecl.php.net/redis-3.1.4" is not valid install failed`

  • 安装报错 ERROR: Service 'php' failed to build: The command '/bin/sh -c chmod +x install.sh     && sh install.sh     && rm -rf /tmp/extensions' returned a non-zero code: 1

    安装报错 ERROR: Service 'php' failed to build: The command '/bin/sh -c chmod +x install.sh && sh install.sh && rm -rf /tmp/extensions' returned a non-zero code: 1

    Uploading image.png…

    安装时报错:

    `---------- Install opcache ---------- fetch http://mirrors.aliyun.com/alpine/v3.9/main/x86_64/APKINDEX.tar.gz fetch http://mirrors.aliyun.com/alpine/v3.9/community/x86_64/APKINDEX.tar.gz WARNING: Ignoring http://mirrors.aliyun.com/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: temporary error (try again later) WARNING: Ignoring http://mirrors.aliyun.com/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: temporary error (try again later) ERROR: unsatisfiable constraints: autoconf (missing): required by: .phpize-deps-0[autoconf] dpkg-dev (missing): required by: .phpize-deps-0[dpkg-dev] dpkg (missing): required by: .phpize-deps-0[dpkg] file (missing): required by: .phpize-deps-0[file] g++ (missing): required by: .phpize-deps-0[g++] gcc (missing): required by: .phpize-deps-0[gcc] libc-dev (missing): required by: .phpize-deps-0[libc-dev] make (missing): required by: .phpize-deps-0[make] pkgconf (missing): required by: .phpize-deps-0[pkgconf] re2c (missing): required by: .phpize-deps-0[re2c]

    ---------- Install gd ---------- fetch http://mirrors.aliyun.com/alpine/v3.9/main/x86_64/APKINDEX.tar.gz fetch http://mirrors.aliyun.com/alpine/v3.9/community/x86_64/APKINDEX.tar.gz WARNING: Ignoring http://mirrors.aliyun.com/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: temporary error (try again later) WARNING: Ignoring http://mirrors.aliyun.com/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: temporary error (try again later) ERROR: unsatisfiable constraints: freetype (missing): required by: world[freetype] freetype-dev (missing): required by: world[freetype-dev] libjpeg-turbo (missing): required by: world[libjpeg-turbo] libjpeg-turbo-dev (missing): required by: world[libjpeg-turbo-dev] libpng (missing): required by: world[libpng] libpng-dev (missing): required by: world[libpng-dev]

    ---------- curl is installed ---------- WARNING: Ignoring APKINDEX.2ac53f5f.tar.gz: No such file or directory WARNING: Ignoring APKINDEX.96fa836e.tar.gz: No such file or directory

    ERROR: Service 'php' failed to build: The command '/bin/sh -c chmod +x install.sh && sh install.sh && rm -rf /tmp/extensions' returned a non-zero code: 1 `

  • 安装了bcmath扩展使用composer提示缺少扩展

    安装了bcmath扩展使用composer提示缺少扩展

    1:php72环境下面,已经安装了bcmath扩展 (php -m 能看到bcmath)提示缺少bcmath 2:php版本怎么是php7.3.6? 我进入容器 php -v 显示的是7.2.19

    Your requirements could not be resolved to an installable set of packages.

    Problem 1 - The requested PHP extension ext-bcmath * is missing from your system. Install or enable PHP's bcmath extension. Problem 2 - friendsofphp/php-cs-fixer v2.2.20 requires php ^5.3.6 || >=7.0 <7.3 -> your PHP version (7.3.6) does not satisfy that requirement. - friendsofphp/php-cs-fixer v2.2.20 requires php ^5.3.6 || >=7.0 <7.3 -> your PHP version (7.3.6) does not satisfy that requirement. - Installation request for friendsofphp/php-cs-fixer v2.2.20 -> satisfiable by friendsofphp/php-cs-fixer[v2.2.20].

  • 源好像有问题

    源好像有问题

    E: Unable to locate package libfreetype6-dev E: Unable to locate package libjpeg62-turbo-dev E: Unable to locate package libpng-dev

    I can't find a way to solve this problem~

  • Y大是不是忘了更新本地代码

    Y大是不是忘了更新本地代码

    https://github.com/yeszao/dnmp/blob/master/Dockerfile#L24 此处应该有一个设置mt变量(你改成了mc)的代码

    https://github.com/yeszao/dnmp/blob/cea37ce8d2bc0e6b58f6d004664f814406afb30c/Dockerfile#L34 这一行怎么消失了?

    php5.4的docker-php-ext-install也是不支持多线程编译的所以要加一下版本判断

  • php56 build failed

    php56 build failed

    dnmp % docker-compose up -d Building php56 [+] Building 0.0s (1/2)
    => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2B 0.0s failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount951349866/Dockerfile: no such file or directory ERROR: Service 'php56' failed to build : Build failed

  • win10 wsl2下, root用户, 默认配置安装elasticsearch报错.

    win10 wsl2下, root用户, 默认配置安装elasticsearch报错.

    win10 wsl2下, ubuntu1804, root用户, 默认配置, 安装elasticsearch后, 容器一直Restarting.

    docker logs es容器id,信息如下, 请问我需要怎么操作?

    OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. {"type": "server", "timestamp": "2020-08-29T10:34:45,076+0800", "level": "WARN", "component": "o.e.b.ElasticsearchUncaughtExceptionHandler", "cluster.name": "docker-cluster", "node.name": "elasticsearch", "message": "uncaught exception in thread [main]" , "stacktrace": ["org.elasticsearch.bootstrap.StartupException: ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];", "at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.1.1.jar:7.1.1]", "at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.1.1.jar:7.1.1]", "Caused by: org.elasticsearch.ElasticsearchException: failed to bind service", "at org.elasticsearch.node.Node.<init>(Node.java:582) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:211) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:211) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.1.jar:7.1.1]", "... 6 more", "Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes", "at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]", "at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]", "at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]", "at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389) ~[?:?]", "at java.nio.file.Files.createDirectory(Files.java:692) ~[?:?]", "at java.nio.file.Files.createAndCheckIsDirectory(Files.java:799) ~[?:?]", "at java.nio.file.Files.createDirectories(Files.java:785) ~[?:?]", "at org.elasticsearch.env.NodeEnvironment.lambda$new$0(NodeEnvironment.java:270) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:207) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:267) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.node.Node.<init>(Node.java:272) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:211) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:211) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.1.1.jar:7.1.1]", "at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.1.jar:7.1.1]", "... 6 more"] }

  • php使用 7.4.1-fpm 使用 -alpine 后缀的镜像存在数据库读取精度会有问题

    php使用 7.4.1-fpm 使用 -alpine 后缀的镜像存在数据库读取精度会有问题

    发现 php使用 7.4.1-fpm-alpine、7.3.1-fpm-alpine 后缀的镜像存在数据库读取数据精度会有问题,如果直接使用 7.4.1-fpm 则不会有这个数据库读取数据错误的问题,估计 alpine 的镜像的可能都会有这个问题。数据库中某个float字段 比如为 0.93 ,读取后会为 0.94, 0.99读取后会为1。希望您有时间可以注意下,避免使用者不必要的损失和困难

  • MAC BOOK PRO 上面安装phalcon扩展不成功,卡在安装途中.md

    MAC BOOK PRO 上面安装phalcon扩展不成功,卡在安装途中.md

    image 根据README.md描述,在.env文件中的90行加入对psr和phalcon的扩展。

    PHP_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,opcache,zip,psr,phalcon
    

    执行

    docker-compose build php
    

    会自动安装psr和phalcon其中,psr安装是没有问题的,phalcon看记录会自行安装 v4.1.2,但是会一直停留在这个界面上面。卡顿时间很久。不得不 ctrl + c暂停,这个原因不知道是什么。

    我另外尝试了另外一种方案。 进入php的环境中,执行如下内容

    docker exec -it php /bin/sh
    install-php-extensions phalcon
    

    image

    感觉执行效果是一样的。也会卡在这样几个界面上 有过1次,它安装成功了,也就只有1次,是通过第二种方式,不知道这种情况出现的原因是什么。 php版本为 7.4 ========如下为我的电脑环境=====

    image

    Docker环境

    Docker version 20.10.5, build 55c4c88
    
  • Swoole 没有添加 configure 项目

    Swoole 没有添加 configure 项目

    服务端对外进行 https 请求时,会报缺少 openssl 的配置

    参考了 https://github.com/swoole/docker-swoole/blob/master/dockerfiles/4.5.10/php7.4/alpine/Dockerfile

    编译的时候,默认打开了 --enable-http2
    --enable-mysqlnd
    --enable-openssl
    --enable-sockets --enable-swoole-json

  • 找不到redis和mongodb扩展

    找不到redis和mongodb扩展

    .env文件中添加了mongodb,redis PHP_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,opcache,mongodb,redis

    curl http://localhost Redis服务器版本:Redis 扩展未安装 MongoDB服务器版本:MongoDB 扩展未安装

    请问是哪里的问题?

  • fix swoole install

    fix swoole install

    fix issue:https://github.com/yeszao/dnmp/issues/509

    /www # php --ri swoole
    
    swoole
    
    Swoole => enabled
    Author => Swoole Team <[email protected]>
    Version => 4.5.2
    Built => Dec 19 2022 02:10:18
    coroutine => enabled
    epoll => enabled
    eventfd => enabled
    signalfd => enabled
    spinlock => enabled
    rwlock => enabled
    zlib => 1.2.12
    brotli => E16777225/D16777225
    mutex_timedlock => enabled
    pthread_barrier => enabled
    futex => enabled
    async_redis => enabled
    
    Directive => Local Value => Master Value
    swoole.enable_coroutine => On => On
    swoole.enable_library => On => On
    swoole.enable_preemptive_scheduler => Off => Off
    swoole.display_errors => On => On
    swoole.use_shortname => On => On
    swoole.unixsock_buffer_size => 8388608 => 8388608
    
  • dnmp安装php扩展redis igbinary memcached xdebug swoole protobuf全部失败

    dnmp安装php扩展redis igbinary memcached xdebug swoole protobuf全部失败

    PHP80_EXTENSIONS=pdo_mysql,pcntl,mysqli,mbstring,calendar,sockets,pdo_pgsql,gd,curl,snmp,tidy,gmp,imap,ldap,imagick,mcrypt,opcache,redis,xdebug,swoole,mongodb,igbinary,protobuf

    dnmp安装php扩展redis igbinary memcached xdebug swoole protobuf全部失败 但是其他扩展安装成功,尝试了n²次,每次过程都是删除dnmp目录重新clone 尝试了不同的网络,包括vpn(香港,德国,日本)和本地网络都是无法安装,alpine版本也从3.12一直尝试到3.17,历时两天时间尝试

  • php8/Dockerfile mac m1 下gnu-libiconv不能加版本号 RUN apk add gnu-libiconv

    php8/Dockerfile mac m1 下gnu-libiconv不能加版本号 RUN apk add gnu-libiconv

    在mac m1 下gnu-libiconv不能加版本号 阿里云的源和中科大的都没有1.15-r3这个版本

    可以改为 RUN apk add gnu-libiconv libstdc++ --no-cache --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/community/ --allow-untrusted

    或者和默认php/Dockerfile下的一样

    RUN apk add --no-cache --repository http://${CONTAINER_PACKAGE_URL}/alpine/v3.13/community/ gnu-libiconv=1.15-r3

    我没有去运行过代码 只是编译的时候发现问题 改了是能编译通过的 #502

    `

    ERROR [dnmp-php8 9/12] RUN apk add gnu-libiconv=1.15-r3 libstdc++ --no-cache --repository http://mirrors.aliyun.com/alpine/edge/community/ --allow-untrusted 54.7s [dnmp-php8 9/12] RUN apk add gnu-libiconv=1.15-r3 libstdc++ --no-cache --repository http://mirrors.aliyun.com/alpine/edge/community/ --allow-untrusted: #0 0.319 fetch http://mirrors.aliyun.com/alpine/edge/community/aarch64/APKINDEX.tar.gz #0 25.16 fetch https://mirrors.aliyun.com/alpine/v3.14/main/aarch64/APKINDEX.tar.gz #0 35.35 fetch https://mirrors.aliyun.com/alpine/v3.14/community/aarch64/APKINDEX.tar.gz #0 54.72 ERROR: unable to select packages: #0 54.74 gnu-libiconv-1.17-r0: #0 54.74 breaks: world[gnu-libiconv=1.15-r3]


    failed to solve: executor failed running [/bin/sh -c apk add gnu-libiconv=1.15-r3 libstdc++ --no-cache --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/community/ --allow-untrusted]: exit code: 1`

    image image image
  • php(8.x,7.x?)安装swoole报错,以及安装swoole openssl,curl报错解决

    php(8.x,7.x?)安装swoole报错,以及安装swoole openssl,curl报错解决

    定位问题 应该是 install-php-extensions 出问题了

    修复方法

    找到php7.x版本安装swoole方法,(7 0 改成 8 0 ,php版本8.x的话修改8.x extensions/install.sh) image

    把swoole源码下载下来放在 extensions文件中(8.0的话, 注意源码zip是多压缩了一份外壳,需要下载下来解压进入文件夹在压缩,然后修改压缩包名字)

    安装方法处理 image

    dockerfile更改 不要限制版本 image

    然后开始安装。

    不行换下源,最近阿里源不是很稳定

Related tags
nginx exporter for Prometheus copy code from ingress-nginx use for monit nginx
nginx exporter for Prometheus copy code from ingress-nginx use for monit nginx

nginx_exporter 介绍 从ingress-nginx官方代码中的expoter迁移出来 用来监控虚拟机上的nginx的expoter 基于官方 controller-v0.49.3 版本移植的代码 软件架构 nginx_socket 通过lua模块monitor.lua 将nginx l

Dec 20, 2021
An implementation of an Ingress controller for NGINX and NGINX Plus

?? Help make the NGINX Ingress Controller better by participating in our survey!

Dec 9, 2022
Simple HPA base NGINX Ingress

Simple HPA Base Ingress Access Log Support NGINX Ingress How to Use Requirement Kubernetes NGINX Ingress Quick Start 1. Deploy Change deploy.yamlENV,

Dec 12, 2022
A Pulumi NGINX Ingress Controller component

Pulumi NGINX Ingress Controller Component This repo contains the Pulumi NGINX Ingress Controller component for Kubernetes. This ingress controller use

Aug 10, 2022
An Ingress controller for Kubernetes using NGINX as a reverse proxy and load balancer

NGINX Ingress Controller Overview ingress-nginx is an Ingress controller for Kubernetes using NGINX as a reverse proxy and load balancer. Learn more a

Nov 15, 2021
kubectl plugin for generating nginx-ingress compatible basic-auth secrets on kubernetes clusters

kubectl-htpasswd kubectl plugin for easily generating hashed basic auth secrets. Supported hash algorithms bcrypt Examples Create the secret on the cl

Jul 17, 2022
Json-log-exporter - A Nginx log parser exporter for prometheus metrics

json-log-exporter A Nginx log parser exporter for prometheus metrics. Installati

Jan 5, 2022
A docker image for test redis HA

Guide 测试集群模式(Test Redis Cluster) redis-test --arch cluster 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 测试哨兵模式(TEST Redis Sentinel) redis-test --arc

Nov 30, 2021
A dynamic docker->redis->traefik discovery agent

traefik-kop A dynamic docker->redis->traefik discovery agent. Solves the problem of running a non-Swarm/Kubernetes multi-host cluster with a single pu

Dec 23, 2022
Explore Docker registries and manipulate Docker images!
Explore Docker registries and manipulate Docker images!

L/S tags Utility and API to manipulate (analyze, synchronize and aggregate) images across different Docker registries. Example invocation $ lstags alp

Nov 25, 2022
Docker-based remote code runner / 基于 Docker 的远程代码运行器
Docker-based remote code runner / 基于 Docker 的远程代码运行器

Docker-based remote code runner / 基于 Docker 的远程代码运行器

Nov 9, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

Dec 13, 2022
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.

GIT-PIPE Hassle-free minimal CI/CD for git repos for docker-based projects. Features: zero configuration for repos by default automatic encrypted back

Sep 23, 2022
Tool to convert docker-compose files to set of simple docker commands

docker-decompose Tool to convert docker-compose files to set of simple docker commands. Install Use go get to install the latest version of the librar

Apr 12, 2022
Go-http-server-docker - Simple sample server using docker and go

go-http-server-docker Simple sample webserver using docker and go.

Jan 8, 2022
Docker-hub-rate-limit - Show pulling rate status of Docker-hub

Docker-Hub Pull Rate Status This tool shows current status of docker hub pull ra

Jan 28, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Dec 30, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Feb 16, 2022
Kubernetes Operator for MySQL NDB Cluster.

MySQL NDB Operator The MySQL NDB Operator is a Kubernetes operator for managing a MySQL NDB Cluster setup inside a Kubernetes Cluster. This is in prev

Dec 21, 2022