[toc]

1.Nginx 安装

一、安装编译工具及库文件

1
2
3
4
5
#安装编译环境:gcc gcc-c++
#安装openssl-devel(使nginx支持ssl)
#安装lib
yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel

二、首先要安装 PCRE

PCRE 作用是让 Nginx 支持 Rewrite 功能。

1
yum -y install pcre pcre-devel

三、安装 Nginx

1、下载 Nginx,下载地址:https://nginx.org/en/download.html

1
# 找到nginx-1.22.0这个稳定包,下载下来,然后用rz上传到服务器

2、解压安装包

1
tar -xzvf nginx-1.22.0.tar.gz

3、进入安装包目录

1
cd nginx-1.22.0

4、编译

1
./configure --prefix=/usr/local/nginx

5、安装

1
make && make install

6、查看nginx版本

1
/usr/local/nginx/sbin/nginx -v

四、启动Nginx

进入安装好的目录/usr/local/nginx/sbin

1
2
3
4
./nginx           启动
./nginx -s stop 快速关闭
./nginx -s quit 优雅关闭,在退出前完成已经接受的连接请求
./nginx -s reload 重新加载配置

五、关于防火墙和SELINUX

关闭防火墙

1
systemctl stop firewalld.service

禁止防火墙开机自启

1
systemctl stop firewalld.service
1
2
3
4
5
6
7
#关闭SELINUX
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
#修改完成之后重启服务器,然后getenforce看看
#当然如果不想重启服务器也可以先修改好配置,然后用 setenforce 0来临时关闭SELINUX,下次重启自然会识别配置文件了。
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive

六、添加systemctl管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStartPre=/bin/mkdir /tmp/nginx
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF

七、创建环境变量

1
2
3
4
5
vim /etc/profile.d/nginx.sh

NGINX_HOME=/usr/local/nginx
PATH=$NGINX_HOME/sbin:$PATH
export NGINX_HOME PATH

source /etc/profile.d/nginx.sh

启动nginx

1
2
mkdir -p /tmp/nginx
nginx

八、修改ip为静态地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="ff458f3b-f132-400d-ae06-86277ce43612"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.110.131 # 静态ip地址
NETMASK=255.255.255.0 # 子网掩码
GATEWAY=192.168.110.1 # 网关地址
BROADCAST=192.168.110.255 # 广播地址
BOOTPROTO="static" # 修改静态

2.Nginx的conf学习

nginx.conf的配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
more /usr/local/nginx/conf/nginx.conf

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

# 虚拟服务器 这里开始
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# 虚拟服务器 这里结束

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

虚拟主机

虚拟主机应用场景:一个WEB服务器同时发布多个WEB站点

用ip基于端口访问
1
2
3
4
5
6
7
8
9
10
# 在跟目录下放置www目录,然后内置两个目录,分别是www目录和void目录
# 写入不同的html页面
[root@localhost /]# cd www
[root@localhost www]# ls
void www
[root@localhost www]# cat void/index.html
this is void web site...
[root@localhost www]# cat www/index.html
this is www web site...
[root@localhost www]#

修改nginx.conf配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost www]# vim /usr/local/nginx/conf/nginx.conf

