作者: admin

  • docker-compose thinkphp连接mysql出现错误(HY000/2002): Connection refused

    db:
        image: mysql:5.7
        volumes:
          - ./mysql:/var/lib/mysql
        restart: always

    根据doker-compose.yml里面文件数据库的配置命名db,php中连接的 mysql 地址就是 db,不用 localhost 或127.0.0.1

    如果是thinkphp5的话,修改config/database.php里面数据库的地址为db

    如果是thinkphp6的话,修改根目录下的.env文件

    APP_DEBUG = true
    
    [APP]
    DEFAULT_TIMEZONE = Asia/Shanghai
    
    [DATABASE]
    TYPE = mysql
    HOSTNAME = db //这里改成docker中数据库的命名
    DATABASE = mydatebase
    USERNAME = root
    PASSWORD = password
    HOSTPORT = 3306
    CHARSET = utf8
    DEBUG = true
    
    [LANG]
    default_lang = zh-cn
  • thinkphp6只能打开首页,或者服务器500错误

    根据官方文档,把nginx配置文件改成

    location / {
      if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
      }
    }  
  • koa的常用插件

    • bodyparser
    • koa-router
  • 记事本

    命令行

    • 光标移动到命令行最前面/后面 ctrl+a/ctrl+e

    Chrome浏览器

    • 撤销刚刚关闭的页面 command+shift+T
  • next.js如何使用axios请求数据

    next.js官方的demo中使用的fetch来获取异步数据,那么问题来了,如何使用axios请求数据?

    
    export default function Home({articles}) {
      return (
        <div>
          {articles.data.map(item=><div>{item.title}</div>)}
        </div>
      )
    }
    export async function getStaticProps() {
      // Call an external API endpoint to get posts
      const articles = await Axios({
        method: 'get',
        url: '/articlelist?page=1',
      })
    
      return {
        props: {
          articles:articles.data,
        },
      }
    }
    

    常见错误如下:

    Error: Error serializing `.articles` returned from `getStaticProps` in “/”. Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.

    如果 Axios前面忘记写 await 会出现这个错误提示

  • docker-compose安装wordpress

    1,新建目录wordpress

    2,在wordpress目录下创建 docker-compose.yml

    version: '3.1'
    services:
      wordpress:
        image: wordpress
        restart: always
        ports:
          - 8080:80
        environment:
          WORDPRESS_DB_HOST: db
          WORDPRESS_DB_USER: exampleuser
          WORDPRESS_DB_PASSWORD: examplepass
          WORDPRESS_DB_NAME: exampledb
        volumes:
          - ./wordpress:/var/www/html
      db:
        image: mysql:5.7
        restart: always
        environment:
          MYSQL_DATABASE: exampledb
          MYSQL_USER: exampleuser
          MYSQL_PASSWORD: examplepass
          MYSQL_RANDOM_ROOT_PASSWORD: '1'
        volumes:
          - ./db:/var/lib/mysql

    4,进入wordpress目录下,启动docker-compose

    docker-compose up -d

    5,关闭

    docker-compose down
  • centos如何安装docker-compose

    上面的文章是centos如何安装docker

    一,判断是否安装docker-compose

    docker-compose version

    二,如果你在windows或者mac安装了docker desktop或者toolbox,说明你已经安装了docker compose,可以直接使用。

    三,如果你是linux,你需要再安装docker compose

    1 运行下面的命令,下载docker compose的当前稳定版本

    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

    2 可执行操作

    sudo chmod +x /usr/local/bin/docker-compose

    参考: https://docs.docker.com/compose/install/

  • next.js安装antd

    example@example.com
    123-456-7890

    东长安街1号
    北京市东城区,100000

  • fatal: unable to access ‘https://github.com/tailwindlabs/heroicons.git/’: Encountered end of file

    fatal: unable to access ‘https://github.com/tailwindlabs/heroicons.git/’: Encountered end of file

    解决办法

    git config –global –unset https.proxy 

  • nextjs报错ChunkLoadError: Loading chunk node_modules_next_dist_client_dev_noop_js failed

    nextjs报错

    ChunkLoadError: Loading chunk node_modules_next_dist_client_dev_noop_js failed

    解决办法

    删除.next目录