halo博客搭建
in 博客 with 0 comment

halo博客搭建

in 博客 with 0 comment

系统:centos7.5 64 账号与密码: root/Pure527yun

配置系统必须的环境

  1. 安装docker(部署mysql服务)

    • 查看系统版本

      cat /etc/redhat-release
      
    • 卸载旧版本

      sudo yum remove docker \
                        docker-client \
                        docker-client-latest \
                        docker-common \
                        docker-latest \
                        docker-latest-logrotate \
                        docker-logrotate \
                        docker-engine
      
    • 安装需要的软件包

      sudo yum install -y yum-utils \
        device-mapper-persistent-data \
        lvm2
      
    • 设置stable镜像仓库( https://download.docker.com/linux/centos/docker-ce.repo)

      sudo yum-config-manager \
          --add-repo \
          http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
      
    • 更新yum软件包索引

      yum makecache fast
      
    • 安装DOCKER CE 最新版

      sudo yum install -y docker-ce docker-ce-cli containerd.io
      
    • 启动docker

      sudo systemctl start docker
      
    • 测试

      docker version
      
    • 配置镜像加速

      mkdir -p /etc/docker
      vim  /etc/docker/daemon.json
      
      >>#阿里云镜像加速
      {
        "registry-mirrors": ["https://n6ltpjsy.mirror.aliyuncs.com"]
      }
      
      systemctl daemon-reload
      systemctl restart docker
      
    • 卸载

      systemctl stop docker 
      yum -y remove docker-ce
      rm -rf /var/lib/docker
      
    • 安装mysql服务

      # 查找 mysql
      docker search mysql
      # 拉取 mysql5.7
      docker pull mysql:5.7
      # 使用 mysql
      docker run -p 3306:3306 --name mysql -v /mydata/docker/mysql/conf:/etc/mysql/conf.d -v /mydata/docker/mysql/logs:/logs -v /mydata/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=pure527yun -d mysql:5.7
      
  2. 安装jdk1.8

    # 解压
    tar -zxvf jdk
    # 配置java
    vim /etc/profile
        # java environment  
        JAVA_HOME=/mydata/jdk1.8.0_191
        export JAVA_HOME
    
  3. 安装maven3

    # 解压
    tar -zxvf maven
    # 配置maven
    vim /etc/profile
        # maven environment
        MAVEN_HOME=/mydata/apache-maven-3.6.0
        export MAVEN_HOME
    
  4. 安装git

    # 查看 git 版本
    git --version
    # 卸载自带的git
    yum remove git
    # 安装所需软件包
    yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
    yum install -y gcc-c++ perl-ExtUtils-MakeMaker
    # 解压
    tar -zxvf git-2.20.1.tar.gz
    # 配置编译安装
    cd git-2.20.1
    ./configure --prefix=/mydata/git ##配置目录
    make && make install
    # 配置git
    vim /etc/profile
        # git environment
        GIT_HOME=/mydata/git
       export GIT_HOME
    
  5. 配置 jdk maven git

    # update path environment
    PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$GIT_HOME/bin:$PATH
    export PATH
    
    # 测试 jdk maven git
    java -version
    mvn -v
    git --version
    
  6. 安装nginx

    # 依赖安装
    yum install -y gcc-c++
    yum install -y pcre pcre-devel
    yum install -y zlib zlib-devel
    yum install -y openssl openssl-devel
    # 解压
    tar -zxvf nginx
    cd nginx
    # 配置
    ./configure \
    --prefix=/mydata/nginx \
    --with-http_ssl_module
    # 安装
    make && make install
    # 测试nginx
    ./nginx -v
    
    # 配置nginx  vim nginx.conf
    server {
            listen       80;
            server_name  localhost;
    
            location / {
               proxy_pass http://localhost:8090;        
            } 
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            rewrite ^(.*) https://$host$1 permanent;
        }
     # HTTPS server
        server {
            listen       443 ssl;
            server_name  localhost;
    
            ssl_certificate      /mydata/nginx/conf/cert/1_yxw920922.cn_bundle.crt;
            ssl_certificate_key  /mydata/nginx/conf/cert/2_yxw920922.cn.key;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
            location / {
                proxy_pass http://localhost:8090;
            }
        }
    
  7. 安装halo

    # 拉取源码 (git clone https://github.com/ruibaby/halo)
    git clone https://gitee.com/babyrui/halo
    # 修改配置文件(主要配置mysql连接信息)
    cd halo
    vim src/main/resources/application.yaml
    # 修改 deploy.sh
    HALO_DIR="/mydata/my_project/halo"
    # 部署 halo
    sh deploy.sh
    # 更新 halo
    cd halo
    git pull
    sh deploy.sh
    
0评论