server {
listen 80; #网页访问端口80
server_name localhost;
location / {
root /www/www; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81; #网页访问端口81
server_name localhost;
location / {
root /www/void; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
用域名基于端口访问
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost www]# vim /usr/local/nginx/conf/nginx.conf

server {
listen 80; #网页访问端口80
server_name www.julintongxue.top;#域名
location / {
root /www/www; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81; #网页访问端口81
server_name void.julintongxue.top;#域名
location / {
root /www/void; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

[toc]

简介

目前,互联网资源的普及,已经可以让每人搭建独立搭一个个人博客了;这边就教大家怎么搭建Hexo并配置。大家可以参考Hexo官方文档配合使用。

前提

Windows端

安装:

  1. Node.js
  2. Git

在我们的日常开发中经常会遇到这种情况:手上有好几个项目,每个项目的需求不同,进而不同项目必须依赖不同版的 NodeJS 运行环境。如果没有一个合适的工具,这个问题将非常棘手。所以nvm应运而生。

而我们传统的安装 NodeJS的方法很容易出现错误,而且配置起来也特别麻烦,所以我们采用nvm这个项目管理工具来配合我们安装博客会更加的丝滑而且几乎没有报错的可能,读者也可以根据自己喜欢的版本无缝切换。

Windows下配置NVM

安装NVM

进入NVM-Windows项目发布地址: https://github.com/coreybutler/nvm-windows/releases ,选择最新发行版本nvm-setup.zip下载:

image-20220710000533630

image-20220710000654131

安装完成后,

在搜索栏查找poweshell,选中x86powershell鼠标右击选择以管理员身份运行

image-20221127134846193

Powershell下,输入NVM,即可发现安装完成:

配置国内源

中国大陆这边连接Node.jsNPM官方服务器有点困难,甚至不单单是下载慢了,有时候直接无法下载使用。所以我们换NVMNode.js成国内源:

到你NVM安装路径,(我的默认安装在:C:\Users\orange\AppData\Roaming\nvm,那么你如果是默认安装的话,里面的orange要改成你自己的用户名)打开setting.txt文件(如果没有,则创建即可),更改:

注意不要照抄文档配置,要根据自己的安装路径写入对应配置

1
2
3
4
5
6
root: C:\Users\orange\AppData\Roaming\nvm
path: C:\Program Files\nodejs
arch: 64
proxy: none
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

这里解释一下参数:

  • root:NVM的安装地址。即上文的%NVM_HOME%
  • path:激活node.js时的存储路径,即上文的%NVM_SYMLINK%
  • arch:系统架构,如果你的Windwos不是x64,则填32
  • proxy:是否走代理
  • node_mirror:node.js的下载源,这里使用的是淘宝源
  • npm_mirror:npm的下载源,这里使用的是淘宝源

image-20230308210424315

管理与安装Node.js

查看已经版本

1
nvm list

查看已经安装的版本:

这里我已经安装了16.15.1版本的node.js,如果你是刚刚安装好的,那么这里将是空白一片

image-20220710001705412

如图:

Snipaste_2022-11-28_14-01-24

查看可安装版本

如何查看通过NVM安装的Node.js版本呢?
你可以直接使用NVM命令:

1
2
# Windows
nvm list available

image-20220710002047715

安装Node.js

我们安装16.15.1版本node.js:

1
nvm install 16.15.1

image-20220710002225007

激活Node.js版本

我们安装好Node.js以后,需要激活它

1
nvm use 16.15.1

image-20220710002353777

然后我们发现出现这堆乱码,其实是因为我们没有用管理员权限的powershell,用管理员的身份打开powershell再来一次即可生效。

安装Git

很简单,无脑下一步!!!

Git的官网地址 给你们啦!!!

安装和管理Hexo博客

使用Npm安装Hexo

因为Node里自带Npm,所以我们可以直接使用Npm;这一步,总的来说,就是:npm install -g hexo为了方便国内用户,提前加了一步更换npm为腾讯云源,非大陆用户可以跳过,Windows用户打开cmdpowershell输入:

1
npm config set registry http://mirrors.cloud.tencent.com/npm/

然后安装hexo-cli

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\WINDOWS\system32> node -v
v16.15.1
PS C:\WINDOWS\system32> npm install hexo-cli --location=global
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

added 59 packages, and audited 60 packages in 58s

14 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 8.11.0 -> 8.13.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.13.2
npm notice Run npm install -g npm@8.13.2 to update!
npm notice

如果出现这个错误

更新一下npm就行了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
npm install -g npm-windows-upgrade


set-ExecutionPolicy RemoteSigned

执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): y


npm-windows-upgrade
npm-windows-upgrade v6.0.1
? Which version do you want to install? 8.13.2
Checked system for npm installation:
According to PowerShell: D:\nodejs
According to npm: D:\nodejs
Decided that npm is installed in D:\nodejs
Upgrading npm... |

Upgrade finished. Your new npm version is 8.13.2. Have a nice day!

更新完成之后就能顺利安装成功hexo了

安装好以后,测试一下:

1
hexo

image-20220710004601578

没有出现未知命令,说明安装成功。可以接下来操作了。

如果出现hexo : 无法加载文件 C:\Program Files\nodejs\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.micros oft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。 所在位置 行:1 字符: 1。

那是因为你用的是win11系统,你需要在设置->隐私和安全性->开发者选项->允许本地powershell脚本在为签名的情况下运行

如图:

image-20230308210045396

应用之后,重新打开新的powershell,再次输入hexo即可。

image-20230308210149994

或者

1
set-ExecutionPolicy RemoteSigned

image-20230930195227900

创建Hexo

因为我们已经安装好Git,所以我们直接是由鼠标右键的Git Bash Here,然后在你喜欢的一个盘符里面创建一个文件夹并且命名。

image-20220710233249939

这里我在D盘创建了个orange的目录,以后我就在里面书写我的博客了,这个目录的文件非常重要,要记得备份哦。。。。。。

image-20220710233151967

刚刚我们已经切换到orange目录,后续操作均在orange目录内进行。确保:

  • Windows用户确保cmdpowershell运行目录在刚刚创建的的orange文件夹内;
  • 注意⚠️:这个目录,日后就是是博客运行目录了。记得备份该文件夹。

在目录内初始化博客

初始化orange目录:

1
2
# 进目录之后,在Git bash里面输入下面目录初始化
hexo init

image-20220710233936892

输入命令后,它会自动爬取hexo的初始化目录,在国内网络是非常不好的,如果出错需要删除目录内容重新执行命令直到成功。

构建Hexo

初始化Hexo后,其实Hexo就可以使用了;构建Hexo:

1
hexo g

会在当前目录下生成一个叫public的文件夹,这个文件夹就是根据你Hexo的配置,生成的HTML+CSS+JS的静态文件了。

启动Hexo内建服务器

其实,整个public文件就是一个博客了,但是我们还要部署Nginx等网络环境或者使用HBuilderX等根据,启动Web服务器才能用浏览器本地IP(即:127.0.0.1localhost)加端口进行访问;为了减少麻烦,可以使用Hexo内建服务器:

1
hexo s

image-20220710234306097

我们可以去127.0.0.1:4000网址看看初始化页面的样子

image-20220710234335015

部署Hexo到远程平台

上述操作,我们已经把Hexo部署在本地;接下来,我们来看看怎么部署到远程平台,部署到远程平台后,公网用户就可以访问了(也就是可以让你小伙伴通过浏览器访问到你的博客)。

部署Hexo到GitHub

GitHub创建仓库

到Github上创建仓库

注意:为了能通过 <你的 GitHub 用户名>.github.io 域名访问,你的仓库(repository) 应该直接命名为:
<你的 GitHub 用户名>.github.io

比如:你的用户名叫:Demo;
那么,你就创建一个仓库叫:Demo.github.io

image-20220710234923191

image-20220710234953614

GitHub现在新的仓库,分支为main,而Hexo默认用master分支。所以创建好后进入仓库,看看是什么分支:

image-20220710235020234

我的博客已经推送过一次了,现在是master,接下来先安装博客里面的git,让我们的博客拥有推送的能力

本地安装hexo-deployer-git

在博客目录内,使用命令窗口/终端输入:

1
2
3
#注意这些插件是安装在博客目录内的,所以是跟随博客内容一起走的
#这个插件是提供上传git能力
npm install hexo-deployer-git --save

修改博客主配置文件

打开博客目录下的_config.yml文件,编辑(这边的可以用记事本),type后的’ ‘,填’git’,然后补上其他内容:

1
2
3
4
5
# 下面这个网址是我的github的一个链接
deploy:
type: git
repo: git@github.com:julintongxue/julintongxue.github.io.git
branch: master

image-20220710235512404

image-20220710235652501

复制HTTPS或者SSH都可以,除了网址你填自己的之外,其他的要和我的符合一致哦

博客推送

在博客目录下命令窗口/终端输入

1
2
3
4
git config --global user.email "your_email"
git config --global user.name "your_name"
# hexo d就是推送博客到指定的地方(本博客推送的地方是Github)
hexo d

会弹出一个github的登陆框,登录上你自己的github即可

然后你访问

<你的 GitHub 用户名>.github.io这个网址就出现你的hexo网站了,你的博客生涯正式开始。。。

image-20220711001206320

配一下ssh公钥验证,这样每次推送就不用次次登录一次Github账号密码

1
ssh-keygen -t rsa -C "your_email"

一路下一步之后,找到你c盘下的用户,找到一个.ssh的隐藏文件夹,在里面有个id_rsa.pub文件,把里面内容复制到github的账户设置里面的ssh验证

image-20220711000855560

因为github在国外,有些时候推送会出现ssl出错,其实就是网络差,我们在Git Bash里面输入下面这行命令,不验证ssl:

1
git config --global http.sslVerify "false"

博客美化

很显然,刚刚装好的博客,丑的一批,啥都没有,那么怎么把这个丑丑的博客改造成为下图那样干净、整洁还有二次元味道捏( ̄▽ ̄)*

image-20230401005302966

主题

更换主题

在博客根目录下,打开git bash,然后克隆代码

1
git clone https://github.com/theme-next/hexo-theme-next themes/next-reloaded

然后修改博客根目录下的全局配置文件_config.ymltheme后面的字母改为your_theme_name,即next-reloaded

image-20230401130703259

头像

主题菜单

隐藏网页底部

网易云音乐外链

看板娘-初音未来

报错

在安装配置node时,cmd检查node没问题

image-20230413013508753

但是检查npm就出现npm WARN config global –global, –localare deprecated. Use–location=global instead.

image-20230413013542955

我们就要来到nvm的路径找到里面的v16.15.1的node的文件夹C:\Users\orange\AppData\Roaming\nvm\v16.15.1

我们需要修改两个文件npmnpm.cmd

image-20230413013913294

将npm文件的第23行,修改成下图样式,命令如下,可以直接粘贴

1
prefix --location=global

image-20230413014025801

image-20230413014108237

将npm.cmd文件的第12行,修改成下图样式,命令如下,可以直接粘贴,修改完保存。

1
prefix --location=global

image-20230413014223400

image-20230413014302436

那么,我们再次打开cmd,执行一下命令再看看还有没报错

image-20230413014433543

[toc]

Blackarch

netdiscover

安装

1
yay -S netdiscover

简单使用

1
2
3
4
5
6
# 这会无休止一直广播ARP
sudo netdiscover
# -i 设置网卡
sudo netdiscover -i wlan0
# -r 设置ip段
sudo netdiscover -i wlan0 -r 192.168.1.0/24

arp-scan

安装

1
2
3
4
5
6
7
8
9
10
11
# 我有blackarch的源,你懂的!!!
[orange@orange ~]$ yay -Ss arp-scan
aur/obs-time-warp-scan 0.1.6-3 (+0 0.00)
Time Warp Scan filter for OBS Studio
aur/arp-scan-git r304.af905ce-1 (+1 0.00)
The ARP Scanner
blackarch/arp-scan 1.9.7-2 (337.6 KiB 1017.9 KiB) [blackarch blackarch-networking blackarch-scanner blackarch-fingerprint]
A tool that uses ARP to discover and fingerprint IP hosts on the local network
community/arp-scan 1.9.7-2 (337.6 KiB 1017.9 KiB)
A tool that uses ARP to discover and fingerprint IP hosts on the local network
[orange@orange ~]$ yay -S arp-scan

简单使用

1
2
# -l 使用本地网络段扫描
sudo arp-scan -l

wireshark