最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Vultr中更新和配置crifan.org的虚拟主机和域名

Web crifan 2090浏览 0评论

折腾:

【已解决】恢复crifan.org的WordPress到Vultr的CentOS7的OneinStack中

期间,借助于Vultr中CentOS7中OneinStack的vhost去添加域名

以及同时去更新DNS域名配置。

此处有两个域名

www.crifan.org

book.crifan.org

通过OneinStack中添加虚机主机

交互安装 – OneinStack

Welcome to use OneinStack

./vhost.sh

不过弄之前,先去更新DNS的IP

去腾讯云的域名管理

腾讯云 – 产业智变 云启未来

我的解析

https://console.cloud.tencent.com/cns

把IP地址从:

150.109.113.228

改为:

149.28.136.189

然后就等IP生效了。

等域名生效后,再去

vhost.sh

➜  use_wget_download ping www.crifan.org
PING www.crifan.org (149.28.136.189): 56 data bytes
64 bytes from 149.28.136.189: icmp_seq=0 ttl=48 time=253.885 ms
64 bytes from 149.28.136.189: icmp_seq=1 ttl=48 time=259.658 ms
Request timeout for icmp_seq 2
64 bytes from 149.28.136.189: icmp_seq=3 ttl=48 time=255.066 ms

已经可以了。

那继续去:

vhost.sh

参考:

【已解决】WordPress网站crifan.org搬家腾讯云后解决二级域名book.crifan.org的页面访问 – 在路上

和官网文档:

交互安装 – OneinStack

还是添加

book.crifan.org

[root@crifan oneinstack]# ./vhost.sh 


#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################


What Are You Doing?
        1. Use HTTP Only
        2. Use your own SSL Certificate and Key
        3. Use Let's Encrypt to Create SSL Certificate and Key
        q. Exit
Please input the correct option: 3


Please input domain(example: www.example.com): www.crifan.org
domain=www.crifan.org


Please input the directory for the domain:www.crifan.org :
(Default directory: /data/wwwroot/www.crifan.org): 
Virtual Host Directory=/data/wwwroot/www.crifan.org


Create Virtul Host directory......
set permissions of Virtual Host directory......


Do you want to add more domain name? [y/n]: book.crifan.org
input error! Please only input 'y' or 'n'


Do you want to add more domain name? [y/n]: y


Type domainname or IP(example: example.com other.example.com): book.crifan.org
domain list=book.crifan.org


Do you want to redirect from book.crifan.org to www.crifan.org? [y/n]: n


Do you want to redirect all HTTP requests to HTTPS? [y/n]: n
[Thu May 23 20:51:49 CST 2019] Create account key ok.
[Thu May 23 20:51:49 CST 2019] Registering account
[Thu May 23 20:51:50 CST 2019] Registered
[Thu May 23 20:51:50 CST 2019] ACCOUNT_THUMBPRINT='B0hxxxtcnw'
[Thu May 23 20:51:50 CST 2019] Creating domain key
[Thu May 23 20:51:50 CST 2019] The domain key is here: /root/.acme.sh/www.crifan.org/www.crifan.org.key
[Thu May 23 20:51:51 CST 2019] Multi domain='DNS:www.crifan.org,DNS:book.crifan.org'
[Thu May 23 20:51:51 CST 2019] Getting domain auth token for each domain
[Thu May 23 20:51:52 CST 2019] Getting webroot for domain='www.crifan.org'
[Thu May 23 20:51:52 CST 2019] Getting webroot for domain='book.crifan.org'
[Thu May 23 20:51:52 CST 2019] Verifying: www.crifan.org
[Thu May 23 20:51:55 CST 2019] Success
[Thu May 23 20:51:55 CST 2019] Verifying: book.crifan.org
[Thu May 23 20:51:58 CST 2019] Success
[Thu May 23 20:51:58 CST 2019] Verify finished, start to sign.
[Thu May 23 20:51:58 CST 2019] Lets finalize the order, Le_OrderFinalize: https://acme-v02.api.letsencrypt.org/acme/finalize/57656599/467085522
[Thu May 23 20:52:00 CST 2019] Download cert, Le_LinkCert: https://acme-v02.api.letsencrypt.org/acme/cert/03eb244b0b07ee2e010ea714d12941693036
[Thu May 23 20:52:00 CST 2019] Cert success.
-----BEGIN CERTIFICATE-----
MIIFZ
...
-----END CERTIFICATE-----
[Thu May 23 20:52:00 CST 2019] Your cert is in  /root/.acme.sh/www.crifan.org/www.crifan.org.cer 
[Thu May 23 20:52:00 CST 2019] Your cert key is in  /root/.acme.sh/www.crifan.org/www.crifan.org.key 
[Thu May 23 20:52:00 CST 2019] The intermediate CA cert is in  /root/.acme.sh/www.crifan.org/ca.cer 
[Thu May 23 20:52:00 CST 2019] And the full chain certs is there:  /root/.acme.sh/www.crifan.org/fullchain.cer 


