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 417A0893
Sudo apt-get update
#Install .NET Core SDK
# Since my local VS installed .Net Core version is: dotnet-dev-1.0.0-preview2-003131, so the .Net Core installed in linux needs to be consistent
Sudo apt-get install dotnet-dev-1.0.0-preview2-003131
- Installing Npm,gulp,bower
sudo apt-get install npm
sudo npm install gulp -g
sudo npm install bower -g
#installnginx
Sudo apt-get install nginx -y
#Start nginx
Sudo service nginx start
Because to use Nginx to do the reverse proxy of ASP. NET Core website, we need to modify Nginx default profile/etc/nginx/sites-available/default, replace the following content with the default configuration:
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;
}
}
To save the rollout, execute the following command:
#check if nginx configuration is zhengque
Sudo nginx -t
#reload nginx configuration
Sudo nginx -s reload
The site we deploy does not start and run on its own, and here we need to use the Supervisor tool to ensure that the site starts and continues to run.
#Install supervisor
Sudo apt-get install supervisor
Configure supervisor, go to directory (/etc/supervisor/conf.d/), create a new profile hwapp.conf, copy the following to the file
[program:hwapp]
command=/usr/bin/dotnet /var/hwapp/hwapp.dll --server.urls:http://*:5000
directory=/var/hwapp
autostart=true
autorestart=true
stderr_logfile=/var/log/hwapp.err.log
stdout_logfile=/var/log/hwapp.out.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopsignal=INT
Start Supervisor
sudo service supervisor Start
Import the public repository GPG keys:
Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | sudo apt-key add-
Sign up for the Microsoft SQL Server Ubuntu repository:
Curl Https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee/etc/apt/sources.list.d/mssql-server.list
Installing SQL Server
sudo apt-get update
sudo apt-get install -y mssql-server
Configuring SQL Server
Sudo/opt/mssql/bin/sqlservr-setup
Verify that SQL Server is started
Systemctl Status Mssql-server
Installing the SQLCMD Tool
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.list
sudo apt-get update
sudo apt-get install mssql-tools
Here, our environment is ready to operate SQL Server on Linux
I am here in local vs wrote an ASP. NET core demo to operate SQL Server installed on Linux.
The data on the home page is taken from the database, see:
SOURCE download
Linux+asp.net Core+nginx+sql Server