Fork me on GitHub

vapor

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159


kill 进程
sudo lsof -i :8080

Nginx配置:

替换以下“你的域名” 为你的域名地址, api 根据你的需要换成 www 或者其他字符。

第一步
sudo vi /etc/nginx/sites-available/api.你的域名.com

第二步,填入以下内容,然后按 esc 输入 :wq 按回车

server {
server_name api.你的域名.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
location @proxy {
proxy_pass http://127.0.0.1:8080;
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
}
}



[program:hello]
command=sudo /home/ubuntu/hello/.build/release/Run serve --env=production
directory=/home/ubuntu/Hello
autorestart=false
user=root
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log

command=/home/vapor/ubuntu/hello/.build/release/Run serve --env=production
directory=/home/vapor/hello/
user=www-data
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log


运行

$ sudo supervisorctlre read
$ sudo supervisorctl add hello
$ sudo supervisorctl start hello
sudo supervisorctl start hellofind / -name supervisor.sock




第三步 执行1
sudo ln -s /etc/nginx/sites-available/api.你的域名.com /etc/nginx/sites-enabled/api.你的域名.com

sudo ln -s /etc/nginx/sites-available/hexo.com /etc/nginx/sites-enabled/hexo.com

第四步,执行以下2个命令
sudo service nginx start
sudo service nginx reload

sudo service nginx restart


api
server {
server_name api.liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
location @proxy {
proxy_pass http://127.0.0.1:8080;
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_redirect off;
}
}


blog
server{
listen 8081 default_server;
listen [::]:8081 default_server;
server_name blog.liangdahong.com;
root /home/hexoBlog;
}
server {
server_name blog.liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
root /home/hexoBlog;
location @proxy {
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_redirect off;
}
}

server {
server_name liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
root /home/ubuntu/hexoBlog/other/me;
location @proxy {
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_redirect off;
}
}




server {
listen 8081 default_server;
listen [::]:8081 default_server;
server_name blog.liangdahong.com;
root /home/hexoBlog;
}

server {
listen 8081 default_server;
listen [::]:8081 default_server;
server_name blog.liangdahong.com;
root /home/hexoBlog;
}

sudo ln -s /etc/nginx/sites-available/api.liangdahong.com /etc/nginx/sites-enabled/api.liangdahong.com
sudo ln -s /etc/nginx/sites-available/hexo.com /etc/nginx/sites-enabled/hexo.com
第四步,执行以下2个命令
vim
sudo service nginx reload


sudo ln -s /etc/nginx/sites-available/blog.liangdahong.com /etc/nginx/sites-enabled/blog.liangdahong.com
sudo ln -s /etc/nginx/sites-available/api.liangdahong.com /etc/nginx/sites-enabled/api.liangdahong.com

mac -> linux

https://blog.csdn.net/m82_a1/article/details/97624965

使用 id_rsa.pub

/home/ubuntu/.ssh/authorized_keys

scp /Users/Mac/Desktop/1/He.java ubuntu@123.207.253.160:/home/ubuntu/

scp /Users/bluemoon/Desktop/未命名文件夹/操作.jpeg ubuntu@123.207.253.160:/home/ubuntu/

注意腾讯的是 ubuntu 不是 root

scp /home/hexoBlog/index.html /home/root/

scp -r /Users/Mac/Desktop/root ubuntu@123.207.253.160:/home/

sudo scp -r /Users/Mac/Desktop/root ubuntu@123.207.253.160:/home/

sudo scp -r /Users/Mac/Desktop/me ubuntu@123.207.253.160:/home/ubuntu/

sudo scp -r /Users/Mac/Desktop/2.底层下-原理.png ubuntu@123.207.253.160:/home/ubuntu/

sudo chmod -R 777 myResources
-R 是指级联应用到文件夹里的全部子文件夹和文件
777 是全部用户都拥有最高权限
myResources 具体的文件夹或者资源

ssh 登录到ubuntu

ssh ubuntu@123.207.253.160

进入 root
su root
退出 root
exit

// 看系统版本
cat /etc/issue

apt install nginx-core
apt install nginx-extras
apt install nginx-full
apt install nginx-light

ssl

sudo scp /home/ubuntu/hexoBlog/other/Resources/blog.liangdahong.com/Nginx/1_blog.liangdahong.com_bundle.crt /etc/nginx/
sudo scp /home/ubuntu/hexoBlog/other/Resources/blog.liangdahong.com/Nginx/2_blog.liangdahong.com.key /etc/nginx/

server {

#SSL 访问端口号为 443
listen 443; 
#填写绑定证书的域名
server_name blog.liangdahong.com; 
#启用 SSL 功能
ssl on;
#证书文件名称
ssl_certificate 1_blog.liangdahong.com_bundle.crt; 
#私钥文件名称
ssl_certificate_key 2_blog.liangdahong.com.key; 
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
ssl_prefer_server_ciphers on;
location / {
   #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
    root /home/ubuntu/hexoBlog; 
    index  index.html index.htm;
}

}

server {
server_name blog.liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
root /home/ubuntu/hexoBlog;
location @proxy {
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_redirect off;
}
}

sudo service nginx restart

sudo scp /home/ubuntu/hexoBlog/other/Resources/liangdahong.com/Nginx/1_liangdahong.com_bundle.crt /etc/nginx/
sudo scp /home/ubuntu/hexoBlog/other/Resources/liangdahong.com/Nginx/2_liangdahong.com.key /etc/nginx/

