ASP. Net core system deployed to CENTOS7 64 specific scenarios

Source: Internet
Author: User
Tags chmod configuration settings dotnet
ASP. Net core system deployed to CENTOS7 64 specific scenarios steps for. Net Core deployment to CentOS7 64-bit Systems

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

The first thing to do before you install Apache is to set the current logon user right to the same permissions as root, otherwise you will report "not in the sudoers file" When you execute the sudo command. The matter will be reported. "

Two ways to resolve permissions problems

1, the first way

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

Su Root

sudo vim/etc/sudoers

In the Vim edit 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, and add later files as follows:

Root all= (All:all) all

Linjie all= (All:all) all

Click ESC Input: Re-enter Wq. So you can save the exit, and then

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

2. The first way to use sudo directly

After the above settings are complete, Apache (three-step operation) is installed below

1, in the Terminal Input command: Yum install httpd or (sudo yum install httpd)

2, the configuration servername (may omit) 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 from Qingzhong

Systemctl Start httpd

Systemctl Enable httpd

Enter http://localhost or http://127.0.0.1 in the browser, and if you see testing 123 ... That means Apache is successfully installed.

The configuration files for the services in the Linux system, and where they are stored:

Service Catalog/ETC/HTTPD

Primary configuration file/etc/httpd/conf/httpd.conf

Web site Data Directory/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 master configuration file include:

ServerRoot Service Directory

ServerAdmin Administrator Mailbox

User who is running the service

Group of users running services

ServerName the domain name of the Web server

DocumentRoot Web site Data Directory

Listen the IP address and port number of the listener

DirectoryIndex The default index page page

ErrorLog error log file

Customlog Access log files

Timeout page timeout, defaults to 300 seconds.

Include additional files that need to be loaded

As you can see from the table above, DocumentRoot is exactly the parameter used to define the path of the site data save, and the default value of the parameter is to store the Web site data in the/var/www/html directory. The name of the home page should be called index.html, so you can manually write a file to this directory to replace the HTTPD service program's default page.

3, installation. NET Core 2.0

1, Registered 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, installation. NET Core

sudo yum update

sudo yum install libunwind Libicu

sudo yum install dotnet-sdk-2.1.4

Note: The above registration and installation can refer to

Https://www.microsoft.com/net/learn/get-started/linux/centos

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 the use of actual IP and port access in the browser (MMPs port set is 8080)

Note the problems that this process may encounter:

Question 1

If the extranet cannot access port 8080 (: This 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 and can't open it, it's a network problem.

1, view the detailed information

2, click Identity--Check automatic connection, click Application.

To this location is basically achieved through IP access, however, each shutdown, restart all need to manually launch the release of the website project to access, so we use Supervisor managed to start the Web site service operation, to ensure that every time as long as a boot, the site can be normal.
3, install Supervisor (set up automatically set up the website)

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

Install the Python supervisor

Yum Search Setuptools

sudo yum install-y python-setuptools.noarch

sudo easy_install supervisor

2, after the installation is completed, create the relevant documents,

First type:

To create the Supervisor configuration file directory

sudo mkdir/etc/supervisor

To create a primary configuration file

Echo_supervisord_conf >/etc/supervisor/supervisord.conf

If you do not have sufficient prompting permissions,

Su Root

Echo_supervisord_conf >/etc/supervisor/supervisord.conf

Create the Project Profile directory CONF.D

cd/etc/supervisor/

sudo mkdir conf.d

Create a Project Profile (boot-initiated web site) under File directory CONF.D

sudo vim conf.d/mmpscore.conf (after editing completes, press ESC, press: Colon, and then enter Wq.) , that is, you can exit)

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 to the corresponding/var/run or/var/log

(with sudo chmod a+w etc/supervisor/supervisord.conf can be opened for editing,/tmp replaced by the corresponding/var/run or/var/log Replace, save)

2, the supervisord.conf in the

; At the [include] node

; files = Relative/directory/*.ini

Into

[include]

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

3, 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 Write the following command (if you do not have permission,

Please use the following methods

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

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 #进程执行的用户身份 (may need to be removed)

Stopsignal=int

Autostart=true #是否自动启动

Autorestart=true #是否自动重启

Startsecs=1 #自动重启间隔

User=root; #进程执行的用户身份 (Can not write)

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

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

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

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

After the operation is finished, save,

Run Supervisord to see if it takes effect and execute the following command:

Once configured, you will need to reload the configuration

Supervisord-c/etc/supervisor/supervisord.conf (start)

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 that the operation was successful.

If there are errors, it is recommended that the following command be executed

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 startup to create files 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 content:

[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 starts:

Systemctl is-enabled Supervisord

Tips:

Enabled

Indicates that the setting was successful.

At this point, the Create Supervisor daemon is complete.

5, testing

Next reboot the machine, enter the IP address in the browser, and see if the website will follow the boot autorun.

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.