转载自:https://www.runoob.com/docker/docker-install-php.html
1、本地创建文件夹
创建本机nginx配置目录
mkdir -p ~/nginx/conf/conf.d touch runoob-test-php.conf
配置内容
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ /.php$ { fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name; include fastcgi_params; } }
创建www虚拟主机目录
mkdir -p ~/nginx/www touch index.php
php内容
<?php echo "hello world";
2、创建php-fpm容器
docker run --name myphp-fpm -v ~/nginx/www:/www -d php:5.6-fpm
3、创建nginx容器
docker run --name runoob-php-nginx -p 8083:80 -d -v ~/nginx/www:/usr/share/nginx/html:ro -v ~/nginx/conf/conf.d:/etc/nginx/conf.d:ro --link myphp-fpm:php nginx
访问 localhost:8083/index.php
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/272174.html