In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you how to install php-fpm service/extension/configuration docker, the content is simple and easy to understand, I hope you can learn about it, after learning, there will definitely be gains, let Xiaobian take you to have a look.
When using brew to install php56 on mac, because openssl is version 1.1, it causes all kinds of errors that google can't fix. It's too much trouble. Now use docker to create a php56-fpm service container, and nginx is installed directly on the host.
PHP DockerHub Home
create a container
#Create container docker run -d \--name php56-fpm \-p 9056:9000 \-v /home/wwwroot:/var/www/html--privileged=truephp:5.6-fpm
Note:
/var/www/html is the working directory of the php docker image.
-v /home/wwwroot:/var/www/html mounts the host's site directory onto the container. For example,/home/wwwroot/siteA is accessed at/var/www/html/siteA in the container.
When nignx forwards php requests, it forwards the script name SCRIPT_NAME and script file name SCRIPT_FILENAME to fpm, which then reads the script execution.
When using the fpm container, you need to pay attention to whether the SCRIPT_FILENAME forwarded by nginx is a valid site path in the fpm container. If the root of nginx cannot be directly mapped to the site root of the fpm container, we need to redefine it as the site root of the fpm container in php location. This allows fpm to read the script correctly.
The requested URL/home/wwwroot/siteA/public/index.php was not found on this server.
Therefore, when configuring nginx server, you should pay attention to the following volume path conversion:
server { listen 8056; .... #host's site root directory root /home/wwwroot/siteA/public; location ~* (^[/]*.php)[/|$] { #site root directory in container root /var/www/html/siteA/public; pass_proxy: 127.0.0.1:9056; include fastcgi.conf; }}
However, in general, everyone is docker nginx + docker php-fpm, both containers are uniformly mapped to the site directory, there will be no such problem. Here nginx is installed directly on the host machine, which causes nginx to redefine the root directory of the site when forwarding php requests.
landing vessel
#Check if the container is running docker ps#Log in to the container docker exec -it php56-fpm /bin/bash
Docker images of php are based on ubuntu and we can use apt-get to install the tools we need, such as vim/vi lrzz net-tools.
#Before using apt-get to install some tools, update the source #Otherwise apt-get E: Unable to locate packageapt-get updateapt-get install vim
Install php/pecl extension
Install php extensions
That is, php official extensions, such as shomp, which comes with it but is not enabled by default.
#View extensions that come with cd /usr/local/php/ext && ls -l#Install extensions dcoker-php-ext-install shmop
Install pecl extension
The container is installed with pecl, so you can install it directly using pecl, pay attention to extending support for php versions.
Docker-php-ext-enable is mainly used to generate the appropriate configuration file for extensions to/usr/local/etc/php/conf.d/docker-php-ext-{extName}.ini to facilitate php loading extensions.
# igbinary php5.6 Maximum version is 2.0.8pecl install igbinary-2.0.8docker-php-ext-enable igbinary# phpredis php5.6 Maximum version is 4.3.0pecl install redis-4.3.0docker-php-ext-enable redis# swoole php5.6 Maximum version is 2.0.11pcel install swoole-2.0.11docker-php-ext-enable swoole
php/php-fpm configuration
/usr/local/etc is the configuration directory of php container, which comes with php and php-fpm configuration files. The configuration directory structure is as follows:
root@aa739592b579:/usr/local# tree etc/ etc/|-- pear.conf|-- php # php configuration directory||-- conf.d # php Extended Configuration|||-- docker-php-ext-shmop.ini||php.ini-development/production of php.ini # cp||-- php.ini-development||-- php.ini-production|-- php-fpm.conf # php-fpm configuration comes with the introduction of php-fpm.d|-- php-fpm.conf.default # php-fpm configuration ontology is consistent with php-fpm.d/www.conf|-- php-fpm.d #Extended configuration of php-fpm|-- docker.conf |-- www.conf # php-fpm configuration ontology mode ah max/min children ah all here|-- zz-docker.conf
You can map the host configuration directory to the container's/usr/local/etc, but be careful to keep the configuration directory on the host consistent with the container's existing configuration directory, or edit the configuration file directly in the container. According to docker philosophy, we should maintain a configuration file on the host mapped to the configuration directory of the container, so as to give full play to the reusability of docker containers.
Mapping host php configuration files to containers
-v /opt/docker/conf/php/php.ini:/usr/local/etc/php/php.ini-v /opt/docker/conf/php/php-fpm.ini:/usr/local/etc/php-fpm.d/www/conf
common problems
1、File not found
The site root directory specified by nginx cannot be mapped directly to the fpm container. Specify the site root directory of the fpm container in location. 2、apt-get E: Unable to locate package
Run apt-get update to refresh the source. 3. Relevant agreements of containers
Working directory: /var/www/html It is recommended that the host site directory be mapped to this directory
Configuration directory: /usr/local/etcNote configuration directory structure
php extension directory: /usr/local/php/ext can view php comes with the extension package using docker-php-ext-install is more convenient to install the above is about docker how to install php-fpm services/extensions/configuration content, if you have learned knowledge or skills, you can share it out to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.