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

【已解决】Linode的CentOS的LNMP中添加二级域名book.crifan.com

CentOS crifan 2904浏览 0评论

折腾:

【记录】给Gitbook添加更多配置和功能

后,需要把编译好的gitbook上传到自己的crifan.com上。

最好的放置位置是弄个二级域名

book.crifan.com

gitbook.crifan.com

把book相关的内容都放进去

而自己之前的网站是lnmp搭建的。

所以去:

lnmp 二级域名

【LNMP】配置二级域名

基于 LNMP 搭建个人网站的填坑之旅 – 简书

Lnmp下 linux下添加二级域名 – 李宗洋博客

所以先去:

【记录】腾讯云的域名的实名认证并添加二级域名

lnmp 添加二级域名

新添加主机绑定二级域名没有生成目录 – LNMP一键安装包 – VPS侦探论坛 – 美国VPS|VPS测试、点评|VPS主机推荐|VPS主机架设优化|美国服务器|LNMP一键安装包|Linux|VPS优惠信息

添加二级域名的时候一直指向default文件夹 – LNMP一键安装包 – VPS侦探论坛 – 美国VPS|VPS测试、点评|VPS主机推荐|VPS主机架设优化|美国服务器|LNMP一键安装包|Linux|VPS优惠信息

基于 LNMP 搭建个人网站的填坑之旅 – 简书

去用lnmp去添加二级域名

参考:

LNMP添加、删除虚拟主机及伪静态使用教程 – LNMP一键安装包

添加之前,先去自己搞清楚当前的路径设置

去centos中用命令行创建二级域名对应目录

<code>[root@crifan lnmp]# pwd
/home/wwwroot/crifan/lnmp
[root@crifan wwwroot]# ll
total 8
drwxr-xr-x  3 www www 4096 Sep 10 12:16 crifan
drwxr-xr-x 13 www www 4096 Dec  4 22:48 www.crifan.com
[root@crifan wwwroot]# mkdir book.crifan.com
</code>

后发现创建者是root

为了防止权限问题,所以还是删除掉,用lnmp的vhost自己创建吧。

算了,不用伪静态了 -》 此处后续都支持放html,css,js的静态页面。

<code>[root@crifan wwwroot]# lnmp vhost add
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): book.crifan.com
 Your domain: book.crifan.com
Enter more domain name(example: lnmp.org *.lnmp.org): 
Please enter the directory for the domain: book.crifan.com
Default directory: /home/wwwroot/book.crifan.com: /home/wwwroot/book.crifan.com
Virtual Host Directory: /home/wwwroot/book.crifan.com
Allow Rewrite rule? (y/n) n
You choose rewrite: none
Allow access log? (y/n) n
Disable access log.
Create database and MySQL user with same name (y/n) n
Add SSL Certificate (y/n) y
1: Use your own SSL Certificate and Key
2: Use Let's Encrypt to create SSL Certificate and Key
Enter 1 or 2: 2
Please enter your email address: [email protected]
It will be processed automatically.

Press any key to start create virtul host...

Create Virtul Host directory......
set permissions of Virtual Host directory......
You select the exist rewrite rule:/usr/local/nginx/conf/none.conf
Test Nginx configure file......
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......
Gracefully shutting down php-fpm . done
Starting php-fpm  done
You select the exist rewrite rule:/usr/local/nginx/conf/none.conf
Test Nginx configure file......
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......
/bin/certbot [found]
Starting create SSL Certificate use Let's Encrypt...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for book.crifan.com
Using the webroot path /home/wwwroot/book.crifan.com for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/book.crifan.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/book.crifan.com/privkey.pem
   Your cert will expire on 2018-03-06. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Let's encrypt crontab renew rule is exist.
Let's Encrypt SSL Certificate create successfully.
Test Nginx configure file......
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......
================================================
Virtualhost infomation:
Your domain: book.crifan.com
Home Directory: /home/wwwroot/book.crifan.com
Rewrite: none
Enable log: no
Create database: no
Create ftp account: no
Enable SSL: yes
  =&gt;Let's Encrypt
================================================
</code>

再去看看:

<code>[root@crifan wwwroot]# lnmp vhost list
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Nginx Virtualhost list:
book.crifan.com
www.crifan.com
[root@crifan wwwroot]# 
</code>

里面有:

然后去弄个html看看是否正常加载:

index.html

<code>&lt;!DOCTYPE html&gt;
&lt;html lang="zh-cn"&gt;
&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;测试book二级域名&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;h1&gt;book.crifan.com域名成功加载&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;
</code>

去访问:

http://book.crifan.com

看看结果:

是可以正常加载的。

转载请注明:在路上 » 【已解决】Linode的CentOS的LNMP中添加二级域名book.crifan.com

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.187 seconds, using 22.11MB memory