1、pull php-fpm环境
docker pull richarvey/nginx-php-fpm:latest
2、run php-fpm镜像
docker run -idt --name php-fpm -p 9000:80 -v /opt/hk.railfi.com:/var/www/html richarvey/nginx-php-fpm
[root@localhost conf.d]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb26d42cdce7 richarvey/nginx-php-fpm "docker-php-entryp..." 2 hours ago Up 2 hours 443/tcp, 9000/tcp, 0.0.0.0:8888->80/tcp php-fpm
3、部署nginx服务器
server { listen 80; server_name localhost; ## send request back to docker ## location / { proxy_pass http://127.0.0.1:9000; #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } ##access_log /data/logs/access_retmobao.789et.com_$year-$month-$day.log ; access_log off; }
4、测试php环境
<?php echo "this is php"; ?>