由于没有给域名续费,加上私人时间不足,ZKWeb 的官网和演示站点已经中止了几个月的时间。
最近时间开始变多,因此从新购买了别的域名和服务器把官网和演示站点从新部署上去。
在此前站点是托管在共享主机上的 Windows + IIS 上的,而如今已经换为了 Linux + Nginx,费用比使用共享主机还要便宜。node
由于服务器是 OpenVZ 下的虚拟主机,不能使用 docker,如下的步骤会直接在服务器上运行网站程序。python
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install dotnet-sdk-2.2 -y
sudo apt-get install libgdiplus libunwind8 openssl -y ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh sudo bash nodesource_setup.sh rm nodesource_setup.sh sudo apt-get install nodejs
sudo apt-get install git cd /home/ubuntu git clone https://github.com/zkweb-framework/ZKWeb git clone https://github.com/zkweb-framework/ZKWeb.MVVMDemo git clone https://github.com/zkweb-framework/ZKWeb.Plugins git clone https://github.com/zkweb-framework/ZKWeb.Demo git clone https://github.com/zkweb-framework/ZKWeb.Home
cd ~/ZKWeb.Demo && sh publish_ubuntu.sh cd ~/ZKWeb.Home && sh publish_ubuntu.sh cd ~/ZKWeb.MVVMDemo/src/ZKWeb.MVVMPlugins/MVVM.Angular.Website/static sudo npm install -g @angular/cli npm install ng build --prod --aot cd ~/ZKWeb.MVVMDemo && sh publish_ubuntu.sh
sudo vi /etc/systemd/system/zkweb-home.service
内容:nginx
[Unit] Description=ZKWeb Home After=network.target [Service] WorkingDirectory=/home/ubuntu/ZKWeb.Home.Publish/ZKWeb.Home.Ubuntu ExecStart=/bin/sh -c "./ZKWeb.Home.AspNetCore server.urls=http://127.0.0.1:5000" Restart=always RestartSec=10 KillSignal=SIGINT SyslogIdentifier=zkweb-home User=ubuntu Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] WantedBy=multi-user.target
sudo vi /etc/systemd/system/zkweb-demo.service
内容:git
[Unit] Description=ZKWeb Demo After=network.target [Service] WorkingDirectory=/home/ubuntu/ZKWeb.Demo.Publish/ZKWeb.Demo.Ubuntu ExecStart=/bin/sh -c "./ZKWeb.Demo.AspNetCore server.urls=http://127.0.0.1:5001" Restart=always RestartSec=10 KillSignal=SIGINT SyslogIdentifier=zkweb-demo User=ubuntu Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] WantedBy=multi-user.target
sudo vi /etc/systemd/system/zkweb-mvvm-demo.service
内容:github
[Unit] Description=ZKWeb MVVM Demo After=network.target [Service] WorkingDirectory=/home/ubuntu/ZKWeb.MVVMDemo.Publish/ZKWeb.MVVMDemo.Ubuntu ExecStart=/bin/sh -c "./ZKWeb.MVVMDemo.AspNetCore server.urls=http://127.0.0.1:5002" Restart=always RestartSec=10 KillSignal=SIGINT SyslogIdentifier=zkweb-mvvm-demo User=ubuntu Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] WantedBy=multi-user.target
# 设置重启后自动开始 sudo systemctl enable zkweb-home sudo systemctl enable zkweb-demo sudo systemctl enable zkweb-mvvm-demo # 马上开始 sudo systemctl start zkweb-home sudo systemctl start zkweb-demo sudo systemctl start zkweb-mvvm-demo # 查看服务日志 sudo journalctl -u zkweb-home sudo journalctl -u zkweb-demo sudo journalctl -u zkweb-mvvm-demo
sudo apt-get install nginx sudo systemctl enable nginx sudo systemctl start nginx
sudo vi /etc/nginx/sites-enabled/default sudo systemctl restart nginx
内容:web
server { listen 80; server_name zkweb.app.compiv.com; location / { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 80; server_name zkweb-demo.app.compiv.com; location / { proxy_pass http://localhost:5001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 80; server_name zkweb-mvvm-demo.app.compiv.com; location / { proxy_pass http://localhost:5002; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install python-certbot-nginx
证书会经过 nginx 模块自动经过认证 (文件路径形式) 与签发。docker
sudo certbot --nginx -d zkweb.app.compiv.com sudo certbot --nginx -d zkweb-demo.app.compiv.com sudo certbot --nginx -d zkweb-mvvm-demo.app.compiv.com
sudo certbot renew --dry-run
经过以上方式安装 certbot 之后会自动注册定时器,用于自动更新 ssl 证书,如下命令能够用来确认定时器的状态。npm
sudo systemctl list-timers certbot.timer
以上就完成部署了,这个部署流程基本上是写给本身看的,若是您有基于 zkweb 的网站也能够拿来参考。
虽然很想用 docker 部署,可是服务器费用相差太大了。ubuntu