编译和部署

dx build --release

对于需要指定环境变量的 dioxus web 项目,需要加上环境变量:

变量1=值1 变量2=值2 dx build --release

比如,本专题中的阅后即焚项目,用到了 APP_URL 环境变量:

APP_URL='https://dx-msg.ace.dpdns.org' dx build --release

编译完成后,会显示最终编译之后,输出的目录,将该目录上传到服务器即可。

部署到 NGINX

如果使用了路由,那么加上以下指令:

以下是一个示例代码:


server {
        listen 80;
        server_name dx-msg.ace.dpdns.org;
        location / {
                return 301 https://$http_host$request_uri;
        }

}

server {
        listen  443 ssl http2;
        server_name dx-msg.ace.dpdns.org;
        root /var/www/dx-msg.ace.dpdns.org;
        index index.html;

        ssl_certificate /opt/ssl/ace.dpdns.org.pem;
        ssl_certificate_key /opt/ssl/ace.dpdns.org.key;
        location / {
                try_files $uri /index.html;
        }

}
要查看完整内容,请先登录