看着图床挂了之后博客中满眼的Chevereto 404图片,内心的崩溃的。为啥不好好做备份呢
最早博客图床用的是七牛云,每个月有免费的10G HTTP流量对于这个根本没人看的站来说绰绰有余。后来上了 HTTPS 之后就只好给七牛交几毛钱使用费。然而近几年域名备案政策严格。未备案的域名已经无法使用国内的云服务了。只好选择自己搭建图床系统。其中 Chevereto 应该算是最好用的了。之前好像用的 Docker 安装。这次尝试了下直接安装。因为不熟悉 PHP 网站部署踩了一点坑……
Chevereto 部署
首先安装依赖(不含 Nginx 和 Mysql)
sudo apt install -y php-fpm php-mysql php-curl php-gd php-mbstring php-zip
安装 Chevereto 的话,比起网上的下载源码安装。我更推荐使用官网的在线安装脚本 https://chevereto.com/free
mkdir chevereto
wget -O chevereto/index.php -c https://chevereto.com/download/file/installer
chmod 777 -R chevereto
然后添加 Nginx 配置文件。
server {
listen 443;
server_name chevereto.kdwycz.com;
access_log /var/log/nginx/chevereto.access.log kd_access_log;
error_log /var/log/nginx/chevereto.error.log;
index index.php index.html index.htm index.nginx-debian.html;
root /home/kdwycz/chevereto/;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
#Chevereto: Pretty URLs
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
#Chevereto: Disable access to sensitive files
location ~* /(app|content|lib)/.*\.(po|php|lock|sql)$ {
deny all;
}
#Chevereto: Upload path for image content only and set 404 replacement
location ^~ /images/ {
location ~* (jpe?g|png|gif) {
log_not_found off;
error_page 404 /content/images/system/default/404.gif;
}
return 403;
}
# Image not found replacement
location ~* (jpe?g|png|gif) {
log_not_found off;
error_page 404 /content/images/system/default/404.gif;
}
# CORS header (avoids font rendering issues)
location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
add_header Access-Control-Allow-Origin "*";
}
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 60m;
ssl_session_tickets on;
# ssl_stapling on;
# ssl_stapling_verify on;
# ssl_trusted_certificate;
ssl_certificate /home/kdwycz/certs/cert.pem;
ssl_certificate_key /home/kdwycz/certs/privkey.pem;
}
server {
listen 80;
server_name chevereto.kdwycz.com;
if ($request_method = GET) {
return 301 https://$server_name$request_uri;
}
return 308 https://$server_name$request_uri;
}
Nginx 配置生效后,就可以打开网址。配置站点名,数据库,初始超级用户,等待自动安装完成了。