標籤:service rest imp upgrade 安裝nginx rod 檔案 etc dem
Linux Disibutaion:Ubuntu 16.04.1 LTS
Web Server:Nginx、Kestrel
sudo sh -c ‘echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list‘sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893sudo apt-get update#Install .NET Core SDK#由於我本地VS安裝的.Net Core版本為:dotnet-dev-1.0.0-preview2-003131,所以在linux中安裝的.Net Core需要保持一致sudo apt-get install dotnet-dev-1.0.0-preview2-003131
sudo apt-get install npmsudo npm install gulp -gsudo npm install bower -g
#安裝nginxsudo apt-get install nginx -y#啟動nginxsudo service nginx start
因為要使用nginx做asp.net core網站的反向 Proxy,我們需要修改nginx的預設設定檔/etc/nginx/sites-available/default ,將以下內容替換預設配置:
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; }}
儲存推出,執行如下命令:
#檢查nginx配置是否zhengquesudo nginx -t#重新載入nginx配置sudo nginx -s reload
我們部署的網站並不會自己啟動並運行,這裡我們就需要用到supervisor這個工具,保證網站的啟動和持續運行。
#安裝supervisorsudo apt-get install supervisor
配置supervisor,進入目錄(/etc/supervisor/conf.d/),建立設定檔hwapp.conf,將如下內容複寫到檔案中
[program:hwapp]command=/usr/bin/dotnet /var/hwapp/hwapp.dll --server.urls:http://*:5000directory=/var/hwappautostart=trueautorestart=truestderr_logfile=/var/log/hwapp.err.logstdout_logfile=/var/log/hwapp.out.logenvironment=ASPNETCORE_ENVIRONMENT=Productionuser=www-datastopsignal=INT
啟動supervisor
sudo service supervisor start
Import the public repository GPG keys:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
註冊Microsoft SQL Server Ubuntu存放庫:
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
安裝SQL Server
sudo apt-get updatesudo apt-get install -y mssql-server
配置SQL Server
sudo /opt/mssql/bin/sqlservr-setup
驗證SQL Server是否啟動
systemctl status mssql-server
安裝sqlcmd工具
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.listsudo apt-get update sudo apt-get install mssql-tools
到此,我們的環境都準備好了,可以在linux上操作SQL Server
我這裡在本地VS寫了一個asp.net core的demo,去操作安裝在linux上的sqlserver。
首頁上的資料就是從資料庫中取出的,見:
源碼下載
linux+asp.net core+nginx+sql server