Steps in. Net Core deployment to a CentOS7 64-bit system

Source: Internet
Author: User
Tags dotnet

. Net Core deployment to CentOS7 Position system the steps in

It is recommended to use the root Administrator account operation

1. Installation Tools

1.Apache

2.. Net Core (dotnet-sdk-2.0)

3,Supervisor ( Process Management tool , the purpose is to start the server on the launch of the ASP. Net Core Web site published on the server)

2. Installing Apache

Before installing Apache , the first thing to do is to set the current login user rights to the same root permissions, or execute sudo The command will be reported as " not in the sudoers file." This matter will be reported . "

The current logon user right is set to root with the same permissions as the following:

Su Root

sudo vim/etc/sudoers

in the Vim editor window of the VIM command , locate the following line:

Root all= (All:all) all

add your own account below, such as Linjie all= (All:all) All, add the following files:

Root all= (All:all) all

Linjie all= (All:all) all

Click ESC Input: Re-enter wq! So that it can be saved back out, and then

Su Linjie switch to his account, you can use sudo to execute the command.

after the above setup is complete, install Apache below (three steps)

1. Enter the command in the terminal: yum install httpd

2, configuration ServerName(can be omitted) vi/etc/httpd/conf/httpd.conf

If there is no domain name, then: ServerName localhost:80 or ServerName 127.0.0.1:80

3.Apache service added to boot

Systemctl Start httpd

Systemctl Enable httpd

Enter http://localhost or http://127.0.0.1in the browser, if you see testing 123. , it means Apache Has been successfully installed.

The configuration files for the services in the Linux system, and the storage locations are as follows :

Service Catalog/ETC/HTTPD

Master configuration file/etc/httpd/conf/httpd.conf

Website Data Catalog/var/www/html

Access Log/var/log/httpd/access_log

Error log/var/log/httpd/error_log

master configuration file: vim/etc/httpd/conf/httpd.conf

The most commonly used parameters in the HTTPD service program master configuration file are:

ServerRoot Service Catalog

ServerAdmin Admin Mailbox

user running the service

Group of users running the service

ServerName The domain name of the Web server

DocumentRoot website Data Catalog

Listen Listening IP address and port number

DirectoryIndex The default index page page

Errorlog error log file

Customlog access log files

Timeout page time-out , default is seconds .

Include Additional files that need to be loaded

from the table above, you can learn DocumentRoot is precisely used to define the site data save path parameter, the default value of its parameters is to store the Web site data in the /var/www/html directory, and the name of the site home page should be called Index.html, so you can manually write a file to this directory to replace The Default Web page of the HTTPD service program .

3.install . NET Core 2.0

1. Registering a Linux system (Cent OS 7)

sudo rpm--import https://packages.microsoft.com/keys/microsoft.asc

sudo sh-c ' echo-e ' [Packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https:// packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https:// Packages.microsoft.com/keys/microsoft.asc ">/etc/yum.repos.d/dotnetdev.repo"

2.Update the installation package, install the . NET Core

sudo yum update

sudo yum install libunwind Libicu

sudo yum install dotnet-sdk-2.1.4

4.Check dotnet--version The result is 2.1.4 the installation is successful.

(Note: The Simple Application project folder, start the Web site with the following command, as long as open the publishing site files, right-click Terminal Open dotnet run or dotnet xx.dll, can be shipped, xx is the name of the site)

sudo dotnet Xxx.dll

then you can open it in the browser using the actual IP and port access (mmps port is set to 8080)

Note the problems that this process may encounter:

question 1

If the extranet cannot access the 8080 port (the port is the access port in the program), set the following

1,sudo firewall-cmd--zone=public--add-port=8080/tcp--permanent

2,firewall-cmd--reload

Question 2

If you open the browser, can not open, is the network problem,

1. View more information

2, click on the identity - Check the automatic connection, click Apply.

To this location is basically achieved through IP access , but after each shutdown, the reboot will need to manually start publishing the site project to access, so we use the Supervisor managed Autostart Web service operation, Ensure that the site can be normal every time you start a boot.
3, install the Supervisor (set the power on automatic setting website)

1. Right-click in the terminal to open, enter the installation command :

Installing Python 's supervisor

Yum Search Setuptools

sudo yum install-y python-setuptools.noarch

Easy_install Supervisor

2, after the installation is complete , create the relevant files ,

The first type:

To create a supervisor configuration file directory

sudo mkdir/etc/supervisor

Creating a master configuration file

Echo_supervisord_conf >/etc/supervisor/supervisord.conf

If you are prompted for insufficient permissions,

Su Root

Echo_supervisord_conf >/etc/supervisor/supervisord.conf

Create a Project Profile directory CONF.D

cd/etc/supervisor/

sudo mkdir conf.d

Create a project configuration file under File directory CONF.D (Start-up web site)

sudo vim conf.d/mmpscore.conf (after editing is complete, press ESC, press: Colon, and then enter wq!). , which can be exited)

