树莓派docker安装nginx+php备忘录
2019-05-26 本文已影响0人
学无止境吧
安装docker以及nginx和php
curl -sSL https://get.docker.com | sh
docker -version
docker start
docker pull nginx
docker pull php:7.2-fpm
docker run -p 8001:80 --name mynginx -v /home/www:/www -v /home/conf.d:/etc/nginx/conf.d -d ce58e9437cd7
docker run -p 9000:9000 --name php72 -v /home/www:/www -d aac9af4c4c13
树莓派文件目录 /home/conf.d 下面新建一个文件 www.conf
;vim www.conf
server{
listen 80;
server_name www;
root /www;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
location / {
index index.html index.htm index.php;
}
location ~ \.php {
root /www;
include fastcgi_params;
fastcgi_pass 172.17.0.3:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
查看容器内网ip
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
安装mysql
docker pull hypriot/rpi-mysql
docker run --name mysql -e MYSQL_ROOT_PASSWORD=1Qaz2wsx -d -p 3306:3306 hypriot/rpi-mysql
因为mysql数据运行在容器中,记得定时备份数据
docker exec -it mysql mysqldump -uroot -p1Qaz2wsx testdb > /home/sql_bak/test_db.sql