这是一个基于 Vue 的通用网站导航页面,你可以将其放在个人网站的首页作为您博客的引导页面或者是您其他项目的引导页。使用自适应布局兼容多端显示,方便游客浏览您的个人网站,背景图来自于 Bing 每日图片。
本次实践为个人测试环境,操作系统版本为centos7.6。
hostname | 本地P地址 | 操作系统版本 | 内核版本 | node版本 |
---|---|---|---|---|
jeven | 192.168.3.246 | Ubuntu 22.04.1 LTS | 5.15.0-89-generic | v18.0.0 |
1.本次实践部署环境为个人测试环境,生产环境请谨慎;
2.在centos7.6环境下部署Blog-Index导航页。
检查本地操作系统版本,当前版本为Ubuntu 22.04.1 LTS。
root@jeven:~# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
检查系统内核版本,当前内核版本为5.15.0-89-generic。
root@jeven:~# uname -r
5.15.0-89-generic
检查系统是否安装yarn工具
root@jeven:~# yarn -v
Command 'yarn' not found, but can be installed with:
apt install cmdtest
下载Node.js安装包,本次使用的Node.js版本为v20.10.0。
wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz
执行以下命令,解压Node.js安装包。
tar -xvJf node-v20.10.0-linux-x64.tar.xz
采用创建软链接的方法,使得在任意目录下都可以直接使用node和npm命令。
ln -s /root/node-v20.10.0-linux-x64/bin/node /usr/local/bin/node
ln -s /root/node-v20.10.0-linux-x64/bin/npm /usr/local/bin/npm
export NODE_HOME=/root/node-v20.10.0-linux-x64/bin/
export PATH=$PATH:$NODE_HOME:/usr/local/bin/
source /etc/profile
查看node版本,确保Node.js正常安装。
root@jeven:~# node -v
v20.10.0
root@jeven:~# npm -v
10.2.3
npm install -g yarn
检查yarn版本,当前安装版本为1.22.21。
root@jeven:~# yarn --version
1.22.21
设置国内镜像源
yarn config set registry https://registry.npmmirror.com
下载Blog-Index软件包
git clone https://github.com/EsunR/Blog-Index.git
查看Blog-Index源码目录
root@jeven:~# tree -L 2 ./Blog-Index/
./Blog-Index/
├── CHANGELOG.md
├── commitlint.config.js
├── demo
│ └── show.png
├── index.html
├── package.json
├── postcss.config.js
├── public
│ └── favicon.ico
├── README.md
├── src
│ ├── App.vue
│ ├── assets
│ ├── components
│ ├── config.ts
│ ├── hooks
│ ├── main.ts
│ ├── types
│ └── utils
├── tsconfig.json
├── vite.config.ts
└── yarn.lock
8 directories, 14 files
root@jeven:~# cd Blog-Index/
root@jeven:~/Blog-Index# ls
CHANGELOG.md demo package.json public src vite.config.ts
commitlint.config.js index.html postcss.config.js README.md tsconfig.json yarn.lock
root@jeven:~/Blog-Index# yarn install
yarn install v1.22.21
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
$ husky install
husky - Git hooks installed
Done in 66.21s.
在开发环境中,执行以下命令,启动Blog-Index项目。
yarn dev --host 192.168.3.246
访问地址:http://192.168.3.246:5173,将IP地址替换为自己服务器IP地址。如果无法访问,则查看服务器防火墙是否配置,如果是云服务器,则还需配置安全组端口。
修改配置文件src/config.ts
vim src/config.ts
使用以下命令来打包生产版本,打包输出在 dist/目录下。
yarn build
root@jeven:~/Blog-Index# ls dist/
assets favicon.ico index.html ssr-manifest.json ssr-manifest.json.gz
安装apache2,Apache2是一个开源的Web服务器软件,是Apache软件基金会的一个成员项目。Apache2是Apache Web Server的下一代版本,是目前世界上使用最广泛的Web服务器软件之一。
apt install apache2 -y
启动apache2服务
systemctl enable apache2 --now
检查apache2服务状态,确保apache2服务处于正常运行状态。
root@jeven:~/Blog-Index# systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-01-29 07:17:21 UTC; 1 week 5 days ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 1031 (apache2)
Tasks: 55 (limit: 4558)
Memory: 6.5M
CPU: 33.061s
CGroup: /system.slice/apache2.service
├─ 1031 /usr/sbin/apache2 -k start
├─783063 /usr/sbin/apache2 -k start
└─783064 /usr/sbin/apache2 -k start
Feb 07 00:00:03 jeven systemd[1]: Reloaded The Apache HTTP Server.
Feb 08 00:00:02 jeven systemd[1]: Reloading The Apache HTTP Server...
Feb 08 00:00:03 jeven apachectl[642921]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. S>
Feb 08 00:00:03 jeven systemd[1]: Reloaded The Apache HTTP Server.
Feb 09 00:00:03 jeven systemd[1]: Reloading The Apache HTTP Server...
Feb 09 00:00:03 jeven apachectl[706265]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. S>
Feb 09 00:00:03 jeven systemd[1]: Reloaded The Apache HTTP Server.
Feb 10 00:00:02 jeven systemd[1]: Reloading The Apache HTTP Server...
Feb 10 00:00:03 jeven apachectl[783062]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. S>
Feb 10 00:00:03 jeven systemd[1]: Reloaded The Apache HTTP Server.
lines 1-23/23 (END)
将Blog-Index目录下的网站文件都拷贝网站根目录/var/www/html下
cp -a dist/* /var/www/html/
重启apache2服务
systemctl restart apache2
访问地址:http://192.168.3.246,将IP地址替换为自己服务器IP地址,进入到web-check首页。如果无法访问,则查看服务器防火墙是否配置,如果是云服务器,则还需配置安全组端口。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。