Do you want to add hotlink protection? [y/n]: n


Allow Rewrite rule? [y/n]: y


Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog rewrite was exist.
(Default rewrite: other): wordpress
You choose rewrite=wordpress


Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/www.crifan.org_nginx.log


nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful
Reload Nginx......


#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  www.crifan.org
Virtualhost conf:             /usr/local/tengine/conf/vhost/www.crifan.org.conf
Directory of:                 /data/wwwroot/www.crifan.org
Rewrite rule:                 /usr/local/tengine/conf/rewrite/wordpress.conf
Let's Encrypt SSL Certificate:/usr/local/tengine/conf/ssl/www.crifan.org.crt
SSL Private Key:              /usr/local/tengine/conf/ssl/www.crifan.org.key

然后去访问

www.crifan.org

试试

403 Forbidden
Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
URL: 
https://www.crifan.org/ 
Server: 
crifan.org 
Date: 
2019/05/23 20:54:35 
Powered by Tengine
tengine

去放一个index.html过去

果然可以了:

说明www.crifan.org的域名和tengine正常了

那再去看看

book.crifan.org

先手动创建文件夹:

[root@crifan wwwroot]# mkdir book.crifan.org
[root@crifan wwwroot]# ll -hal
total 20K
drwxr-xr-x 5 root root 4.0K May 23 21:06 .
drwxr-xr-x 5 root root 4.0K May  9 21:51 ..
drwxr-xr-x 2 root root 4.0K May 23 21:06 book.crifan.org
drwxr-xr-x 3 www  www  4.0K May 23 21:02 default
drwxr-xr-x 2 www  www  4.0K May 23 21:02 www.crifan.org
[root@crifan wwwroot]# chown www:www book.crifan.org/
[root@crifan wwwroot]# ll -hal
total 20K
drwxr-xr-x 5 root root 4.0K May 23 21:06 .
drwxr-xr-x 5 root root 4.0K May  9 21:51 ..
drwxr-xr-x 2 www  www  4.0K May 23 21:06 book.crifan.org
drwxr-xr-x 3 www  www  4.0K May 23 21:02 default
drwxr-xr-x 2 www  www  4.0K May 23 21:02 www.crifan.org

然后此处发现

【已解决】WordPress网站crifan.org搬家腾讯云后解决二级域名book.crifan.org的页面访问 – 在路上

之前是

单独运行vhost去添加book.crifan.org

而上面是一起创建的

感觉不太对

后者需要额外设置才可以的

至少要去加上nginx配置

去想办法把此处之前nginx的配置:

加到现有的,tengine的配置中去

去看看配置:

/usr/local/tengine/conf/vhost/www.crifan.org.conf

[root@crifan wwwroot]# cd /usr/local/tengine/
[root@crifan tengine]# ll
total 36
drwx------ 2 www  root 4096 May  9 21:55 client_body_temp
drwxr-xr-x 5 root root 4096 May 23 20:52 conf
drwx------ 2 www  root 4096 May  9 21:55 fastcgi_temp
drwxr-xr-x 2 root root 4096 May  9 21:55 html
drwxr-xr-x 2 root root 4096 May  9 21:55 logs
drwx------ 2 www  root 4096 May  9 21:55 proxy_temp
drwxr-xr-x 2 root root 4096 May  9 21:55 sbin
drwx------ 2 www  root 4096 May  9 21:55 scgi_temp
drwx------ 2 www  root 4096 May  9 21:55 uwsgi_temp
[root@crifan tengine]# cd conf/
[root@crifan conf]# ll
total 80
-rw-r--r-- 1 root root 1034 May  9 21:55 fastcgi.conf
-rw-r--r-- 1 root root 1034 May  9 21:55 fastcgi.conf.default
-rw-r--r-- 1 root root  964 May  9 21:55 fastcgi_params
-rw-r--r-- 1 root root  964 May  9 21:55 fastcgi_params.default
-rw-r--r-- 1 root root 2837 May  9 21:55 koi-utf
-rw-r--r-- 1 root root 2223 May  9 21:55 koi-win
-rw-r--r-- 1 root root 4053 May  9 21:55 mime.types
-rw-r--r-- 1 root root 4053 May  9 21:55 mime.types.default
-rw-r--r-- 1 root root 2876 May  9 21:55 nginx.conf
-rw-r--r-- 1 root root 3060 May  9 21:55 nginx.conf_bk
-rw-r--r-- 1 root root 3060 May  9 21:55 nginx.conf.default
-rw-r--r-- 1 root root  484 May  9 21:55 proxy.conf
drwxr-xr-x 2 root root 4096 May 23 20:52 rewrite
-rw-r--r-- 1 root root  596 May  9 21:55 scgi_params
-rw-r--r-- 1 root root  596 May  9 21:55 scgi_params.default
drwxr-xr-x 2 root root 4096 May 23 20:52 ssl
-rw-r--r-- 1 root root  623 May  9 21:55 uwsgi_params
-rw-r--r-- 1 root root  623 May  9 21:55 uwsgi_params.default
drwxr-xr-x 2 root root 4096 May 23 20:51 vhost
-rw-r--r-- 1 root root 3610 May  9 21:55 win-utf
[root@crifan conf]# cd vhost/
[root@crifan vhost]# ll
total 4
-rw-r--r-- 1 root root 1390 May 23 20:52 www.crifan.org.conf

