3.4 部署网站
约 387 字大约 1 分钟
2025-05-06
需要收集表单的类似问卷的功能就需要后端了,只能部署到服务器上
也可以部署到 github page 这样的静态网页,通过 https://formspree.io 进行后端收集表单
3.4.1 配置 Nginx
安装 nginx(如果未安装):
sudo apt update sudo apt install nginx
编辑 nginx 配置(假设项目在 /home/ubuntu/your_project):
sudo vim /etc/nginx/sites-available/default
将 server 部分改为如下(请根据实际路径调整 root 路径):
server { listen 80; server_name 服务器公网IP或域名; root /home/ubuntu/your_project; index index.html; location / { try_files $uri $uri/ =404; } location /save_result { proxy_pass http://127.0.0.1:5000/save_result; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
重启 nginx:
sudo systemctl restart nginx
访问测试:在浏览器访问 http://服务器IP/ ,应该能看到 index.html
页面
3.4.2 Vuepress DocSearch
https://vitepress.yiov.top/docsearch.html#%E5%AE%98%E6%96%B9%E7%94%B3%E8%AF%B7
之前搞了好多次 Algolia DocSearch 都没有成功,结果按照上面的教程一步一步对下来发现:
登录 Algolia 官方爬虫后台 进行调试点
Overview
进来后发现爬虫数据有的,但是 Records 没有值点
Editor
进行修改调试:pathsToMatch
多了一个doc
- 爬虫配置中的
actions
的recordProps
也最好要改成自己使用的主题的提供的选项
修改之后点
Runtest
测试一下,我发现我的 Record 还是 0(没有警告),但是不要紧,保存之后重新完整爬取之后 index Records 就有值了