拉取并安装php5.6
docker pull php:5.6-fpm docker run --name php56fpm -v /srv/dev-disk-by-label-mybook1/var/php56/www:/var/www/html -v /srv/dev-disk-by-label-mybook1/var/php56/phpini:/ /usr/local/etc/php -p 9001:80 -d --restart=always --privileged=true php:5.6-fpm
*修改一下权限
chmod 777 -R /srv/dev-disk-by-label-mybook1/var/php56/www
给主机的nginx挂上php
在/etc/nginx/sites-enabled/中新建个文件multiphp
内容如下:
server { listen 8888; listen [::]:8888; server_name default_server; root /srv/dev-disk-by-label-mybook1/var/php56/www; index index.php index.html index.html; location / { try_files $uri $uri/ =404; } location ~ \.php$ { root /var/www/html; ### 这里必须指定容器内部的地址,默认就是这个路径 fastcgi_pass 172.17.0.5:9000; ###我的端口是这个,按需修改(因ip变动,后面修改为nasn1:9001) fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; include fastcgi_params; } }
增加拓展
进入docker命令行
docker exec -it php56fpm /bin/bash
安装 ifconfig, ping
apt update apt install net-tools iputils-ping
看看有没需要添加
apt-get install nano
安装依赖(安装gd扩展等必须要先安装系统依赖)
apt install libfreetype6-dev libmcrypt-dev libpng-dev libjpeg-dev libpng-dev sendmail zlib1g-dev docker-php-ext-install mysql docker-php-ext-install mysqli docker-php-ext-install gd docker-php-ext-install zip docker-php-ext-install mbstring docker-php-ext-install pdo_mysql