去看看现有配置

再去想办法写个book.crifan.org的配置

很明显:

server_name www.crifan.org book.crifan.org;
root /data/wwwroot/www.crifan.org;

只是多了sever_name是book.crifan.org

通过比较:

之前的TencentHK

和现有Vultr的

nginx的配置:

可以看出

tengine和nginx名字不同外,以及之前强制跳转ssl外,也就是多了个:

server_name book.crifan.org;

所以,可以直接复制一份过去

至于改动哪些,可以参考对比之前TencentHK的配置:

发现还是多了个ssl证书

  ssl_certificate /usr/local/nginx/conf/ssl/book.crifan.org.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/book.crifan.org.key;

所以没法直接修改配置文件还需要证书才行

所以还是去借用vhost去添加吧

后来注意到:

所以再去给Vultr加上

server_name crifan.org;

即:

server_name www.crifan.org crifan.org;
...
root /data/wwwroot/www.crifan.org;

再去reload

[root@crifan vhost]# nginx -t
nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful
[root@crifan vhost]# nginx reload
nginx: invalid option: "reload"
[root@crifan vhost]# sudo service nginx reload
Redirecting to /bin/systemctl reload nginx.service
[root@crifan vhost]# sudo service nginx status
Redirecting to /bin/systemctl status nginx.service
[0m nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-23 21:33:43 CST; 50min ago
     Docs: http://nginx.org/en/docs/
  Process: 10946 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
  Process: 12073 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 10957 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
  Process: 10951 ExecStart=/usr/local/tengine/sbin/nginx -c /usr/local/tengine/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 10949 ExecStartPre=/usr/local/tengine/sbin/nginx -t -c /usr/local/tengine/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 10954 (nginx)
   CGroup: /system.slice/nginx.service
           10954 nginx: master process /usr/local/tengine/sbin/nginx -c /usr/local/tengine/conf/nginx.conf
           10993 nginx: worker process is shutting down
           12079 nginx: worker process
           12081 nginx: worker process


May 23 21:33:43 crifan.org systemd[1]: Starting nginx - high performance web server...
May 23 21:33:43 crifan.org nginx[10949]: nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
May 23 21:33:43 crifan.org nginx[10949]: nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful
May 23 21:33:43 crifan.org systemd[1]: Started nginx - high performance web server.
May 23 22:24:31 crifan.org systemd[1]: Reloading nginx - high performance web server.
May 23 22:24:31 crifan.org systemd[1]: Reloaded nginx - high performance web server.

加之前,去修改已有的www.crifan.org的配置,去掉

server_name book.crifan.org;

变成:

server_name www.crifan.org;

再去:

[root@crifan vhost]# cd /root/oneinstack
[root@crifan oneinstack]# ll
total 3300
-rwxr-xr-x 1 root root    5861 May  4 18:32 addons.sh
-rwxr-xr-x 1 root root   24593 May  4 18:32 backup_setup.sh
-rwxr-xr-x 1 root root   14634 May  4 18:32 backup.sh
drwxr-xr-x 2 root root    4096 May  4 18:32 config
drwxr-xr-x 2 root root    4096 May  4 18:32 include
drwxr-xr-x 2 root root    4096 May  4 18:32 init.d
-rw-r--r-- 1 root root 3105478 May  9 22:15 install.log
-rwxr-xr-x 1 root root   50595 May  4 18:32 install.sh
-rw-r--r-- 1 root root   11358 May  4 18:32 LICENSE
-rw-r--r-- 1 root root    2510 May  9 21:52 options.conf
-rwxr-xr-x 1 root root    7760 May  4 18:32 pureftpd_vhost.sh
-rw-r--r-- 1 root root    5310 May  4 18:32 README.md
-rwxr-xr-x 1 root root    4938 May  4 18:32 reset_db_root_password.sh
drwxr-xr-x 3 root root    4096 May 23 20:48 src
drwxr-xr-x 2 root root    4096 May  4 18:32 tools
-rwxr-xr-x 1 root root   30291 May  4 18:32 uninstall.sh
-rwxr-xr-x 1 root root    5766 May  4 18:32 upgrade.sh
-rw-r--r-- 1 root root    1854 May  4 18:32 versions.txt
-rwxr-xr-x 1 root root   52035 May  4 18:32 vhost.sh
[root@crifan oneinstack]# pwd
/root/oneinstack
[root@crifan oneinstack]# ./vhost.sh 

[root@crifan oneinstack]# ./vhost.sh 


#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################


What Are You Doing?
        1. Use HTTP Only
        2. Use your own SSL Certificate and Key
        3. Use Let's Encrypt to Create SSL Certificate and Key
        q. Exit
Please input the correct option: 3


Please input domain(example: www.example.com): book.crifan.org
domain=book.crifan.org


Please input the directory for the domain:book.crifan.org :
(Default directory: /data/wwwroot/book.crifan.org): 
Virtual Host Directory=/data/wwwroot/book.crifan.org


Create Virtul Host directory......
set permissions of Virtual Host directory......


Do you want to add more domain name? [y/n]: n


Do you want to redirect all HTTP requests to HTTPS? [y/n]: n
[Thu May 23 21:33:39 CST 2019] Creating domain key
[Thu May 23 21:33:39 CST 2019] The domain key is here: /root/.acme.sh/book.crifan.org/book.crifan.org.key
[Thu May 23 21:33:39 CST 2019] Single domain='book.crifan.org'
[Thu May 23 21:33:39 CST 2019] Getting domain auth token for each domain
[Thu May 23 21:33:40 CST 2019] Getting webroot for domain='book.crifan.org'
[Thu May 23 21:33:40 CST 2019] book.crifan.org is already verified, skip http-01.
[Thu May 23 21:33:40 CST 2019] Verify finished, start to sign.
[Thu May 23 21:33:40 CST 2019] Lets finalize the order, Le_OrderFinalize: https://acme-v02.api.letsencrypt.org/acme/finalize/57656599/467142120
[Thu May 23 21:33:42 CST 2019] Download cert, Le_LinkCert: https://acme-v02.api.letsencrypt.org/acme/cert/03ca76552b9c2a7a8c6eeb3453f39d7197eb
[Thu May 23 21:33:42 CST 2019] Cert success.
-----BEGIN CERTIFICATE-----
MIIFWD........Ksom
dP0JfB6xxx9VizDNDsuTWSslFgagvg==
-----END CERTIFICATE-----
[Thu May 23 21:33:42 CST 2019] Your cert is in  /root/.acme.sh/book.crifan.org/book.crifan.org.cer 
[Thu May 23 21:33:42 CST 2019] Your cert key is in  /root/.acme.sh/book.crifan.org/book.crifan.org.key 
[Thu May 23 21:33:42 CST 2019] The intermediate CA cert is in  /root/.acme.sh/book.crifan.org/ca.cer 
[Thu May 23 21:33:42 CST 2019] And the full chain certs is there:  /root/.acme.sh/book.crifan.org/fullchain.cer 


Do you want to add hotlink protection? [y/n]: n


Allow Rewrite rule? [y/n]: n


Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/book.crifan.org_nginx.log


nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful
Reload Nginx......


#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  book.crifan.org
Virtualhost conf:             /usr/local/tengine/conf/vhost/book.crifan.org.conf
Directory of:                 /data/wwwroot/book.crifan.org
Let's Encrypt SSL Certificate:/usr/local/tengine/conf/ssl/book.crifan.org.crt
SSL Private Key:              /usr/local/tengine/conf/ssl/book.crifan.org.key

测试nginx配置:

[root@crifan vhost]# nginx -t
nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful

然后再去试试访问

book.crifan.org

问题依旧。

再去:

[root@crifan vhost]# cd /data/wwwroot/
[root@crifan wwwroot]# ll
total 12
drwxr-xr-x 2 www www 4096 May 23 21:33 book.crifan.org
drwxr-xr-x 3 www www 4096 May 23 21:02 default
drwxr-xr-x 2 www www 4096 May 23 21:02 www.crifan.org
[root@crifan wwwroot]# cd book.crifan.org/
[root@crifan book.crifan.org]# ll
total 0
[root@crifan book.crifan.org]# cp ../default/index.html .
[root@crifan book.crifan.org]# ll
total 20
-rw-r--r-- 1 root root 17832 May 23 21:49 index.html

访问可以了:

转载请注明:在路上 » 【已解决】Vultr中更新和配置crifan.org的虚拟主机和域名

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.189 seconds, using 23.35MB memory