- 使用cppweb搭建简单的http服务器和https服务器
linux可用
-
git clone https://gitee.com/chenxuan520/server-for-static-web.git
-
./install.sh
-
填入端口等信息
-
服务器运行
-
填入绑定的端口(如5200)
-
填入网页默认的html文件名(index.html)
-
填入是否运行在后台 (true or false)
-
填入是否使用守护进程 (true or false)
windows和linux都可
-
git clone https://gitee.com/chenxuan520/server-for-static-web.git
-
make (windows下make -f makefile.win)
如果有https证书也可以make ssl
-
修改config.json,介绍
-
./main
-
不运行在后台的话shell结束会一起结束
-
守护进程可以保证宕机快速重启
-
直接修改config.json
-
./main --reload
- ./main --stop
- ./main --config=(文件名字)
- ./main --help
-
用于修改配置法,脚本法无效
-
需要提前安装openssl
sudo apt install openssl libssl-devopenssl genrsa -des3 -out privkey.pem 2048
openssl req -new -key privkey.pem -out cert.csr
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095-
获取路径有域名购买处或者freessl
-
下载用于nginx的证书,包含一个pem和一个key
-
转换key为pem
openssl rsa -in (key name).key -out (new name).pem-
把"cert path"和"key path"的值改为证书路径
-
如果没有密码把"cert password"这行注释
-
make ssl
-
./main