
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
一个一体化PHP Docker镜像,预配置了大量扩展,可通过环境变量进行配置。支持PHP 7.2、7.3、7.4及早期支持8.0版本,提供多种变体以适应不同的部署场景。
源代码可在 https://github.com/garbetjie/docker-php 获取。
Docker镜像托管在Docker Hub,可通过以下命令拉取:
bashdocker pull docker.xuanyuan.run/garbetjie/php:7.4-fpm
更多镜像可在 https://hub.docker.com/r/garbetjie/php 查看。
关于PHP 8.0镜像的说明
PHP 8.0仍处于早期发布阶段。因此,并非所有已安装的扩展在PHP 8.0镜像中都可用,且PHP 8.0没有CLI版本。随着缺失的扩展逐渐兼容PHP 8.0,它们将被添加进来。
提供三种变体:cli、fpm 和 nginx。每个PHP版本都有对应的变体:
garbetjie/php:7.X-cli
PHP的线程安全版本,默认包含 https://www.php.net/parallel 扩展(但已禁用)。
garbetjie/php:[7.x|8.0]-fpm
安装了PHP-FPM的PHP版本。所有错误日志均写入容器的 stderr。
garbetjie/php:[7.x|8.0]-nginx
集成PHP-FPM和NGiNX Web服务器的版本,可作为自包含的Web服务器使用。访问日志写入容器的 stdout,PHP-FPM日志写入容器的 stderr。
PHP的多数配置选项可通过环境变量控制,部分适用于所有变体,部分仅适用于特定变体。
配置通过shell模板注入,使用 https://github.com/jirutka/esh 作为模板引擎构建配置文件,自定义配置文件也可使用ESH语法。
以下环境变量适用于所有镜像变体,控制PHP核心行为:
| 部分 | 名称 | INI等效配置 | 默认值 |
|---|---|---|---|
| PHP核心 | DISPLAY_ERRORS | https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors | "Off" |
| ERROR_REPORTING | https://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting | "E_ALL & ~E_DEPRECATED & ~E_STRICT" | |
| HTML_ERRORS | https://www.php.net/manual/en/errorfunc.configuration.php#ini.html-errors | "Off" | |
| MAX_EXECUTION_TIME | https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time | 30 | |
| MAX_INPUT_TIME | https://www.php.net/manual/en/info.configuration.php#ini.max-input-time | 30 | |
| MAX_REQUEST_SIZE | https://www.php.net/manual/en/ini.core.php#ini.post-max-size | "8M" | |
| MEMORY_LIMIT | https://www.php.net/manual/en/ini.core.php#ini.memory-limit | "64M" | |
| OPCACHE_ENABLED | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.enable | true | |
| OPCACHE_CLI_ENABLED | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.enable-cli | false | |
| OPCACHE_MAX_ACCELERATED_FILES | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files | *** | |
| OPCACHE_REVALIDATE_FREQ | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq | 2 | |
| OPCACHE_VALIDATE_TIMESTAMPS | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.validate-timestamps | true | |
| OPCACHE_SAVE_COMMENTS | https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments | true | |
| SESSION_COOKIE_NAME | https://www.php.net/manual/en/session.configuration.php#ini.session.name | "PHPSESSID" | |
| SESSION_SAVE_HANDLER | https://www.php.net/manual/en/session.configuration.php#ini.session.save-handler | "files" | |
| SESSION_SAVE_PATH | https://www.php.net/manual/en/session.configuration.php#ini.session.save-path | "/tmp/sessions" | |
| TIMEZONE | https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone | "Etc/UTC" | |
| UPLOAD_MAX_FILESIZE | https://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize | "8M" | |
| New Relic扩展 | NEWRELIC_ENABLED | N/A(启用/禁用New Relic扩展) | false |
| NEWRELIC_APP_NAME | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-appname | "" | |
| NEWRELIC_AUTORUM_ENABLED | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-autorum | 0 | |
| NEWRELIC_DAEMON_LOGLEVEL | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-daemon-loglevel | "error" | |
| NEWRELIC_DAEMON_PORT | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-daemon-port | "@newrelic-daemon" | |
| NEWRELIC_DAEMON_WAIT | N/A(等待New Relic守护进程连接的秒数) | 3 | |
| NEWRELIC_HOST_DISPLAY_NAME | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-process_host-display_name | "" | |
| NEWRELIC_LABELS | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-labels | "" | |
| NEWRELIC_LICENCE | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-license | "" | |
| NEWRELIC_LOGLEVEL | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-loglevel | "info" | |
| NEWRELIC_RECORD_SQL | https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-tt-sql | "obfuscated" | |
| OpenCensus扩展 | OPENCENSUS_ENABLED | N/A(启用/禁用OpenCensus扩展) | false |
| XDebug扩展 | XDEBUG_ENABLED | N/A(启用/禁用XDebug扩展) | false |
| XDEBUG_IDE_KEY | https://xdebug.org/docs/all_settings#idekey | "IDEKEY" | |
| XDEBUG_REMOTE_AUTOSTART | https://xdebug.org/docs/all_settings#remote_autostart | 0 | |
| XDEBUG_REMOTE_HOST | https://xdebug.org/docs/all_settings#remote_host | "192.168.99.1" | |
| XDEBUG_REMOTE_PORT | https://xdebug.org/docs/all_settings#remote_port | 9000 |
以下变量适用于PHP-FPM:
| 名称 | FPM INI等效配置 | 默认值 |
|---|---|---|
| PM | https://www.php.net/manual/en/install.fpm.configuration.php#pm | "static" |
| LISTEN | https://www.php.net/manual/en/install.fpm.configuration.php#listen | "0.0.0.0:9000" |
| MAX_CHILDREN | https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-children | 0 |
| MIN_SPARE_SERVERS | https://www.php.net/manual/en/install.fpm.configuration.php#pm.min-spare-servers | 1 |
| MAX_SPARE_SERVERS | https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-spare-servers | 3 |
| MAX_REQUESTS | https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-requests | *** |
| STATUS_PATH | https://www.php.net/manual/en/install.fpm.configuration.php#pm.status-path | "/_/status" |
| TIMEOUT | https://www.php.net/manual/en/install.fpm.configuration.php#request-terminate-timeout | 60 |
以下变量适用于NGiNX,部分会覆盖PHP-FPM默认值:
| 名称 | NGiNX配置等效项 | 默认值 |
|---|---|---|
| GZIP_TYPES | http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_types | "application/ecmascript application/javascript application/json application/xhtml+xml application/xml text/css text/ecmascript text/javascript text/plain text/xml" |
| GZIP_PROXIED | http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_proxied | "any" |
| LISTEN | http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_pass | "/var/run/php-fpm.sock" |
| PORT | http://nginx.org/en/docs/http/ngx_http_core_module.html#listen | 80 |
| ROOT | http://nginx.org/en/docs/http/ngx_http_core_module.html#root | "/app/public" |
| STATUS_HOSTS_ALLOWED | http://nginx.org/en/docs/http/ngx_http_access_module.html#allow | "172.16.0.0/12 127.0.0.1" |
| STATUS_HOSTS_DENIED | http://nginx.org/en/docs/http/ngx_http_access_module.html#deny | "all" |
| TIMEOUT | http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout | 60 |
opencensus 和 parallel 扩展,否则会导致PHP段错误退出。[PHP Modules] amqp (仅7.x镜像) bcmath bz2 Core ctype curl date dom exif fileinfo filter ftp gd gettext gmp hash iconv igbinary imap intl json libxml mbstring memcached msgpack mysqlnd newrelic (仅7.x镜像) opencensus (仅7.x镜像) openssl parallel (仅*-cli版本) pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline redis Reflection session SimpleXML soap sockets sodium SPL sqlite3 standard tokenizer xdebug xml xmlreader xmlwriter Zend OPcache zip zlib [Zend Modules] Xdebug Zend OPcache
2020-07-05
2020-06-29
2020-05-22
/var/lib/nginx 所有权不正确。2020-02-04
gzip_proxied 的能力。2020-01-31
$NEWRELIC_LOGLEVEL 配置选项。$NEWRELIC_DAEMON_LOGLEVEL 被正确应用。$NEWRELIC_DAEMON_WAIT 增加至5秒。-cli 镜像)。2020-01-08
/var/tmp/nginx 所有权不正确。2019-12-19
2019-12-17
2019-12-14
2019-12-13
$SESSION_COOKIE_NAME 配置,并修复 $SESSSION_SAVE_* 配置未被使用的问题。2019-11-21
opencensus 扩展的能力(默认禁用)。2019-11-20
7.3-zts-cli 和 7.2-zts-cli)。parallel 扩展。您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 garbetjie/php 相关的常用 Docker 镜像,适用于 Web 开发、内容管理、传统应用 等不同场景: