折腾:
【已解决】恢复crifan.com的WordPress到Vultr的CentOS7的OneinStack中
期间,借助于Vultr中CentOS7中OneinStack的vhost去添加域名
以及同时去更新DNS域名配置。
此处有两个域名
通过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.com PING www.crifan.com (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.com搬家腾讯云后解决二级域名book.crifan.com的页面访问 – 在路上
和官网文档:
还是添加
[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.com domain=www.crifan.com Please input the directory for the domain:www.crifan.com : (Default directory: /data/wwwroot/www.crifan.com): Virtual Host Directory=/data/wwwroot/www.crifan.com Create Virtul Host directory...... set permissions of Virtual Host directory...... Do you want to add more domain name? [y/n]: book.crifan.com 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.com domain list=book.crifan.com Do you want to redirect from book.crifan.com to www.crifan.com? [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.com/www.crifan.com.key [Thu May 23 20:51:51 CST 2019] Multi domain='DNS:www.crifan.com,DNS:book.crifan.com' [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.com' [Thu May 23 20:51:52 CST 2019] Getting webroot for domain='book.crifan.com' [Thu May 23 20:51:52 CST 2019] Verifying: www.crifan.com [Thu May 23 20:51:55 CST 2019] Success [Thu May 23 20:51:55 CST 2019] Verifying: book.crifan.com [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.com/www.crifan.com.cer [Thu May 23 20:52:00 CST 2019] Your cert key is in /root/.acme.sh/www.crifan.com/www.crifan.com.key [Thu May 23 20:52:00 CST 2019] The intermediate CA cert is in /root/.acme.sh/www.crifan.com/ca.cer [Thu May 23 20:52:00 CST 2019] And the full chain certs is there: /root/.acme.sh/www.crifan.com/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.com_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.com Virtualhost conf: /usr/local/tengine/conf/vhost/www.crifan.com.conf Directory of: /data/wwwroot/www.crifan.com Rewrite rule: /usr/local/tengine/conf/rewrite/wordpress.conf Let's Encrypt SSL Certificate:/usr/local/tengine/conf/ssl/www.crifan.com.crt SSL Private Key: /usr/local/tengine/conf/ssl/www.crifan.com.key
然后去访问
试试
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.com/ Server: crifan.com Date: 2019/05/23 20:54:35 Powered by Tengine tengine
去放一个index.html过去
果然可以了:
说明www.crifan.com的域名和tengine正常了
那再去看看
先手动创建文件夹:
[root@crifan wwwroot]# mkdir book.crifan.com [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.com 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.com [root@crifan wwwroot]# chown www:www book.crifan.com/ [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.com 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.com
然后此处发现
【已解决】WordPress网站crifan.com搬家腾讯云后解决二级域名book.crifan.com的页面访问 – 在路上
之前是
单独运行vhost去添加book.crifan.com
而上面是一起创建的
感觉不太对
后者需要额外设置才可以的
至少要去加上nginx配置
去想办法把此处之前nginx的配置:
加到现有的,tengine的配置中去
去看看配置:
/usr/local/tengine/conf/vhost/www.crifan.com.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.com.conf
去看看现有配置
再去想办法写个book.crifan.com的配置
很明显:
server_name www.crifan.com book.crifan.com; root /data/wwwroot/www.crifan.com;
只是多了sever_name是book.crifan.com
通过比较:
之前的TencentHK
和现有Vultr的
nginx的配置:
可以看出
tengine和nginx名字不同外,以及之前强制跳转ssl外,也就是多了个:
server_name book.crifan.com;
所以,可以直接复制一份过去
至于改动哪些,可以参考对比之前TencentHK的配置:
发现还是多了个ssl证书
ssl_certificate /usr/local/nginx/conf/ssl/book.crifan.com.crt; ssl_certificate_key /usr/local/nginx/conf/ssl/book.crifan.com.key;
所以没法直接修改配置文件还需要证书才行
所以还是去借用vhost去添加吧
后来注意到:
所以再去给Vultr加上
server_name crifan.com;
即:
server_name www.crifan.com crifan.com; ... root /data/wwwroot/www.crifan.com;
再去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.com systemd[1]: Starting nginx - high performance web server... May 23 21:33:43 crifan.com nginx[10949]: nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok May 23 21:33:43 crifan.com nginx[10949]: nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful May 23 21:33:43 crifan.com systemd[1]: Started nginx - high performance web server. May 23 22:24:31 crifan.com systemd[1]: Reloading nginx - high performance web server. May 23 22:24:31 crifan.com systemd[1]: Reloaded nginx - high performance web server.
加之前,去修改已有的www.crifan.com的配置,去掉
server_name book.crifan.com;
变成:
server_name www.crifan.com;
再去:
[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.com domain=book.crifan.com Please input the directory for the domain:book.crifan.com : (Default directory: /data/wwwroot/book.crifan.com): Virtual Host Directory=/data/wwwroot/book.crifan.com 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.com/book.crifan.com.key [Thu May 23 21:33:39 CST 2019] Single domain='book.crifan.com' [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.com' [Thu May 23 21:33:40 CST 2019] book.crifan.com 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.com/book.crifan.com.cer [Thu May 23 21:33:42 CST 2019] Your cert key is in /root/.acme.sh/book.crifan.com/book.crifan.com.key [Thu May 23 21:33:42 CST 2019] The intermediate CA cert is in /root/.acme.sh/book.crifan.com/ca.cer [Thu May 23 21:33:42 CST 2019] And the full chain certs is there: /root/.acme.sh/book.crifan.com/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.com_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.com Virtualhost conf: /usr/local/tengine/conf/vhost/book.crifan.com.conf Directory of: /data/wwwroot/book.crifan.com Let's Encrypt SSL Certificate:/usr/local/tengine/conf/ssl/book.crifan.com.crt SSL Private Key: /usr/local/tengine/conf/ssl/book.crifan.com.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
然后再去试试访问
问题依旧。
再去:
[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.com 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.com [root@crifan wwwroot]# cd book.crifan.com/ [root@crifan book.crifan.com]# ll total 0 [root@crifan book.crifan.com]# cp ../default/index.html . [root@crifan book.crifan.com]# ll total 20 -rw-r--r-- 1 root root 17832 May 23 21:49 index.html
访问可以了: