Linux+asp.net Core+nginx+sql Server

Source: Internet
Author: User
Tags dotnet



Linux Disibutaion:ubuntu 16.04.1 LTS



Web Server:nginx, Kestrel


    • Install the. NET Core
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




    • Installing Nginx
#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




    • Installing Supervisor


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




    • Installing SQL Server


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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.