最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】用OneinStack去添加主机域名

添加 crifan 781浏览 0评论
折腾:
【记录】手动交互模式去安装OneinStack以搭建Web服务器
之后,需要继续添加域名映射。
尤其是需要添加https。
./vhost.sh

[root@izj6cefkuu3496m71s907xz ~]# cd oneinstack
[root@izj6cefkuu3496m71s907xz oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit 
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### 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 ): xxx.com domain= xxx.com Please input the directory for the domain: xxx.com : (Default directory: /data/wwwroot/ xxx.com ): Virtual Host Directory=/data/wwwroot/ xxx.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 [Sun Aug 26 22:18:41 CST 2018] Registering account [Sun Aug 26 22:18:42 CST 2018] Registered [Sun Aug 26 22:18:42 CST 2018] ACCOUNT_THUMBPRINT='u3iY29DK1h9HVwIilNJaSHJtyJeqiDa49IGIjpAeApc' [Sun Aug 26 22:18:42 CST 2018] Creating domain key [Sun Aug 26 22:18:42 CST 2018] The domain key is here: /root/.acme.sh/ xxx.com/xxx.com.key [Sun Aug 26 22:18:42 CST 2018] Single domain=' xxx.com ' [Sun Aug 26 22:18:42 CST 2018] Getting domain auth token for each domain [Sun Aug 26 22:18:42 CST 2018] Getting webroot for domain=' xxx.com ' [Sun Aug 26 22:18:42 CST 2018] Getting new-authz for domain=' xxx.com ' [Sun Aug 26 22:18:43 CST 2018] The new-authz request is ok. [Sun Aug 26 22:18:43 CST 2018] Verifying: xxx.com [Sun Aug 26 22:18:46 CST 2018] Success [Sun Aug 26 22:18:46 CST 2018] Verify finished, start to sign. [Sun Aug 26 22:18:48 CST 2018] Cert success. -----BEGIN CERTIFICATE----- MIIGDzCCBPegAwIBAgISAzCmuvePE8ZtQz5w+rgQpyheMA0GCSqGSIb3DQEBCwUA MEo........ Q== -----END CERTIFICATE----- [Sun Aug 26 22:18:48 CST 2018] Your cert is in  /root/.acme.sh/ xxx.com/xxx.com.cer [Sun Aug 26 22:18:48 CST 2018] Your cert key is in  /root/.acme.sh/ xxx.com/xxx.com.key [Sun Aug 26 22:18:48 CST 2018] The intermediate CA cert is in  /root/.acme.sh/ xxx.com/ca.cer [Sun Aug 26 22:18:48 CST 2018] And the full chain certs is there:  /root/.acme.sh/ xxx.com/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,laravel,thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud 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/ xxx.com_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/RadHat 6+ Debian 7+ and Ubuntu 12+      # #       For more information please visit
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### Your domain:                   xxx.com Virtualhost conf:             /usr/local/nginx/conf/vhost/ xxx.com.conf Directory of:                 /data/wwwroot/ xxx.com Rewrite rule:                 /usr/local/nginx/conf/rewrite/wordpress.conf Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/ xxx.com.crt SSL Private Key:              /usr/local/nginx/conf/ssl/ xxx.com.key [root@izj6cefkuu3496m71s907xz oneinstack]#
不知道是否需要,还是去重启一下Nginx:
[root@izj6cefkuu3496m71s907xz oneinstack]# 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 Sun 2018-08-26 22:18:49 CST; 2min 53s ago
     Docs: 
http://nginx.org/en/docs/
  Process: 3528 ExecStop=/usr/local/nginx/sbin/nginx -s stop (code=exited, status=0/SUCCESS)
  Process: 3537 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
  Process: 3533 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 3531 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 3535 (nginx)
   CGroup: /system.slice/nginx.service
           3535 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           3566 nginx: worker process
           3569 nginx: worker process

Aug 26 22:18:49 izj6cefkuu3496m71s907xz systemd[1]: Starting nginx - high performance web server...
Aug 26 22:18:49 izj6cefkuu3496m71s907xz nginx[3531]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Aug 26 22:18:49 izj6cefkuu3496m71s907xz nginx[3531]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Aug 26 22:18:49 izj6cefkuu3496m71s907xz systemd[1]: Started nginx - high performance web server.
[root@izj6cefkuu3496m71s907xz oneinstack]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@izj6cefkuu3496m71s907xz oneinstack]# 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 Sun 2018-08-26 22:21:48 CST; 6s ago
     Docs: 
