0%

VPS 部署hexo blog

思路

blog:hexo
静态页面->nginx
部署:rsync

nginx

1
2
3
4
5
6
7
8
9
10
/etc/yum.repo/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

yum install nginx
cd /etc/nginx/sites-available
vi sample.com

导入站点配置内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
server{
listen 45.62.103.228:80 default_server;
root /var/www/fivelike.com/;
server_name fivelike.xyz;
access_log /var/log/nginx/fivelike_access.log;
error_log /var/log/nginx/fivelike_error.log;
location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
root /var/www/fivelike.xyz/;
access_log off;
expires 1d;
}
location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
root /var/www/fivelike.xyz/;
access_log off;
expires 10m;
}
location / {
root /var/www/fivelike.xyz;
if (-f $request_filename){
rewrite ^/(.*)$ /$1 break;
}
}
}

建立软链接

1
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

在/etc/nginx/nginx.conf http block:

1
include /etc/nginx/sites-enabled/*;

query port 80

1
2
3
4
lsof -i:80
firewall-cmd --add-port=80/tcp --zone=public --permanent
systemctl restart nginx.service
firewall-cmd --list-ports

rsync部署

1
rsync -arvp --delete-after -rsh="ssh" /home/fivelike/a/blog/public/ root@ xxx.xxx.xxx.xxx:/var/www/fivelike.xyz/