docker下配置php
macos系统无法使用神通数据库,所以使用docker来安装php
第一步先安装php
docker search php
docker pull php:7.1-fpm
docker run --name php-test -d -v /Users/xxxx/docker/www:/var/www/html php:7.1-fpm
创建目录
mkdir /conf/conf.d/
vim test-php.conf
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;
}
}
第二部 安装nginx并关联php
docker search nginx
docker pull nginx
docker run -d -p 8081:80 --name nginx-test -v /Users/xxxx/docker/www:/usr/share/nginx/html -v /Users/xxxxx/docker/conf/conf.d:/etc/nginx/conf.d --link test-php:php nginx
现在可以运行了。。。
127.0.0.1:8081/index.php