• 在CentOS7下安装jekyll


    [root@k8smaster nodejs]# yum install gem ruby ruby-devel -y

    [root@k8smaster nodejs]# gem sources -l #查看gem源
    [root@k8smaster nodejs]# gem sources -a http://gems.rubyforge.org #添加gem源
    [root@k8smaster nodejs]# gem sources --remove https://gems.ruby-china.org/ #删除gem源
    [root@k8smaster nodejs]# gem sources -u #更新缓存

    [root@k8smaster nodejs]# gem install jekyll

    [root@k8smaster nodejs]# gem install bundler

    [root@k8smaster nodejs]# wget https://nodejs.org/dist/v4.4.2/node-v4.4.2-linux-x64.tar.xz

    解压xz -d node-v4.4.2-linux-x64.tar.xz
    解压tar -xvf node-v4.4.2-linux-x64.tar

    [root@k8smaster nodejs]# cp -r node-v4.4.2-linux-x64 /usr/local/

    添加环境变量

    [root@k8smaster nodejs]# vi /etc/profile

    在最后面添加
    PATH=$PATH:/usr/local/node-v4.4.2-linux-x64/bin
    export PATH
    使用以下命令使环境变量立即生效source /etc/profile

    [root@k8smaster nodejs]# jekyll new myblog #生成静态页面

    启动服务

    [root@k8smaster nodejs]# cd myblog/
    [root@k8smaster myblog]# jekyll server

    或者在启动jekyll服务的时候指定端口号

    [root@k8smaster myblog]# jekyll serve --port 3000

    访问站点
    http://127.0.0.1:4000/

    [root@k8smaster nodejs]# netstat -anp |grep 4000
    tcp 0 0 127.0.0.1:4000 0.0.0.0:* LISTEN 17183/ruby
    [root@k8smaster nodejs]#
    [root@k8smaster nodejs]# netstat -ano
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address Foreign Address State Timer
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0)
    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN off (0.00/0/0)
    tcp 0 0 127.0.0.1:4000 0.0.0.0:* LISTEN off (0.00/0/0)
    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN off (0.00/0/0)
    tcp 0 232 172.16.160.100:22 172.16.160.103:49767 ESTABLISHED on (0.25/0/0)
    tcp6 0 0 :::22 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::8888 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 ::1:25 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::9999 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::111 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::8080 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::50000 :::* LISTEN off (0.00/0/0)
    tcp6 0 0 :::80 :::* LISTEN off (0.00/0/0)
    udp 0 0 0.0.0.0:68 0.0.0.0:* off (0.00/0/0)
    udp 0 0 127.0.0.1:323 0.0.0.0:* off (0.00/0/0)
    udp 0 0 0.0.0.0:48413 0.0.0.0:* off (0.00/0/0)
    udp 0 0 172.16.160.100:50776 61.216.153.104:123 ESTABLISHED off (0.00/0/0)
    udp6 0 0 ::1:323 :::* off (0.00/0/0)
    udp6 0 0 :::3061 :::* off (0.00/0/0)
    raw6 0 0 :::58 :::* 7 off (0.00/0/0)

    修改端口

    [root@k8smaster myblog]# vi + _config.yml

    在最后一行后面添加以下内容
    port: 1234


    访问

    [root@k8smaster ~]# curl http://127.0.0.1:1234/
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Your awesome title</title>


    [root@k8smaster myblog]# ll
    总用量 20
    -rw-r--r--. 1 root root 525 3月 22 10:32 about.md
    -rw-r--r--. 1 root root 1415 3月 22 10:57 _config.yml
    -rw-r--r--. 1 root root 953 3月 22 10:32 Gemfile
    -rw-r--r--. 1 root root 1180 3月 22 10:34 Gemfile.lock
    -rw-r--r--. 1 root root 213 3月 22 10:32 index.md
    drwxr-xr-x. 2 root root 50 3月 22 10:32 _posts
    drwxr-xr-x. 5 root root 76 3月 22 10:35 _site
    [root@k8smaster myblog]# cd _site/
    [root@k8smaster _site]# ll
    总用量 12
    drwxr-xr-x. 2 root root 23 3月 22 10:35 about
    drwxr-xr-x. 2 root root 21 3月 22 10:35 assets
    -rw-r--r--. 1 root root 3836 3月 22 10:58 feed.xml
    -rw-r--r--. 1 root root 5301 3月 22 10:58 index.html
    drwxr-xr-x. 3 root root 19 3月 22 10:35 jekyll
    [root@k8smaster _site]# pwd
    /home/jekyll/myblog/_site
    [root@k8smaster _site]#


    由于jekyll将地址绑定到了127.0.0.1,导致局域网的其它机器并不能访问它的服务。但实际上只要改变运行jekyll的参数就可以了。

    jekyll serve -w --host=0.0.0.0

  • 相关阅读:
    [转载]spring使用PropertyPlaceholderConfigurer加载properties文件处理中文乱码
    [转载]使用@value注解注入properties配置信息
    [JAVA]使用HttpURLConnection下载文件
    [转载]在Java代码运行时获取当前和调用者的行号,方法名,类名,文件名
    [转载]linux下使用tar命令
    暂时解决java.lang.IllegalStateException: It is invalid to call isReady() when the response has not been put into non-blocking mode *
    oracle使用imp导入数据覆盖(overwirte)原有表数据
    线性基
    Matching Problem 暴力
    Alternative Accounts 贪心匹配
  • 原文地址:https://www.cnblogs.com/amoyzhu/p/6598850.html
Copyright © 2020-2023  润新知