ASP. Net core system deployed to Ubuntu 16.04 specific scenarios

Source: Internet
Author: User
Tags configuration settings dotnet gpg
ASP. Net core system deployed to Ubuntu 16.04 specific scenarios steps for. Net Core deployment to Ubuntu 16.04

1. Installation Tools

1, Apache

2. Net Core (dotnet-sdk-2.0)

3, Supervisor (Process management tools, the purpose is to boot on the server on the server launched on the asp.net Core Web site)

2. Install Apache

To install Apache, enter the command at the command line terminal:

sudo apt-get install apache2

(Note: View Apache version sudo apachectl-v)

Restart the Apache service sudo/etc/init.d/apache2 restart

In the browser to enter http://localhost or http://127.0.0.1, if you see it works!, it means that Apache successfully installed, Apache default installation, will be under the/var to create a directory called WWW, This is the web directory, all the Web files to be able to access the browser will be placed in this directory.

3, installation. NET Core 2.0

1, install the. NET Core 2.0 to the Linux system, and if the preview version is installed, first uninstall the original preview version.

A, the View method, Linux system, the right key run, the input dotnet--version results with Preview is the preview version.

B, uninstall method, Linux system, the right key running end, input sudo apt remove dotnet-sdk-2.0.0-preview3-006729 (including Preview is the preview version) to uninstall the preview version.

2, Registered Linux system (Ubuntu and Debian based systems, different system operation is not the same)

A, Ubuntu 17.10

Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | GPG--dearmor > MICROSOFT.GPG

sudo mv MICROSOFT.GPG/ETC/APT/TRUSTED.GPG.D/MICROSOFT.GPG

sudo sh-c ' echo ' Deb [ARCH=AMD64] Https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main >/ Etc/apt/sources.list.d/dotnetdev.list '

B, Ubuntu 17.04 (Planned EOL by Ubuntu, January 2018)

Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | GPG--dearmor > MICROSOFT.GPG

sudo mv MICROSOFT.GPG/ETC/APT/TRUSTED.GPG.D/MICROSOFT.GPG

sudo sh-c ' echo ' Deb [ARCH=AMD64] Https://packages.microsoft.com/repos/microsoft-ubuntu-zesty-prod zesty Main >/ Etc/apt/sources.list.d/dotnetdev.list '

C, Ubuntu 16.04 (the system)

Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | GPG--dearmor > MICROSOFT.GPG

sudo mv MICROSOFT.GPG/ETC/APT/TRUSTED.GPG.D/MICROSOFT.GPG

sudo sh-c ' echo ' Deb [ARCH=AMD64] Https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main >/ Etc/apt/sources.list.d/dotnetdev.list '

3, update the installation package, installation. NET Core

sudo apt-get update

sudo apt-get install dotnet-sdk-2.1.4

Note: The above registration and installation can refer to https://www.microsoft.com/net/learn/get-started/linux/ubuntu16-04

4, check the dotnet--version result is 2.1.4 the installation is successful.

(Note: A simple Application project folder, use the following command to start the Web site, as long as the file open the publishing site, the right to open the terminal dotnet Run or dotnet Xx.dll, can be shipped, XX for the name of the site)

sudo dotnet Xxx.dll

You can then open localhost:5000 in the browser (5000 is the default port, and if so, use the actual IP and port access)

This is achieved through IP access, however, after the reboot we will find that the site does not boot, this time will need to supervisor
3, install Supervisor (set up automatically set up the website)

1, right key in the terminal open, enter the installation command:

sudo apt-get install Supervisor

2, after installation, in the/ect/supervisor/confg.d/directory to create a new configuration file, named mmpscore.conf (the individual takes the name of the current project)

3, use the command to create a new file:

sudo touch mmpscore.conf

Open mmpscore.conf and write the following command (if you do not have permission, sudo gedit/ect/supervisor/confg.d/mmpscore.conf #编辑命令

):

The contents of the command are as follows:

[Program:mmpscore]

Command=dotnet MmPSCore.dll #要执行的命令 (Publish Web site execution file)

The directory that the directory=/home/xx/mmpscore# command executes (publish Web site file path) environment=aspnetcore__environment=production #环境变量

User=www-data #进程执行的用户身份

Stopsignal=int

Autostart=true #是否自动启动

Autorestart=true #是否自动重启

Startsecs=1 #自动重启间隔

Stderr_logfile=/var/log/testcore.err.log #标准错误日志

Stdout_logfile=/var/log/testcore.out.log #标准输出日志

Note: #后面的内容为注释, when saving the above file code, remember to delete

4. After configuration, you need to reload the configuration

Reload configuration settings After

sudo supervisord-c/etc/supervisor/supervisord.conf service side

sudo supervisorctl-c/etc/supervisor/supervisord.conf Client

Reboot

Supervisor Service

sudo service supervisor Stop

sudo service supervisor Start

5, the next restart the machine, in the browser input localhost:5000, to see whether the Web site following the boot automatically run.

Add:

Apt-get Install curl Hint does not have this software source

Workaround:

sudo add-apt-repository ppa:costamagnagianfranco/ettercap-stable-backports

sudo apt-get update

sudo apt-get Install Curl

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.