https://dotnet.microsoft.com/download/dotnet-core/3.1
mkdir -p /var/lib/dotnet
1.3 把壓縮包上傳Linux,解壓到/var/lib/dotnet目錄
tar zxf aspnetcore-runtime-3.1.1-linux-x64.tar.gz -C /var/lib/dotnet
1.4 創建軟鏈接方式來設置環境變量
ln -s /var/lib/dotnet/dotnet /usr/local/bin
dotnet --info
mkdir /home/www
2.2 通過FTP等工具將VS打包好的部署包上傳到該目錄
cd /home/wwww
dotnet AspNetCoreDeployDemo.dll
2.4 網頁測試或者命令行測試能否打開該地址,如果打不開,請檢查
wget http://localhost:5000
這時候,窗口不能關閉,如果關閉就訪問不到,下面要使用suppervisor或者systemd等工具進行后台守護進程。
cd /app/supervisor
./run_supervisor.sh
3.2 查看supperisor運行狀態
3.3 查看配置文件,並把后台界面端口關閉,可以看到會加載supervisord/下面的ini配置文件
#項目名 [program:demo] #腳本目錄 directory=/home/wwww #腳本執行命令 command=dotnet AspNetCoreDeployDemo.dll #環境變量 environment=ASPNETCORE_ENVIRONMENT=Production #用戶 user = root #進程數 numprocs=1 #supervisor啟動的時候是否隨着同時啟動,默認True autostart=true #當程序exit的時候,這個program不會自動重啟,默認unexpected,設置子進程掛掉后自動重啟的情況,有三個選項,false,unexpected和true。如果為false的時候,無論什么情況下,都不會被重新啟動,如果為unexpected,只有當進程的退出碼不在下面的exitcodes里面定義的 autorestart=false #這個選項是子進程啟動多少秒之后,此時狀態如果是running,則我們認為啟動成功了。默認值為1 startsecs=1 #把stderr重定向到stdout,默認 false redirect_stderr = true #stdout日志文件大小,默認 50MB stdout_logfile_maxbytes=10 #stdout日志文件備份數 stdout_logfile_backups=10 #日志輸出 stderr_logfile=/app/supervisor/logs/demo/log_error.log
supervisorctl reload
3.6啟動程序
supervisorctl start demo
supervisord -v 查看版本號 supervisorctl 查看正在守候的進程 supervisorctl start <application name> 啟動指定應用 supervisorctl stop <application name> 停止指定應用 supervisorctl restart all 重啟所有應用 supervisorctl stop all 停止所有應用 supervisorctl start all 啟動所有應用
yum install -y nginx-1.16.1-1.el7.ngx.x86_64.rpm
service nginx start
#或者
systemctl start nginx.service
systemctl enable nginx.service
nginx -v
service nginx status
systemctl status nginx.service
vi /etc/nginx/conf.d/demo.conf server { listen 80; 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; } }
nginx -s reload