sudo yum update
sudo yum install java-1.8.0-openjdk
java -version
作者归档:Rick
使用 Let’s Encrypt 免费申请泛域名 SSL 证书,并实现自动续期
参考:
https://www.cnblogs.com/michaelshen/p/18538178
https://letsencrypt.org/getting-started/
https://certbot.eff.org/
certbot 选择平台
My HTTP website is running Nginx
ON Linux
(snap)
按照提示操作如下:
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
sudo certbot renew --dry-run
手动部署 sharp-admin 应用
- 购买云服务器,操作系统 centos
- 配置免密登录https://xhope.top/?p=1722
- 安装 Nginx https://xhope.top/?p=1768
- 域名解析 & 配置方向代理
vim /etc/nginx/conf.d/sharp-admin.conf
sharp-admin.conf
server {
listen 80;
server_name sharp-admin.xhope.top;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- 配置证书,并自动续期https://xhope.top/?p=1783
- 安装 MySQL https://xhope.top/?p=1765
- 安装 MariaDB https://xhope.top/?p=1763
- 安装 jre 1.8 https://xhope.top/?p=1788
- 上传文件
mkdir -p /usr/local/projects/sharp-admin
目录结构
├── deploy
│ └── sharp-admin-2.0-SNAPSHOT.jar
├── application-prod.yml(可选)
├── sharp-admin.sql
├── config.sh
└── deploy.sh
└── mysqldump.sh
└── mysqldump
- 数据库初始化
mysql -uroot -p123456 sharp-admin < /usr/local/projects/sharp-admin/sharp-admin.sql
– 启动 sharp-admin 应用
sh deploy.sh
访问 sharp-admin.xhope.top
– 数据库备份
chmod +x /usr/local/projects/sharp-admin/mysqldump.sh
crontab -e
0 23 * * * /usr/local/projects/sharp-admin/mysqldump.sh
- 创建服务,开机启动 sharp-admin 应用 https://xhope.top/?p=1773
- 数据库备份上传 OSS https://xhope.top/?p=1803
crontab -e
40 23 * * * bash -c 'source ~/.bash_profile && /usr/bin/python3 /usr/local/projects/sharp-admin/upload.py'
创建服务,开机启动 sharp-admin 应用
创建 Service 文件
vim /etc/systemd/system/sharp-admin.service
写入以下内容:
[Unit]
Description=Sharp Admin Deploy Service
After=network.target mysql.service
Requires=mysql.service
[Service]
Type=simple
# ExecStart=/bin/bash -c 'nohup java -Xms1024m -Xmx2048m -Dspring.profiles.active=prod -jar /usr/local/projects/sharp-admin/sharp-admin-2.0-SNAPSHOT.jar --server.port=8080 &'
ExecStart=/usr/local/projects/sharp-admin/deploy.sh
WorkingDirectory=/usr/local/projects/sharp-admin
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
如果数据库是 mariadb
上面需要替换成 mariadb.service
添加deploy.sh
可执行权限
chmod +x /usr/local/projects/sharp-admin/deploy.sh
启用并启动服务
sudo systemctl daemon-reload
sudo systemctl enable sharp-admin.service
sudo systemctl start sharp-admin.service
Centos7 安装 Nginx
参考https://nginx.org/en/linux_packages.html#RHEL
Install the prerequisites:
sudo yum install yum-utils
To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:
sudo yum-config-manager --enable nginx-mainline
To install nginx, run the following command:
sudo yum install nginx
start
nginx
设置开机启动
sudo systemctl enable nginx