Nodejs有很多版本,按照不同的操作系统、不同的处理器,下载安装对应版本。
一、去官网下载ARMv8版本的压缩包(Jetson Nano的处理器是ARM57,基于ARMv8的核)
英文网址:Download | Node.js
通过Linux系统命令【uname -a】 查看操作系统位数(备注:x86_64表示X86处理器64位系统, aarch64表示ARM处理器64位系统)
Linux ljx-desktop 4.9.253-tegra #1 SMP PREEMPT Mon Jul 26 12:13:06 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux
二、下载下来的文件【node-v16.14.0-linux-arm64.tar】传到Nano上,解压,然后通过建立软连接变为全局命令。
1、传到Nano上可以是任意路径,本例路径为 /home/ljx/node-js
2、解压(解压后的文件我这边将名字改了,这个地方自己随意,只要在建立软连接的时候写正确就可以)
#解压
tar -xvJf node-v16.14.0-linux-arm64.tar.xz
#移动到/usl/lcoal目录下
mv node-v16.14.0-linux-arm64 /usr/local/node-v6
#创建软链接
ln -s /usr/local/node-v6/node-v16.14.0-linux-arm64/bin/node /bin/node
ln -s /usr/local/node-v6/node-v16.14.0-linux-arm64/bin/npm /bin/npm
#添加环境变量
echo 'export PATH=/usr/local/node-v6/bin:$PATH' >> /etc/profilesource /etc/profile #让环境变量生效
如果哪天环境搞坏了重新解压删除软连接重新来一遍就好了
sudo rm /bin/node
sudo rm /bin/npm
确认一下nodejs下bin目录是否有node 和npm文件,如果有执行软连接,如果没有重新下载执行上边步骤。
3、最后一步检验nodejs是否已变为全局(也可以说“安装”成功)
在Linux命令行【node -v和 npm -v 】命令会显示nodejs版本,如显示版本则大功告成。
v16.14.0
8.3.1
二、安装并使用Hexo
Hexo的安装较为简单,使用如下命令安装
npm install -g hexo-cli
#这里有一点要注意的就是,npm的源是在国外的,访问可能会很慢,这里可以换成我们国内的源进行安装加快速度。操作如下:
npm config set registry https://registry.npm.taobao.org
初始化Hexo
上面的安装完成之后执行下面的命令进行对Hexo进行一个初始化
#这个文件名字可以自己指定,之后会在当前目录下生成对应文件夹
hexo init <文件名字>
cd 文件名字
npm install
可以看到安装好之后的一个目录结构:
init 出现问题的话去出错的github里面下载下来就行了
需要安装pug以及stylus的渲染器(以后可能会用到)
npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive
目录文件说明:
_config.yml:网站的配置信息,您可以在此配置大部分的参数。
package.json:应用程序的信息。EJS, Stylus 和 Markdown renderer 已默认安装,您可以自由移除。
scaffolds:模版文件夹。当您新建文章时Hexo 会根据 scaffold 来建立文件Hexo的模板是指在新建的文章文件中默认填充的内容。例如,如果您修改scaffold/post.md中的Front-matter内容,那么每次新建一篇文章时都会包含这个修改。
source:资源文件夹是存放用户资源的地方。除 _posts 文件夹之外,开头命名为 _ (下划线)的文件 / 文件夹和隐藏的文件将会被忽略。Markdown 和 HTML 文件会被解析并放到 public 文件夹,而其他文件会被拷贝过去。
themes:主题 文件夹。Hexo 会根据主题来生成静态页面。
查看hexo的版本以及对应的数据:
hexo
FATAL SyntaxError: Unexpected token i in JSON at position 0
at JSON.parse (<anonymous>)
at /usr/local/lib/node_modules/hexo-cli/lib/find_pkg.js:18:23
at tryCatcher (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:466:21)
ljx@ljx-desktop:~/node-js/hexo-starter-master$ npm install
npm ERR! code EJSONPARSE
npm ERR! path /home/ljx/node-js/hexo-starter-master/package.json
npm ERR! JSON.parse Unexpected token "i" (0x69) in JSON at position 0 while parsing near "i{\n \"name\": \"hexo-s..."
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ljx/.npm/_logs/2022-02-13T12_02_30_036Z-debug-0.log
ljx@ljx-desktop:~/node-js/hexo-starter-master$ sudo npm install
npm ERR! code EJSONPARSE
npm ERR! path /home/ljx/node-js/hexo-starter-master/package.json
npm ERR! JSON.parse Unexpected token "i" (0x69) in JSON at position 0 while parsing near "i{\n \"name\": \"hexo-s..."
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ljx/.npm/_logs/2022-02-13T12_02_47_466Z-debug-0.log
ljx@ljx-desktop:~/node-js/hexo-starter-master$ ls
blog _config.yml nginx package.json public source
_config.landscape.yml db.json node_modules package-lock.json scaffolds themes
ljx@ljx-desktop:~/node-js/hexo-starter-master$ vi package.json
ljx@ljx-desktop:~/node-js/hexo-starter-master$ npm install
突然出错了,把我这个新手整懵逼了,想着重新npm install发现了错误
hexo -v可以了
ljx@ljx-desktop:~/node-js/hexo-starter-master$ hexo -v
INFO Validating config
hexo: 6.0.0
hexo-cli: 4.3.0
os: linux 4.9.253-tegra Ubuntu 18.04.6 LTS (Bionic Beaver)
node: 16.14.0
v8: 9.4.146.24-node.20
uv: 1.43.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.18.1
modules: 93
nghttp2: 1.45.1
napi: 8
llhttp: 6.0.4
openssl: 1.1.1m+quic
cldr: 40.0
icu: 70.1
tz: 2021a3
unicode: 14.0
ngtcp2: 0.1.0-DEV
nghttp3: 0.1.0-DEV
还想试下别的错误,还真出来了
ljx@ljx-desktop:~/node-js/hexo-starter-master$ hexo -v
FATAL YAMLException: end of the stream or a document separator is expected (7:9)
4 |
5 | # Site
6 | title:俊俊的笔记
7 | subtitle: 记录学习
-------------^
8 | description: ’希望大佬能够出现在我这里给指点一二‘
9 | keywords: Nvidia Jetson Tx2 AGX-Xavier N ...
at generateError (/home/ljx/node-js/hexo-starter-master/node_modules/js-yaml/lib/loader.js:183:10)
at throwError (/home/ljx/node-js/hexo-starter-master/node_modules/js-yaml/lib/loader.js:187:9)
at readDocument (/home/ljx/node-js/hexo-starter-master/node_modules/js-yaml/lib/loader.js:1645:5)
at loadDocuments (/home/ljx/node-js/hexo-starter-master/node_modules/js-yaml/lib/loader.js:1688:5)
at Object.load (/home/ljx/node-js/hexo-starter-master/node_modules/js-yaml/lib/loader.js:1714:19)
at Hexo.yamlHelper (/home/ljx/node-js/hexo-starter-master/node_modules/hexo/lib/plugins/renderer/yaml.js:7:15)
at Hexo.tryCatcher (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/util.js:16:23)
at Hexo.<anonymous> (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/method.js:15:34)
at /home/ljx/node-js/hexo-starter-master/node_modules/hexo/lib/hexo/render.js:81:22
at tryCatcher (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:466:21) {
reason: 'end of the stream or a document separator is expected',
mark: {
name: null,
buffer: '# Hexo Configuration\n' +
'## Docs: https://hexo.io/docs/configuration.html\n' +
'## Source: https://github.com/hexojs/hexo/\n' +
'\n' +
'# Site\n' +
'title:俊俊的笔记\n' +
'subtitle: 记录学习\n' +
'description: ’希望大佬能够出现在我这里给指点一二‘\n' +
'keywords: Nvidia Jetson Tx2 AGX-Xavier NX Nano Nano2gb\n' +
'author: ljx\n' +
'language: en\n' +
"timezone: ''\n" +
'\n' +
'# URL\n' +
"## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'\n" +
'url: http://example.com\n' +
'permalink: :year/:month/:day/:title/\n' +
'permalink_defaults:\n' +
'pretty_urls:\n' +
" trailing_index: true # Set to false to remove trailing 'index.html' from permalinks\n" +
" trailing_html: true # Set to false to remove trailing '.html' from permalinks\n" +
'\n' +
'# Directory\n' +
'source_dir: source\n' +
'public_dir: public\n' +
'tag_dir: tags\n' +
'archive_dir: archives\n' +
'category_dir: categories\n' +
'code_dir: downloads/code\n' +
'i18n_dir: :lang\n' +
'skip_render:\n' +
'\n' +
'# Writing\n' +
'new_post_name: :title.md # File name of new posts\n' +
'default_layout: post\n' +
'titlecase: false # Transform title into titlecase\n' +
'external_link:\n' +
' enable: true # Open external links in new tab\n' +
' field: site # Apply to the whole site\n' +
" exclude: ''\n" +
'filename_case: 0\n' +
'render_drafts: false\n' +
'post_asset_folder: false\n' +
'relative_link: false\n' +
'future: true\n' +
'highlight:\n' +
' enable: true\n' +
' line_number: true\n' +
' auto_detect: false\n' +
" tab_replace: ''\n" +
' wrap: true\n' +
' hljs: false\n' +
'prismjs:\n' +
' enable: false\n' +
' preprocess: true\n' +
' line_number: true\n' +
" tab_replace: ''\n" +
'\n' +
'# Home page setting\n' +
"# path: Root path for your blogs index page. (default = '')\n" +
'# per_page: Posts displayed per page. (0 = disable pagination)\n' +
'# order_by: Posts order. (Order by date descending by default)\n' +
'index_generator:\n' +
" path: ''\n" +
' per_page: 10\n' +
' order_by: -date\n' +
'\n' +
'# Category & Tag\n' +
'default_category: uncategorized\n' +
'category_map:\n' +
'tag_map:\n' +
'\n' +
'# Metadata elements\n' +
'## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta\n' +
'meta_generator: true\n' +
'\n' +
'# Date / Time format\n' +
'## Hexo uses Moment.js to parse and display date\n' +
'## You can customize the date format as defined in\n' +
'## http://momentjs.com/docs/#/displaying/format/\n' +
'date_format: YYYY-MM-DD\n' +
'time_format: HH:mm:ss\n' +
"## updated_option supports 'mtime', 'date', 'empty'\n" +
"updated_option: 'mtime'\n" +
'\n' +
'# Pagination\n' +
'## Set per_page to 0 to disable pagination\n' +
'per_page: 18\n' +
'pagination_dir: page\n' +
'\n' +
'# Include / Exclude file(s)\n' +
"## include:/exclude: options only apply to the 'source/' folder\n" +
'include:\n' +
'exclude:\n' +
'ignore:\n' +
'\n' +
'# Extensions\n' +
'## Plugins: https://hexo.io/plugins/\n' +
'## Themes: https://hexo.io/themes/\n' +
'#theme: landscape\n' +
'\n' +
'theme: hexo-theme-matery\n' +
'# Deployment\n' +
'## Docs: https://hexo.io/docs/one-command-deployment\n' +
'deploy:\n' +
" type: ''\n",
position: 141,
line: 6,
column: 8,
snippet: ' 4 | \n' +
' 5 | # Site\n' +
' 6 | title:俊俊的笔记\n' +
' 7 | subtitle: 记录学习\n' +
'-------------^\n' +
' 8 | description: ’希望大佬能够出现在我这里给指点一二‘\n' +
' 9 | keywords: Nvidia Jetson Tx2 AGX-Xavier N ...'
}
}
这里的错误就是_config.yml文件内容有问题
生成静态文件,并开启Hexo服务:
进入到了hexo的安装目录之后,使用hexo generate来生成静态文件,也可以使用hexo g,之后使用hexo server(可以写成hexo s)命令启动服务,操作如下:
ljx@ljx-desktop:~/node-js/hexo-starter-master$ hexo g
INFO Validating config
INFO Start processing
INFO Files loaded in 1.09 s
INFO Generated: archives/index.html
INFO Generated: archives/2022/index.html
INFO Generated: archives/2022/02/index.html
INFO Generated: index.html
INFO Generated: medias/avatar.jpg
INFO Generated: medias/barrager/0.png
INFO Generated: medias/featureimages/10.jpg
INFO Generated: medias/reward/alipay.jpg
INFO Generated: 2022/02/12/hello-world/index.html
INFO Generated: favicon.png
INFO Generated: medias/comment_bg.png
INFO Generated: medias/icp.png
INFO Generated: medias/logo.png
INFO Generated: medias/barrager/1.png
INFO Generated: medias/barrager/2.png
INFO Generated: medias/barrager/close.png
INFO Generated: medias/featureimages/13.jpg
INFO Generated: medias/featureimages/16.jpg
INFO Generated: medias/featureimages/15.jpg
INFO Generated: medias/featureimages/2.jpg
INFO Generated: medias/featureimages/21.jpg
INFO Generated: medias/featureimages/22.jpg
INFO Generated: medias/featureimages/23.jpg
INFO Generated: medias/featureimages/3.jpg
INFO Generated: medias/featureimages/5.jpg
INFO Generated: medias/featureimages/8.jpg
INFO Generated: medias/featureimages/7.jpg
INFO Generated: medias/reward/wechat.png
INFO Generated: medias/banner/0.jpg
INFO Generated: libs/awesome/webfonts/fa-brands-400.woff2
INFO Generated: libs/twikoo/twikoo.all.min.js.LICENSE.txt
INFO Generated: libs/lightGallery/img/loading.gif
INFO Generated: libs/share/fonts/iconfont.eot
INFO Generated: medias/banner/2.jpg
INFO Generated: medias/featureimages/0.jpg
INFO Generated: medias/banner/3.jpg
INFO Generated: medias/featureimages/11.jpg
INFO Generated: medias/featureimages/1.jpg
INFO Generated: medias/featureimages/12.jpg
INFO Generated: medias/featureimages/14.jpg
INFO Generated: medias/featureimages/17.jpg
INFO Generated: medias/featureimages/18.jpg
INFO Generated: medias/featureimages/19.jpg
INFO Generated: medias/featureimages/20.jpg
INFO Generated: medias/featureimages/4.jpg
INFO Generated: medias/featureimages/9.jpg
INFO Generated: medias/featureimages/6.jpg
INFO Generated: libs/awesome/webfonts/fa-brands-400.woff
INFO Generated: libs/awesome/webfonts/fa-solid-900.woff
INFO Generated: libs/aos/aos.js
INFO Generated: libs/awesome/webfonts/fa-solid-900.woff2
INFO Generated: libs/aplayer/APlayer.min.css
INFO Generated: libs/background/ribbon-dynamic.js
INFO Generated: libs/codeBlock/codeBlockFuction.js
INFO Generated: libs/instantpage/instantpage.js
INFO Generated: libs/jqcloud/jqcloud-1.0.4.min.js
INFO Generated: libs/justifiedGallery/justifiedGallery.min.css
INFO Generated: libs/minivaline/MiniValine.js
INFO Generated: libs/mermaid/mermaid.min.css
INFO Generated: libs/others/TencentCaptcha.js
INFO Generated: libs/prism/prism.css
INFO Generated: libs/scrollprogress/scrollProgress.min.js
INFO Generated: libs/tocbot/tocbot.css
INFO Generated: libs/fancybox/jquery.fancybox.css
INFO Generated: libs/share/css/share.min.css
INFO Generated: libs/animate/animate.min.css
INFO Generated: libs/cryptojs/crypto-js.min.js
INFO Generated: libs/dplayer/DPlayer.min.css
INFO Generated: libs/gitment/gitment-default.css
INFO Generated: libs/gitalk/gitalk.css
INFO Generated: libs/masonry/masonry.pkgd.min.js
INFO Generated: libs/jquery/jquery-3.6.0.min.js
INFO Generated: libs/materialize/materialize.min.css
INFO Generated: libs/valine/Valine.min.js
INFO Generated: libs/lightGallery/css/lightgallery.min.css
INFO Generated: libs/awesome/css/all.css
INFO Generated: libs/share/js/jquery.share.min.js
INFO Generated: libs/lightGallery/js/lightgallery-all.min.js
INFO Generated: medias/images/02.jpg
INFO Generated: libs/awesome/webfonts/fa-regular-400.ttf
INFO Generated: libs/lightGallery/fonts/lg.svg
INFO Generated: css/barrager.css
INFO Generated: css/bb.css
INFO Generated: css/my-gitalk.css
INFO Generated: css/my.css
INFO Generated: js/gallery-encrypt.js
INFO Generated: css/gallery.css
INFO Generated: css/gitment.css
INFO Generated: libs/aplayer/Meting.min.js
INFO Generated: libs/background/canvas-nest.js
INFO Generated: libs/background/ribbon-refresh.min.js
INFO Generated: libs/codeBlock/codeCopy.js
INFO Generated: libs/background/ribbon.min.js
INFO Generated: libs/codeBlock/codeLang.js
INFO Generated: libs/codeBlock/codeShrink.js
INFO Generated: libs/jqcloud/jqcloud.css
INFO Generated: libs/others/busuanzi.pure.mini.js
INFO Generated: libs/others/clicklove.js
INFO Generated: libs/others/snow.js
INFO Generated: libs/others/star.js
INFO Generated: libs/tocbot/tocbot.min.js
INFO Generated: css/matery.css
INFO Generated: js/jquery.barrager.js
INFO Generated: js/search.js
INFO Generated: libs/aos/aos.css
INFO Generated: js/matery.js
INFO Generated: libs/aplayer/APlayer.min.js
INFO Generated: libs/gitment/gitment.js
INFO Generated: libs/justifiedGallery/justifiedGallery.min.js
INFO Generated: libs/others/sakura-half.js
INFO Generated: libs/materialize/materialize.min.js
INFO Generated: libs/others/sakura-reduce.js
INFO Generated: libs/others/sakura-small.js
INFO Generated: libs/others/sakura.js
INFO Generated: libs/valine/av-min.js
INFO Generated: libs/fancybox/fancybox.js
INFO Generated: libs/awesome/css/all.min.css
INFO Generated: libs/share/js/social-share.min.js
INFO Generated: medias/cover.jpg
INFO Generated: libs/twikoo/twikoo.all.min.js
INFO Generated: medias/banner/1.jpg
INFO Generated: medias/banner/5.jpg
INFO Generated: medias/banner/6.jpg
INFO Generated: libs/awesome/webfonts/fa-brands-400.eot
INFO Generated: libs/awesome/webfonts/fa-brands-400.ttf
INFO Generated: libs/awesome/webfonts/fa-regular-400.svg
INFO Generated: js/crypto-js.js
INFO Generated: libs/dplayer/DPlayer.min.js
INFO Generated: libs/awesome/webfonts/fa-regular-400.woff
INFO Generated: libs/lightGallery/img/video-play.png
INFO Generated: libs/echarts/echarts.min.js
INFO Generated: libs/lightGallery/img/youtube-play.png
INFO Generated: libs/awesome/webfonts/fa-regular-400.woff2
INFO Generated: libs/lightGallery/img/vimeo-play.png
INFO Generated: libs/lightGallery/fonts/lg.ttf
INFO Generated: libs/lightGallery/fonts/lg.woff
INFO Generated: libs/share/fonts/iconfont.svg
INFO Generated: libs/share/fonts/iconfont.woff
INFO Generated: libs/share/fonts/iconfont.ttf
INFO Generated: libs/awesome/webfonts/fa-solid-900.eot
INFO Generated: libs/awesome/webfonts/fa-regular-400.eot
INFO Generated: libs/awesome/webfonts/fa-solid-900.ttf
INFO Generated: libs/gitalk/gitalk.min.js
INFO Generated: medias/banner/4.jpg
INFO Generated: medias/images/03.jpg
INFO Generated: libs/mermaid/mermaid.min.js
INFO Generated: medias/images/01.jpg
INFO Generated: libs/awesome/webfonts/fa-brands-400.svg
INFO Generated: libs/awesome/webfonts/fa-solid-900.svg
INFO Generated: libs/mermaid/mermaid.js
INFO 150 files generated in 690 ms
hexo -s出现问题,肯定是我之前的配置冲突了如下:
INFO Validating config
FATAL Port 4000 has been used. Try other port instead.
FATAL {
err: Error: listen EADDRINUSE: address already in use :::4000
at Server.setupListenHandle [as _listen2] (node:net:1330:16)
at listenInCluster (node:net:1378:12)
at Server.listen (node:net:1465:7)
at /home/ljx/node-js/hexo-starter-master/node_modules/hexo-server/lib/server.js:68:12
at Promise._execute (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/promise.js:103:10)
at checkPort (/home/ljx/node-js/hexo-starter-master/node_modules/hexo-server/lib/server.js:65:10)
at Hexo.module.exports (/home/ljx/node-js/hexo-starter-master/node_modules/hexo-server/lib/server.js:17:10)
at Hexo.tryCatcher (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/util.js:16:23)
at Hexo.<anonymous> (/home/ljx/node-js/hexo-starter-master/node_modules/bluebird/js/release/method.js:15:34)
at Hexo.call (/home/ljx/node-js/hexo-starter-master/node_modules/hexo/lib/hexo/index.js:258:27)
at /usr/local/lib/node_modules/hexo-cli/lib/hexo.js:60:17
at tryCatcher (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:15:14) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 4000
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html
ljx@ljx-desktop:~/node-js/hexo-starter-master$ sudo vi _config.yml
ljx@ljx-desktop:~/node-js/hexo-starter-master$ ls
blog _config.yml nginx package.json public source
_config.landscape.yml db.json node_modules package-lock.json scaffolds themes
ljx@ljx-desktop:~/node-js/hexo-starter-master$ vi package.json
ljx@ljx-desktop:~/node-js/hexo-starter-master$ hexo s -p 4001
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:4001/ . Press Ctrl+C to stop.
4000估计也开启了,现在可以看到4001端口的服务已经开启,之后在你的浏览器输入http://<你的linux机器的ip地址或者服务器公网地址>:4001,如下可以看到最开始的一个界面:
初步使用Hexo:
使用前,我们对我们的站点进行一个配置,也就是我们创建的hexo目录的_config.yml文件,可以修改的部分介绍如下:
Sitetitle: QIMING.INFO #博客网站的标题
subtitle: #博客网站的副标题
description: #你的网站描述
keywords: #网站的关键词
author: #作者的名字
language: #博客网站使用的语言
timezone: #网站时区
4开始使用Hexo发布自己的第一篇博客!
执行下面的目录创建一篇新文章:
hexo new post <文章标题>
这里我创建了一篇博客,创建之后hexo目录下面的source/post文件夹下会产生一个搭建环境第一天文件
编辑文章
进入到上面说的那个目录下可以看到我们创建的博客文件:
直接使用vim或者vi就可以对我们的博客文章进行编辑了,打开此后可以看到---分隔的区域,这部分主要对文章进行标注变量,如下:
发布文章
输入如下命令,生成静态网页,静态网页会存放在public文件下
hexo g
hexo s
之后就可以去浏览器访问了!可以看到我们发布的文章已经成功在浏览器显示,到这里个人博客网站就已经成功搭建了。
主题的选择
主题网站:https://hexo.io/themes/ hexo提供了大量精美的主题供我们选择,选择喜欢的主题,在hexo目录下的themes文件夹下使用git clone下载主题,之后再配置文件_config.yml把theme后面修改成下载的主题的名字,之后运行hexo clean ,hexo g即可看到生效的主题。
将Hexo部署上线到服务器:
如果是有服务器的小伙伴,也可以将Hexo部署到服务器供全网访问,服务器的购买这里就不多说,阿里云跟腾讯云上面对于学生也有较为优惠的价格。部署到服务器的话,就需要将上面的全部操作,在你的服务器系统上面执行,之后我们使用Nginx(反向代理服务器)进行部署。
Nginx安装:(这个方法我没有用,安装2)
Nginx是一款高性能的 HTTP 和反向代理服务器,这里我们采用编译安装的方式,按照下面的指引依次执行命令
#安装gcc编译环境:
yum install -y gcc-c++
#安装zlib-devel库:yum install -y zlib-devel
#安装OpenSSL密码库:yum install -y openssl openssl-devel
#安装pcre正则表达式库:编译nginx,需要需要指定pcre的路径,这里我们选择安装稳定版本的。
#下载地址:https://ftp.pcre.org/pub/pcre/#选择对应的版本下载下来之后上传到我们的服务器,也可以使用wget直接下载
tar -xf pcre-8.43.tar.gzcd pcre-8.43
mkdir -p /usr/local/pcre./configure --prefix=/usr/local/pcre
make && make install
下载编译安装nginx:
nginx下载官网:http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.16.0.tar.gz
mkdir -p /usr/local/nginx
tar -xf nginx-1.16.0.tar.gz
#编译指定安装路径需要进入nginxcd nginx-1.16.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
#http_ssl_module 这是支持https的一个模块,就是可以使用https://这样去访问。
make && make install #编译安装
启动nginx服务:
#启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#用指定配置文件的方式启动 -c
#测试:
/usr/local/nginx/sbin/nginx -t
#这个用于测试nginx的语法是否有问题 显示is successful即为成功。
#关闭:/usr/local/nginx/sbin/nginx -s stop
#继续输入以下命令使Nginx开机自动启动:systemctl enable nginx
#配置文件的位置:/usr/local/nginx/conf
之后我们需要配置阿里云公网ip,编辑配置文件。
之后再重启nginx服务,开启hexo服务,这个时候使用公网的ip就可以访问到我们的hexo博客了!
安装2:
- 下载nginx安装包:nginx: download
- 下载 nginx-rtmp-module :https://github.com/arut/nginx-rtmp-module/archive/master.zip
- 解压
-
#两个包最好放一个空文件夹中 tar -zxvf nginx-1.18.0.tar.gz #解压命令 unzip nginx-rtmp-module-master #解压命令
- 安装依赖
-
sudo apt install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel ## 再执行安装 make && make install
或者
-
## 进入nginx目录 cd nginx-1.18.0 **********************安装依赖 gcc g++******************************** sudo apt install gcc g++ **********************安装依赖 pcre******************************** wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz tar -zxvf pcre-8.40.tar.gz cd pcre-8.40 #编译安装 ./configure make && make install #查看pcre版本 pcre-config --version **********************安装依赖 zlib******************************** wget http://zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install **********************安装依赖 openssl******************************** wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz tar -zxvf openssl-1.0.1c.tar.gz
- install nginx
-
# 将nginx-rtmp 模本编译到 nginx 下,注意是通过相对路径找到自己对应的nginx-rtmp-module-master 安装位置 1) ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/home/ljx/node-js/nginx/nginx-1.18.0/pcre-8.40 --with-zlib=/home/ljx/node-js/nginx/nginx-1.18.0/zlib-1.2.11 --add-module=/home/ljx/node-js/nginx/nginx-rtmp-module-master 2)make 3)make install
- 配置nginx
-
cd /usr/local/nginx sudo gedit nginx.conf ### 修改内容如下 注意是在http{}外进行添加:
rtmp{ server{ listen 1935 ; application live{ live on; record off; } application hls{ live on; hls on; hls_path nginx-rtmp-module/hls; hls_cleanup off; } } }
- 配置环境
-
sudo gedit /etc/profile """加入下面的话在最后""" export PATH="$PATH:/usr/local/nginx" """""""""""""""""""""""" source /etc/profile
- 启动与停止
-
#启动nginx服务器 启动服务器后在浏览器输入你服务器的ip(127.0.0.1):端口如果可以访问则说明配置成功了。 sudo -s source /etc/profile nginx -V # begin /usr/local/nginx/nginx ps -ef | grep nginx netstat -ano|grep 1935 #停止 /usr/local/nginx/nginx -s stop #关闭防火墙,不然你浏览器访问不了 systemctl stop firewalld #检查是否成功:浏览器输入服务器IP,就可以检测是否成功
nginx自启动
-
sudo gedit /etc/rc.local """ sudo source /etc/profile sudo /usr/local/nginx/nginx """ sudo reboot ps -ef | grep nginx
发布到github,小编现在没钱买域名这些,所以用这个也满足了
-
配置github基本你的先下载
-
sudo apt install git
-
git --version //验证是否安装成功
-
git config --global user.name "用户名你的设备当前使用的用户名"
-
git config --global user.email 你的github邮箱
-
git config --list
-
为GitHub账号添加SSH Keys
1.生成Keys
linuxidc@linuxidc:~$ ssh-keygen -t rsa -C "你的github邮箱"
-
输出如下示例: Generating public/private rsa key pair. Enter file in which to save the key (/home/linuxidc/.ssh/id_rsa): /home/linuxidc/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/linuxidc/.ssh/id_rsa. Your public key has been saved in /home/linuxidc/.ssh/id_rsa.pub. The key fingerprint is: SHA256:SJzejSuID3eygvca1i7Ci+TqTIbxWcXULnw949ZXyMM root@linuxidc.net The key's randomart image is: +---[RSA 2048]----+ | .. | | + .. | | .*. . . o | | +oooo+ E .| |. . ooS..+ o | |.o.= . .o . . | |o**.o . .. . | |@o+= . . | |BO*+o | +----[SHA256]-----+
-
回到主目录下 ls -a
-
新生成的.ssh
-
cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRTOMUbHoY8yr6fyYE43pL3bD7VUz9FvlGzi3ACX4jYeUcaPM+Ni5XBtM1ZPD1l1EN0fCNrSpR1Y1sw4dJzbeE9JFM/iLTugFyUaxaLcNPpqXkR4uxipheeM5aIg+523Lm2oR7HeImORjHPr2SN5ZR/YbLecMxhDbx3rAbeYYNtxBE9c9kRF0m0gyLneCo8HxIZz+9wXK2G/B5eZEpnG/8zWkGkCwRB16J6JeWF+9kjwohxXTtZHDjXSt8VysW0EFRkxjxSk5JOTPgPtJOPDKfmXWsw47OeY3gRJHCb4BCMxBvlU341Ncp/rYP/S9bWuUDWHCt8rkGoRXF/6LKw9FD root@linuxidc.net
复制密钥到github
-
登录github-> Settings-> SSH and GPG Keys-> New SSH key添加
-
测试是否连接成功
linuxidc@linuxidc:~$ ssh -T git@github.com
Hi Unlicensed-driver-ljx! You've successfully authenticated, but GitHub does not provide shell access
成功!
-
本地创建一个仓库,我直接用这个node-js下hexo的目录了
-
git init
-
ls -a
-
新建Github仓库
-
- 到GitHub上去建一个repository. 注意名字只能是" github账户名.github.io ".
- 然后进入这个repo,点击最右侧的setting。
在这个界面一直往下拉,可以看到
目录下找到_config.yml使用vscode或者sublime等编辑器打开.按照如下配置Deployment:
记得 先安装deploy-git ,也就是部署的命令,这样你才能用命令部署到GitHub。
deploy时要你输入username和password。
sudo npm install hexo-deployer-git --save
sudo hexo clean
sudo hexo generate
sudo hexo deploy
好了愉快登录,Hexo
后面完善细节,主题这些,小白我是所以写的不好的大家指出来