1.對后端項目打包,我使用的時rider
?
?
2.打包前端? npm run build
3.在iis上部署? 網站-添加網站
4.選擇之前打包的后端文件,設置端口
?
5.安裝對應net環境插件:主要是runtime和sdk插件以及dotnet-hosting-2.2.0-win,具體版本看自己項目的對應版本
?這是缺少插件的報錯
?
6.安裝好插件后啟動下iis后端
?
?
?后端啟動成功
7.配置nginx下的nginx.conf
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {client_max_body_size 300m;include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 8030;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;gzip on;gzip_min_length 1k;gzip_comp_level 9;gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;gzip_vary on;gzip_disable "MSIE [1-6]\.";gzip_buffers 32 4k;gzip_static on;location / {root D:\deployment\WithinHospReviewFE; #對應前端地址index index.html index.htm;# 用于配合 browserHistory使用 try_files $uri $uri/ /index.html;}location ~ /api/ {rewrite ^.+apis/?(.*)$ /$1 break;include uwsgi_params;proxy_connect_timeout 600s;proxy_send_timeout 600s;proxy_read_timeout 600s;proxy_pass http://192.168.2.4:7070; #對應發布之后部署到iis的后端api地址}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:8091##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
配置好后,對外的訪問ip地址即為:https://blog.csdn.net/qq_46636081/article/details/149015799?spm=1001.2014?
8.常見問題:
8.1.缺少net核心插件
?8.2.nginx配置錯誤,比如我之前在nginx配置時,配置前端項目路徑時有中文目錄,需要將中文目錄修改為英文目錄
8.3.nginx啟動失敗,nginx啟動后可以自己在任務管理器中查看下,是否啟動成功,有時啟動后nginx會秒掛掉
?
9.IIS安裝
https://blog.csdn.net/qq_46636081/article/details/149015799?spm=1001.2014?