且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

默认情况下,如何在 Docker 容器中启动 php-fpm?

更新时间:2022-03-28 22:49:34

你应该使用 supervisor 来启动几个服务

You should use supervisor in order to launch several services

在您的 dockerfile 中,安装 supervisor,然后启动

In your dockerfile, install supervisor, then you launch

COPY ./docker/supervisord.conf /etc/supervisord.conf
....
CMD ["/usr/bin/supervisord", "-n"]

并且您的 docker/supervisord.conf 包含您要启动的所有服务,因此您可以拥有类似的东西

And your docker/supervisord.conf contains all the services you want to start, so you can have something like that

[program:php-fpm]
  command=/opt/remi/php70/root/usr/sbin/php-fpm -c /etc/php-fpm.conf
  ;command=/usr/sbin/php70-fpm -c /etc/php-fpm.d
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  stderr_logfile_maxbytes=0

[program:nginx]
  command=/usr/sbin/nginx
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  stderr_logfile_maxbytes=0

当然你应该适应你的路径和 php-fpm 版本和你的服务(在我的例子中是 nginx,你的 apache 等等......),但基本上主管是从一个管理多个服务的启动的***方式起点.

Of course you should adapt with your path and php-fpm versions and your services (nginx in my example, apache for you etc...), but basically supervisor is the best way to manage the start of several services from one start point.

这里可以找到docker官方关于supervisor的文档

Here you can find the official doc of docker about supervisor

https://docs.docker.com/engine/admin/using_supervisord/