chevereto图床程序的安装与迁移

实用工具 虚幻 562℃ 0评论

前言

之前自建了一个chevereto图床程序,但是现在遇到了迁移的问题,这里做一个记录

安装

首先在新的服务器上安装一个chevereto,这里采用的chevereto免费版
首先需要使用bt.cn/lnmp.org搭建相应环境

#进入网站目录
cd /home/wwwroot/你的域名
#下载程序
wget https://github.com/Chevereto/Chevereto-Free/archive/1.1.3.zip
#解压
unzip 1.1.3.zip
#转移文件至网站根目录
Chevereto-Free-1.1.3/* ./
#更改目录权限
chown /home/wwwroot/你的域名 -R www:www

由于这里采用的是NGINX,所以还需要修改NGINX的伪静态配置
vi /usr/local/nginx/conf/vhost/你的域名.conf

# Chevereto Nginx rewrite rules
# Make sure to place these inside your server{} block

# Disable access to .ht* files
location ~ /\.ht {
    deny all;
}

# Disable access to sensitive files in app path
location ~ /(app|content|lib)/.*\.(po|php|lock|sql)$ {
   deny all;
}

# Disable log on not found images + image replacement
location ~* (jpe?g|png|gif) {
    log_not_found off;
    error_page 404 /content/images/system/default/404.gif;
}

# Enable CORS header (needed for CDN)
location ~* \.(ttf|ttc|otf|eot|woff|woff2|css|js)$ {
    add_header Access-Control-Allow-Origin "*";
}

# Force serve upload path as static content (match your upload folder if needed)
location /images {}

# Route dynamic request to index.php
location / {
    try_files $uri $uri/ /index.php?$query_string;
}

现在访问你的域名按照提示一步一步的安装即可。

迁移

因为某些原因,我需要把图床从一台服务器迁移到另外一台服务器。
一般迁移网站有两个部分,数据库的迁移,网站文件的迁移。
数据库迁移
备份数据库

#-p密码,这里没有空格,-p和密码是连载一起的,chevereto代表,图床数据库
mysqldump -u root -p密码 --databases chevereto  > /root/img.dump

把img.dump上传到新服务器,然后恢复数据库

mysql -u root -p密码 < /root/img.dump #dump文件路径请根据实际情况选择

打包图片
我们迁移网站的时候,可以把整个网站打包,也可以只打包需要的部分,这里就只打包了图片

tar -cf img.tar /home/wwwroot/你的域名/images

将img.tar上传新文章,然后将文件解压到/home/wwwroot/你的域名/images即可

tar -xf img.tar
mv images/* /home/wwwroot/你的域名/images

现在可以访问你的域名了,你能够看到网站迁移已经完成了。

转载请注明:虚坏叔叔 » chevereto图床程序的安装与迁移

喜欢 (12)

您必须 登录 才能发表评论!