续费了三四年的搬瓦工传家宝终于不能续费了,本博客也得迁移了。正好阿里云推出了香港轻量应用服务器,24元一个月,不用备案。看起来不错,先试试这个~
同时原始域名isnow.pw续费金额太高,暂时修改域名为ipoi.bid。

服务器修改

用户目录创建

创建myblog用户,同时创建myblog主目录

1
useradd -m myblog

创建myblog用户密码

1
passwd myblog

nginx安装

本系统使用的是ubuntu16.04。使用apt-get快速安装nginx

1
2
apt-get update
apt-get install nginx

此时使用ip即可访问nginx主页。

nginx配置

nginx绑定域名,使ip访问自动跳转域名。绑定myblog用户空间。设置404页面等等
修改/etc/nginx/sites-available/default 这个配置文件
打开/etc/nginx/sites-available/default这个文件进行修改。

1
vi /etc/nginx/sites-available/default 

修改内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home/myblog;
index index.html index.htm index.php;

server_name ipoi.bid www.ipoi.bid;
if ( $host != 'ipoi.bid'){
rewrite ^(.*)$ http://ipoi.bid;
}
error_page 404 /404.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}

重启nginx服务

1
service nginx restart

此时要验证是否修改成功,可以往/home/myblog目录下新建一个index.html尝试

rsync配置(此部分可跳过)

启用rsync

1
vim /etc/default/rsync
1
RSYNC_ENABLE=true   #false改true

拷贝/etc/rsyncd.conf 文件

1
sudo cp /usr/share/doc/rsync/examples/rsyncd.conf /etc

修改rsyncd.conf配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
log file=/var/log/rsyncd
pid file=/var/run/rsyncd.pid
syslog facility=daemon
[myblog]

comment = public archive
path = /home/myblog
use chroot = yes
# max connections=10
lock file = /var/lock/rsyncd
# the default for read only is yes...
read only = no
list = yes
uid = nobody
gid = nogroup
# exclude =
# exclude from =
# include =
# include from =
auth users = myblog
# secrets file = /etc/rsyncd.secrets
strict modes = yes
# hosts allow =
# hosts deny =
ignore errors = no
ignore nonreadable = yes
transfer logging = no
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz

博客修改

_config.yml

修改域名地址 以及rsync配置

1
2
3
4
5
6
7
8
9
10
11
12
13
# 域名地址部分
url: http://ipoi.bid

#rsync配置
deploy:
type: rsync
host: ipoi.bid
user: myblog
root: /home/myblog
port: 22
delete: false
verbose: true
ignore_errors: false

现在本地重新生成上传博客即可

1
hexo d -g

到现在为止 我们的博客就迁移好了!