没有不值得去解决的问题,也没有不值得去学习的技术!

How to Switch a Website From One Domain to Another

Open: https://learn-php-app-0605-prod.wangqiang.store/robots.txt . Confirm that the domain has been successfully switched

1. The current domain is: https://learn-php-app-0605-prod.shuijingwanwq.com . I plan to switch it to: https://learn-php-app-0605-prod.wangqiang.store . See Figure 1.

The current domain is: https://learn-php-app-0605-prod.shuijingwanwq.com . Plan to switch it to: https://learn-php-app-0605-prod.wangqiang.store
Figure 1

2. Add DNS resolution for learn-php-app-0605-prod.wangqiang.store. See Figure 2.

Add DNS resolution for learn-php-app-0605-prod.wangqiang.store
Figure 2

3. Delete the previous virtual host, learn-php-app-0605-prod.shuijingwanwq.com, using OneinStack. The directory should not be deleted.

Plaintext

[root@iZ23wv7v5ggZ ~]# ~/oneinstack/vhost.sh --del

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

Virtualhost list:
learn-php-app-0605-prod.shuijingwanwq.com www.shuijingwanwq.com

Please input a domain you want to delete: learn-php-app-0605-prod.shuijingwanwq.com

Do you want to delete Virtul Host directory? [y/n]: n

Domain: learn-php-app-0605-prod.shuijingwanwq.com has been deleted.


4. Add a new virtual host, learn-php-app-0605-prod.wangqiang.store, using OneinStack. Keep using the directory from the previous virtual host: /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com

Plaintext

[root@iZ23wv7v5ggZ ~]# ~/oneinstack/vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       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): learn-php-app-0605-prod.wangqiang.store
domain=learn-php-app-0605-prod.wangqiang.store

Please input the directory for the domain:learn-php-app-0605-prod.wangqiang.store :
(Default directory: /data/wwwroot/learn-php-app-0605-prod.wangqiang.store): /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.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]: y

Please select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048):
[Thu Jun 15 05:07:11 PM CST 2023] Using CA: https://acme.zerossl.com/v2/DV90
[Thu Jun 15 05:07:11 PM CST 2023] Creating domain key
[Thu Jun 15 05:07:11 PM CST 2023] The domain key is here: /root/.acme.sh/learn-php-app-0605-prod.wangqiang.store/learn-php-app-0605-prod.wangqiang.store.key
[Thu Jun 15 05:07:11 PM CST 2023] Single domain='learn-php-app-0605-prod.wangqiang.store'
[Thu Jun 15 05:07:11 PM CST 2023] Getting domain auth token for each domain
[Thu Jun 15 05:07:17 PM CST 2023] Getting webroot for domain='learn-php-app-0605-prod.wangqiang.store'
[Thu Jun 15 05:07:17 PM CST 2023] Verifying: learn-php-app-0605-prod.wangqiang.store
[Thu Jun 15 05:07:19 PM CST 2023] Processing, The CA is processing your order, please just wait. (1/30)
[Thu Jun 15 05:07:23 PM CST 2023] Success
[Thu Jun 15 05:07:23 PM CST 2023] Verify finished, start to sign.
[Thu Jun 15 05:07:23 PM CST 2023] Lets finalize the order.
[Thu Jun 15 05:07:23 PM CST 2023] Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/HvpQ_zj63S9ys7pI8RtvAw/finalize'
[Thu Jun 15 05:07:25 PM CST 2023] Order status is processing, lets sleep and retry.
[Thu Jun 15 05:07:25 PM CST 2023] Retry after: 15
[Thu Jun 15 05:07:41 PM CST 2023] Polling order status: https://acme.zerossl.com/v2/DV90/order/HvpQ_zj63S9ys7pI8RtvAw
[Thu Jun 15 05:07:42 PM CST 2023] Downloading cert.
[Thu Jun 15 05:07:42 PM CST 2023] Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/34xe1tRFLIZFO436TLz-7Q'
[Thu Jun 15 05:07:44 PM CST 2023] Cert success.
-----BEGIN CERTIFICATE-----
**********************************
-----END CERTIFICATE-----
[Thu Jun 15 05:07:44 PM CST 2023] Your cert is in: /root/.acme.sh/learn-php-app-0605-prod.wangqiang.store/learn-php-app-0605-prod.wangqiang.store.cer
[Thu Jun 15 05:07:44 PM CST 2023] Your cert key is in: /root/.acme.sh/learn-php-app-0605-prod.wangqiang.store/learn-php-app-0605-prod.wangqiang.store.key
[Thu Jun 15 05:07:44 PM CST 2023] The intermediate CA cert is in: /root/.acme.sh/learn-php-app-0605-prod.wangqiang.store/ca.cer
[Thu Jun 15 05:07:44 PM CST 2023] And the full chain certs is there: /root/.acme.sh/learn-php-app-0605-prod.wangqiang.store/fullchain.cer

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

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,whmcs rewrite was exist.
(Default rewrite: other): laravel
You choose rewrite=laravel

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/learn-php-app-0605-prod.wangqiang.store_nginx.log

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

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  learn-php-app-0605-prod.wangqiang.store
Virtualhost conf:             /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.wangqiang.store.conf
Directory of:                 /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/laravel.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/learn-php-app-0605-prod.wangqiang.store.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.wangqiang.store.key


5. After editing the Nginx configuration file as needed, restart the Nginx service.

Plaintext

[root@iZ23wv7v5ggZ ~]# vi /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.wangqiang.store.conf
[root@iZ23wv7v5ggZ ~]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service


6. Open: https://learn-php-app-0605-prod.wangqiang.store/robots.txt . Confirm that the domain has been successfully switched. See Figure 3.

Open: https://learn-php-app-0605-prod.wangqiang.store/robots.txt . Confirm that the domain has been successfully switched
Figure 3

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系