阿里云 ECS+CADDY+TOMCAT+MYSQL 搭建 SOLO 博客

本贴最后更新于 2114 天前,其中的信息可能已经事过景迁

阿里云 ECS 直接买了 5 年

image.png

  • 域名很早以前的一直没有备案

CADDY

https://caddyserver.com/download 插件随便选

curl https://getcaddy.com | bash -s personal dyndns,http.cache,http.git,http.login,http.upload,http.webdav
  • /etc/caddy/Caddyfile
:80 {

  root /www
  index index.html
  gzip
  log /www/log/access.log
  basicauth /file "用户名" "密码"
  browse /file /www/album.tpl
  errors /www/log/error.log {
    rotate_size      10
    rotate_age      30
    rotate_keep     20
    rotate_compress

    404 404.html
    500 500.html
  }
  gzip {
    ext        *
    level       1
    not        /images /videos
  }
  header / {
    # Enable HTTP Strict Transport Security (HSTS) to force clients to always
    # connect via HTTPS (do not use if only testing)
    Strict-Transport-Security "max-age=31536000;"
    # Enable cross-site filter (XSS) and tell browser to block detected attacks
    X-XSS-Protection "1; mode=block"
    # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
    X-Content-Type-Options "nosniff"
    # Disallow the site to be rendered within a frame (clickjacking protection)
    X-Frame-Options "DENY"
  }
  header /api {
    Access-Control-Allow-Origin  *
    Access-Control-Allow-Methods "GET, POST, OPTIONS"
    -Server
  }
  internal /internal
  log / /www/log/caddy.log  {
    rotate_size 10  # Rotate after 50 MB
    rotate_age  30  # Keep rotated files for 90 days
    rotate_keep 20  # Keep at most 20 log files
    rotate_compress # Compress rotated log files in gzip format
  }
  limits {
    header 100KB
    body   /upload 100MB
    body   /profile 25KB
    body   /api 10KB
  }
  markdown /blog {
    ext      .md .txt
    css     /css/blog/.css
    js      /js/blog.js

    template default.html
    template blog  blog.html
    template about about.html
  }
  proxy /solo 0.0.0.0:8080 {
     transparent
     except /opt/tomcat/webapps/solo
  }
  proxy /b baidu.com
  push /push

#########################################################
  basicauth /dav "用户名" "密码"
  webdav /dav {
    scope /webdav
    modify      false
    allow       /www/dav
#    allow_r     regex
    block       /www
#    block_r     regex
  }
}

TODO:dav 没配好不能访问

TOMCAT9.0.16+JAR1.8.0_201

echo "# JAVA
export JRE_HOME=/usr/local/jre
export PATH=$JRE_HOME/bin:$PATH
export CLASSPATH=.:$JRE_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar" >> /etc/profile

TOMCAT 安装配置

MYSQL 安装

配置 apt-get 源
MySQL APT Respository

image.png

wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
dpkg -i ./mysql-apt-config_*_all.deb
apt-get update
apt-get install mysql-server
service mysql start
mysql -u root -p
CREATE DATABASE solo DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'solo'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON solo.* TO 'solo'@'localhost';
FLUSH PRIVILEGES;

当时 ftp 没配好 war 放网盘里了 http://ys-n.ys168.com/604076540/l4T465H378NHLT8fSWV/solo.war

下载放进 /opt/tomcat/webapps

打工告成
image.png

image.png
dav 没配好 可以用这个看 log

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...