docker installation php container
Preface: Continuing from the previous article Installing nginx container
1 . Pull the php image, I pulled the 7.2.9 version of php
docker pull php:7.2.9-fpm
2. Create a php container
docker run -p 9000:9000 --name php729 -v $PWD/www:/www -v $PWD/php/conf:/usr/local/etc/php -v $PWD/php/conf/conf.d:/usr/local/etc/php/conf.d -v $PWD/php/logs:/phplogs -d php:7.2.9-fpm
-v $PWD/www:/www The directory here and above The www directory where nginx is located in the article is the same
-v $PWD/php/conf:/usr/local/etc/php I don’t know what the use of mounting this directory is, so I’ll copy someone else’s first
3. In this way, the php container is created. Next, check the container IP and configure it in the *.conf file of nginx.
docker inspect php729 |grep "IPAddress"
Open the conf file in nginx. Here is The test.conf file in the previous article
location ~ \.php$ { fastcgi_pass <strong>172.0.0.1</strong>:9000; #<strong>将此处的127.0.0.1替换成你刚查出来的ip</strong> fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
After completion, restart the nginx container, and then access the test file on the page to succeed.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of What container does php use?. For more information, please follow other related articles on the PHP Chinese website!