网站迁移到 DNMP 啦

文档

DNMP 详细配置查看文档

1 备份数据库

mysqldump -h127.0.0.1 -uroot -pmima --all-databases > all_databases.sql

2 安装

git clone https://github.com/yeszao/dnmp

cd dnmp 

cp .env.sample //注意配置mysql和redis的访问策略
cp docker-compose.sample.yml docker-compose.yml // 把注释取消开启相应的服务

docker-compose up -d

3 nginx配置

  • nginx 配置需改一个参数

    php 是启动的容器名称

    fastcgi_pass   php:9000;
  • localhost.conf 示例文件中的,这一行配置, Laravel 不需要注销掉,要不会报错。下方有 Laravel 配置文件参考。

    include        fastcgi-php.conf;
  • 将 证书放在 ./services/nginx/ssl 目录下

    listen 443 ssl;
    ssl_certificate /ssl/xxxx;
    ssl_certificate_key /ssl/xxx;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    不支持ssl on;不要添加

4 mysql 配置

  • 第一次安装的时候需要进入到mysql容器内,运行 进入mysql
    mysql 

    设置远程连接

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
    flush privileges;

    要不会连接不上

5 恢复数据库

mysql -h127.0.0.1 -uroot -pmima -P3306 <all_databases.sql

6 laravel nginx 配置文件参考

server {
    listen *:80;
    server_name sso.jc91715.top;

    root /www/sites/sso.jc91715.top/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #fastcgi_pass unix:/run/php/php7.2-fpm.sock; 注销掉
        fastcgi_pass   php:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #include        fastcgi-php.conf; 注销掉
        include fastcgi_params;
        fastcgi_read_timeout 600;
    }

    location ~ /.well-known {
        allow all;
    }

    access_log /var/log/nginx/sso.jc91715.top.access.log;
    error_log  /var/log/nginx/sso.jc91715.top.error.log;
    client_max_body_size 200M;

    #ssl on;
    listen 443 ssl;
    ssl_certificate /ssl/cert/sso.jc91715.top/cert/ssl.crt;
    ssl_certificate_key /ssl/cert/sso.jc91715.top/cert/ssl.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    if ($scheme != "https") {
         return 301 https://$host$request_uri;
    }

}

Posted in docker || on Jan 13, 2021


Octobercms交流群