docker pull nginx
docker run --name mynginx -p 80:80 -v /D/work/www:/var/www -v /D/woek/nginx/conf/conf.d:/etc/nginx/conf.d -d nginx
nginx.conf配置
# php
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name localhost;
root /var/www/vote/public;
index index.php;
location / {
#-e表示只要filename存在,则为真
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php7-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
docker pull php:7.1-fpm
docker run -p 9000:9000 --name phpfpm -v /D/work/www:/var/www -d php:7.1-fpm
docker pull mysql5.6
docker run -p 3306:3306 --name mysql5.6 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
docker常用基本命令
docker inspect --format='{{.NetworkSettings.IPAddress}}' 容器名称 查看容器ip
docker ps 查看运行的容器
docker rm -f 容器id 删除容器
docker start/stop/restart 启动/停止/重启 容器
docker images 查看下载的镜像
docker rmi 镜像名称 删除镜像
docker search 搜索docker仓库里面的镜像
docker exec -it 容器id /bin/bash 进入容器打开shell交互
fastadmin安装成功提示模块不存在
location / {
try_files $uri $uri/ /index.php$is_args$args;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.+?\.php)(/.+)$ /$1?s=$2 last;
rewrite ^(.*)$ /你的后台入口文件?s=$1 last; #注意 这里要替换成你的后台入口文件
break;
}
}
docker php could not find drive
原因是缺少pdo模块 进入php容器 运行
docker-php-ext-install mysqli pdo pdo_mysql
docker fastadmin Call to undefined function think\captcha\imagettftext()
- THE END -
最后修改:2022年1月25日
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://www.95app.top/docker-%e5%ae%89%e8%a3%85-nginx-php-mysql%e7%8e%af%e5%a2%83-fastadmin/