http://nginx.org/en/docs/
  Process: 3621 ExecStop=/usr/local/nginx/sbin/nginx -s stop (code=exited, status=0/SUCCESS)
  Process: 3629 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
  Process: 3625 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 3623 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 3627 (nginx)
   CGroup: /system.slice/nginx.service
           3627 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           3628 nginx: worker process
           3630 nginx: worker process

Aug 26 22:21:48 izj6cefkuu3496m71s907xz systemd[1]: Starting nginx - high performance web server...
Aug 26 22:21:48 izj6cefkuu3496m71s907xz nginx[3623]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Aug 26 22:21:48 izj6cefkuu3496m71s907xz nginx[3623]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Aug 26 22:21:48 izj6cefkuu3496m71s907xz systemd[1]: Started nginx - high performance web server.
[root@izj6cefkuu3496m71s907xz oneinstack]# 
然后试了试主页打开效果:
注:
之前用lnmp的vhost给自己的crifan加过https
所以现在:
https://crifan.com/
会自动跳转到:
https://www.crifan.com/
而现在此处https有问题啊
并且:
http://xxx.com/
也没能自动跳转到:
http://www.xxx.com/
算了,去删除之前的配置
然后在配置期间,去删除之前的域名,然后重新配置:
Do you want to add more domain name? [y/n]:
选y,去加上:
www.china-team.com
以及:
Do you want to redirect all HTTP requests to HTTPS? [y/n]: 
选y,强制跳转
不过:
难道ssl生效要过段时间?
另外从:
https://github.com/licess/lnmp
看到,和之前安装的类似,也有lnmp命令:
结果发现此处竟然没有:
[root@izj6cefkuu3496m71s907xz ~]# lnmp ssl
-bash: lnmp: command not found
[root@izj6cefkuu3496m71s907xz ~]# lnmp
-bash: lnmp: command not found
[root@izj6cefkuu3496m71s907xz ~]# cd oneinstack
[root@izj6cefkuu3496m71s907xz oneinstack]# lnmp ssl
-bash: lnmp: command not found
centos lnmp: command not found
解决CentOS 7.1上LNMP环境 404 File not found._服务器应用_Linux公社-Linux系统门户网站
算了,还是去删除,重新配置:
./vhost.sh del
[root@izj6cefkuu3496m71s907xz oneinstack]# pwd
/root/oneinstack
[root@izj6cefkuu3496m71s907xz oneinstack]# ./vhost.sh del

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit 
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### Virtualhost list: xxx.com Please input a domain you want to delete: xxx.com Do you want to delete Virtul Host directory? [y/n]: y Press Ctrl+c to cancel or Press any key to continue... Domain: xxx.com has been deleted. [root@izj6cefkuu3496m71s907xz oneinstack]# ./vhost.sh del ####################################################################### #       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      # #       For more information please visit
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### Virtualhost was not exist!
然后重新配置:
[root@izj6cefkuu3496m71s907xz oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit 
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### 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 ): xxx.com domain= xxx.com Please input the directory for the domain: xxx.com : (Default directory: /data/wwwroot/ xxx.com ): Virtual Host Directory=/data/wwwroot/ xxx.com Create Virtul Host directory...... set permissions of Virtual Host directory...... Do you want to add more domain name? [y/n]: y Type domainname or IP(example: example.com other.example.com ): www.xxx.com domain list= www.xxx.com Do you want to redirect from www.xxx.com to xxx.com? [y/n]: ^C
看到这个提示:
Do you want to redirect from www.xxx.com to xxx.com? [y/n]: ^C
就觉得不太多,感觉应该先设置:
www.xxx.com
再设置:
xxx.com
这样就会问:
是否从xxx.com跳转到www.xxx.com了,才对。
[root@izj6cefkuu3496m71s907xz oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit 
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### 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.xxx.com domain= www.xxx.com Please input the directory for the domain: www.xxx.com : (Default directory: /data/wwwroot/ www.xxx.com ): Virtual Host Directory=/data/wwwroot/ www.xxx.com Create Virtul Host directory...... set permissions of Virtual Host directory...... Do you want to add more domain name? [y/n]: y Type domainname or IP(example: example.com other.example.com ): xxx.com domain list= xxx.com Do you want to redirect from xxx.com to www.xxx.com? [y/n]: y Do you want to redirect all HTTP requests to HTTPS? [y/n]: y Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for www.xxx.com [Sun Aug 26 22:44:04 CST 2018] Creating domain key ...
感觉有点不对啊,
Let’s Encrypt Verify error! DNS problem: NXDOMAIN looking up A for www.xxx.com
那就先去看看阿里云的DNS配置
【已解决】OneinStack添加ssl出错:Let’s Encrypt Verify error! DNS problem: NXDOMAIN looking up A for
继续操作,看看后续是否有问题
[Sun Aug 26 22:44:11 CST 2018] Cert success.
-----BEGIN CERTIFICATE-----
MIIGJzCCBQ+gAwIBAgISA2CJ61MurnKIVWvF6I9WbUBJMA0GCSqGSIb3DQEBCwUA
MEo.........
WzgM2KN1dvT
ZdCLP4cyX/RGd87sIY9yNyimXs3elZvp1F/unR6xrYzdTu0GGqymPSNJmA==
-----END CERTIFICATE-----
[Sun Aug 26 22:44:11 CST 2018] Your cert is in  /root/.acme.sh/
www.xxx.com/www.xxx.com.cer
[Sun Aug 26 22:44:11 CST 2018] Your cert key is in  /root/.acme.sh/
www.xxx.com/www.xxx.com.key
[Sun Aug 26 22:44:12 CST 2018] The intermediate CA cert is in  /root/.acme.sh/
www.xxx.com/ca.cer
[Sun Aug 26 22:44:12 CST 2018] And the full chain certs is there:  /root/.acme.sh/
www.xxx.com/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,laravel,thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud 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.xxx.com_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/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit 
OneinStack - 一键PHP/JAVA安装工具
      # ####################################################################### Your domain:                   www.xxx.com Virtualhost conf:             /usr/local/nginx/conf/vhost/ www.xxx.com.conf Directory of:                 /data/wwwroot/ www.xxx.com Rewrite rule:                 /usr/local/nginx/conf/rewrite/wordpress.conf Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/ www.xxx.com.crt SSL Private Key:              /usr/local/nginx/conf/ssl/ www.xxx.com.key
重启Nginx试试
[root@izj6cefkuu3496m71s907xz oneinstack]# service nginx reload
Redirecting to /bin/systemctl reload nginx.service
[root@izj6cefkuu3496m71s907xz oneinstack]# 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 Sun 2018-08-26 22:44:12 CST; 9min ago
     Docs: 
http://nginx.org/en/docs/
  Process: 3749 ExecStop=/usr/local/nginx/sbin/nginx -s stop (code=exited, status=0/SUCCESS)
  Process: 3838 ExecReload=/usr/local/nginx/sbin/nginx -s reload (code=exited, status=0/SUCCESS)
  Process: 3757 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
  Process: 3754 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 3751 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 3755 (nginx)
   CGroup: /system.slice/nginx.service
           3755 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           3844 nginx: worker process
           3846 nginx: worker process

Aug 26 22:44:12 izj6cefkuu3496m71s907xz systemd[1]: Starting nginx - high performance web server...
Aug 26 22:44:12 izj6cefkuu3496m71s907xz nginx[3751]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Aug 26 22:44:12 izj6cefkuu3496m71s907xz nginx[3751]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Aug 26 22:44:12 izj6cefkuu3496m71s907xz systemd[1]: Started nginx - high performance web server.
Aug 26 22:54:03 izj6cefkuu3496m71s907xz systemd[1]: Reloaded nginx - high performance web server
然后打开:
http://www.xxx.com/
就强制跳转到了:
https://www.xxx.com/
参考别的:
去加上CNAME
好像是有效的,不用修改。
参考:
http://www.laozuo.org/10935.html
自己服务器中ping 带www和不带www,都是OK的:
[root@izj6cefkuu3496m71s907xz oneinstack]# ping 
xxx.com
PING 
xxx.com
 (47.52.190.220) 56(84) bytes of data.
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=1 ttl=63 time=1.19 ms
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=2 ttl=63 time=1.20 ms
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=3 ttl=63 time=1.21 ms
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=4 ttl=63 time=1.19 ms
^C
--- 
xxx.com
 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.193/1.203/1.217/0.043 ms
[root@izj6cefkuu3496m71s907xz oneinstack]# ^C
[root@izj6cefkuu3496m71s907xz oneinstack]# ping 
www.xxx.com
PING 
www.xxx.com
 (47.52.190.220) 56(84) bytes of data.
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=1 ttl=63 time=1.17 ms
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=2 ttl=63 time=1.21 ms
64 bytes from 47.52.190.220 (47.52.190.220): icmp_seq=3 ttl=63 time=1.20 ms
^C
--- 
www.xxx.com
 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.172/1.195/1.212/0.016 ms
不过又出现其他问题:
【自动解决】OneinStack安装Let’s Encrypt的ssl证书后https的地址经常打不开

转载请注明:在路上 » 【已解决】用OneinStack去添加主机域名

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.176 seconds, using 22.18MB memory