The second type:

echo_supervisord_conf > supervisord.conf

sudo mkdir/etc/supervisor

sudo mkdir/etc/supervisor/conf.d

sudo cp supervisord.conf/etc/supervisor/supervisord.conf

Note:1./tmp in supervisord.conf is replaced by the corresponding /var/run or /var/log

( using sudo chmod a+w etc/supervisor/supervisord.conf can be opened for editing,/tmp for the corresponding /var/run or /var/log after replacement, save )

2, the supervisord.conf in the

; [include] node at

; files = Relative/directory/*.ini

Into

[include]

Files =/etc/supervisor/conf.d/*.conf

3, the configuration file, named mmpscore.conf ( the name of the current project )

sudo touch/etc/supervisor/conf.d/mmpscore.conf (custom project name, this item is mmpscore.conf)

Open Mmpscore.conf writes the following command ( If there is no permission,

Please use the following method

sudo chmod a+w/etc/supervisor/conf.d/mmpscore.conf (Command start Edit)

The command contents are as follows:

[Program:mmpscore]

Command=dotnet MmPSCore.dll # command to execute (Publish Web site execution file)

directory=/home/xx/mmpscore# Command Execution directory (publish Web site file path) environment=aspnetcore__environment=production # environment variable

User=www-data # user identity of the process execution (may need to be removed)

Stopsignal=int

Autostart=true # whether to start automatically

Autorestart=true # Whether to restart automatically

Startsecs=1 # Automatic restart interval

User=root; # The user identity of the process execution (can not be written)

Stderr_logfile=/var/log/testcore.err.log # standard error log

Stdout_logfile=/var/log/testcore.out.log # Standard output log

Note:# After the content is a comment, when saving the above file code , remember to delete

After the above operation is done, save,

run Supervisordto see if it takes effect, execute the following command:

Supervisord-c/etc/supervisor/supervisord.conf

Ps-ef | grep ProjectName

Return

Root 27007 27006 1 13:21? 00:00:02 dotnet ProjectName.dll

Root 27026 26810 0 13:23 pts/0 00:00:00 grep--color=auto ProjectName

Indicates a successful run!

If there is an error, it is recommended to execute the following command

This two-sentence order is important.

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

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

4. Configure Supervisord Boot

    1. create a file under the specified directory supervisord.service

sudo touch/usr/lib/systemd/system/supervisord.service

sudo chmod a+w usr/lib/systemd/system/supervisord.service

B. Enter the following:

[Unit]

Description=supervisor Daemon

[Service]

Type=forking

Execstart=/usr/bin/supervisord-c/etc/supervisor/supervisord.conf

Execstop=/usr/bin/supervisorctl shutdown

Execreload=/usr/bin/supervisorctl Reload

Killmode=process

Restart=on-failure

Restartsec=42s

[Install]

Wantedby=multi-user.target

Save and exit

C. execute the following command:

Systemctl Enable Supervisord

Tips:

Created symlink From/etc/systemd/system/multi-user.target.wants/supervisord.service to/usr/lib/systemd/system/ Supervisord.service.

D. Verify that the boot is on:

Systemctl is-enabled Supervisord

Tips:

Enabled

Indicates a successful setup!

This completes the creation of the Supervisor Daemon.

5. Testing

then restart the machine, enter in the browser IP Address to see if the website follows the boot automatically .

Steps in. Net Core deployment to a CentOS7 64-bit system

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.