server {

#SSL 访问端口号为 443
listen 443; 
#填写绑定证书的域名
server_name liangdahong.com; 
#启用 SSL 功能
ssl on;
#证书文件名称
ssl_certificate 1_liangdahong.com_bundle.crt ; 
#私钥文件名称
ssl_certificate_key 2_liangdahong.com.key; 
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
ssl_prefer_server_ciphers on;
location / {
   #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
    root /home/ubuntu/hexoBlog/other/me; 
    index  index.html index.htm;
}

}

sudo scp /home/ubuntu/hexoBlog/other/Resources/resume.liangdahong.com/Nginx/1_resume.liangdahong.com_bundle.crt /etc/nginx/
sudo scp /home/ubuntu/hexoBlog/other/Resources/resume.liangdahong.com/Nginx/2_resume.liangdahong.com.key /etc/nginx/
server {

#SSL 访问端口号为 443
listen 443; 
#填写绑定证书的域名
server_name resume.liangdahong.com; 
#启用 SSL 功能
ssl on;
#证书文件名称
ssl_certificate 1_resume.liangdahong.com_bundle.crt ; 
#私钥文件名称
ssl_certificate_key 2_resume.liangdahong.com.key ; 
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
ssl_prefer_server_ciphers on;
location / {
   #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
    root /home/ubuntu/hexoBlog/other/resume; 
    index  index.html index.htm;
}

}

vapor ssl

server {
server_name api.liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
location @proxy {
proxy_pass http://127.0.0.1:8080;
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
}
}
sudo scp /home/ubuntu/hexoBlog/other/Resources/api.liangdahong.com/Nginx/1_api.liangdahong.com_bundle.crt /etc/nginx/
sudo scp /home/ubuntu/hexoBlog/other/Resources/api.liangdahong.com/Nginx/2_api.liangdahong.com.key /etc/nginx/

server {

# SSL 访问端口号为 443

​ listen 443;

# 填写绑定证书的域名

​ server_name api.liangdahong.com;

# 启用 SSL 功能

​ ssl on;

# 证书文件名称

​ ssl_certificate 1_api.liangdahong.com_bundle.crt ;

# 私钥文件名称

​ ssl_certificate_key 2_api.liangdahong.com.key ;
​ ssl_session_timeout 5m;

# 请按照以下协议配置

​ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

# 请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。

​ ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
​ ssl_prefer_server_ciphers on;
​ location / {
​ proxy_pass http://127.0.0.1:8080;
​ proxy_pass_header Server;
​ 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_pass_header Server;
​ proxy_connect_timeout 3s;
​ proxy_read_timeout 10s;
​ }
}

Hexo 从 Github 或者 Codeing 迁移到腾讯云

环境是:Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-54-generic x86_64)

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 创建 nginx 的配置信息
// cd 到目录下
cd /etc/nginx/conf.d/

// 创建具体的配置文件 xxx.conf
sudo vim blog.conf
// 输入:

// https 配置,这里是使用的腾讯免费一年的 SSL 证书
// 主要修改:server_name ssl_certificate ssl_certificate_key root 这 4 个内容
server {
#SSL 访问端口号为 443
listen 443;
#填写绑定证书的域名
server_name blog.liangdahong.com;
#启用 SSL 功能
ssl on;
#证书文件名称
ssl_certificate 1_blog.liangdahong.com_bundle.crt;
#私钥文件名称
ssl_certificate_key 2_blog.liangdahong.com.key;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
#网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
root /home/ubuntu/hexoBlog;
index index.html index.htm;
}
}

// http 配置
// 主要修改:server_name root 这 2 个内容
server {
server_name liangdahong.com;
listen 80;
try_files $uri @proxy;
client_max_body_size 20m;
root /home/ubuntu/hexoBlog/other/me;
location @proxy {
proxy_pass_header Server;
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_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_redirect off;
}
}

// wq 保存
// 重新启动 nginx
sudo service nginx restart

vapor 具体操作流程

Vapor Nginx Supervisor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
supervisorctl help   // supervisorctl 帮助

sudo supervisorctl status // 查看所有进程的状态
sudo supervisorctl update // 配置文件修改后使用该命令加载新的配置
sudo supervisorctl reload // 重新启动配置中的所有程序

sudo supervisorctl stop hello // 停止 hello
sudo supervisorctl start hello // 启动 hello
sudo supervisorctl restart hello // 重启 hello
sudo supervisorctl status hello // 查看指定进程的状态


注:
1、把 hello 换成 hello 可以管理配置中的所有进程。
2、直接输入 supervisorctl 进入 supervisorctl 的 shell 交互界面,此时上面的命令不带 supervisorctl 可直接使用。
1
2
3
4
5
6
7
8
1、修改代码
2、编译
2.1、vapor build 编译项目
2.2、sudo vapor build --release 打包项目
2.3、vapor run serve 运行项目

3、重新启动 supervisor 里面和自动运行服务
sudo supervisorctl restart hello
1
2
3
4
5
6
7
8
9
Ubuntu 上 SSH 免密登录 macOS
// macOS
vim ~/.ssh/id_rsa.pub

// Ubuntu
将 macOS id_rsa.pub 的内容拷贝到此文件中
sudo vim ~/.ssh/authorized_keys

sudo service ssh start
- END -
扫一扫上面的二维码图案,加我微信

文章作者:梁大红

特别声明:若无特殊声明均为原创,转载请注明,侵权请联系

版权声明:署名-非商业性使用-禁止演绎 4.0 国际