CentOS7 Deploying a net core application

Source: Internet
Author: User

1 upload the published. NET Core program FTP to the/home/netcore directory and execute the following command

Dotnet WebMVC.dll

  

2. Test whether the program is running properly

Curl http://localhost:5000

  

3. Configure Nginx

/etc/nginx/nginx.conf

User nginx;worker_processes auto;error_log/var/log/nginx/error.log;pid/run/nginx.pid;# Load dynamic modules. see/usr/share/nginx/readme.dynamic.include/usr/share/nginx/modules/*.conf;events {worker_connections 1024;} HTTP {log_format main ' $remote _addr-$remote _user [$time _local] "$request" ' $status $body _by    Tes_sent "$http _referer" "$http _user_agent" "$http _x_forwarded_for";    Access_log/var/log/nginx/access.log main;    Sendfile on;    Tcp_nopush on;    Tcp_nodelay on;    Keepalive_timeout 65;    Types_hash_max_size 2048;    Include/etc/nginx/mime.types;    Default_type Application/octet-stream;    # Load Modular configuration files from THE/ETC/NGINX/CONF.D directory.    # See Http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include/etc/nginx/conf.d/*.conf;# server {# listen default_server;# listen [::]: default_server;# server_name _;# root/usr/share/nginx/html;       # Load configuration files for the default server block.# include/etc/nginx/default.d/*.conf;# location/{#            Proxy_pass http://localhost:5000;# proxy_http_version 1.1;#}# error_page 404/404.html;#        Location =/40x.html {#}# Error_page-502 503 504/50x.html;# location =/50x.html {#        }#}# Settings for a TLS enabled server.## server {# Listen 443 SSL HTTP2 default_server;#        Listen [::]:443 SSL http2 default_server;# server_name _;# root/usr/share/nginx/html;## Ssl_certificate "/ETC/PKI/NGINX/SERVER.CRT"; # Ssl_certificate_key "/etc/pki/nginx/private/server.key"; # s Sl_session_cache shared:ssl:1m;# ssl_session_timeout 10m;# ssl_ciphers high:!anull:! md5;# ssl_prefer_server_ciphers on;## # Load configuration FIles for the default server block.# include/etc/nginx/default.d/*.conf;## location/{#}## E            Rror_page 404/404.html;# location =/40x.html {#}## Error_page-502 503 504/50x.html;# Location =/50x.html {#}#}}

/etc/nginx/conf.d/default.conf

server {    listen;    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;    }}

Execution:nginx–s reload make it effective immediately, access http://192.168.1.107

This problem is caused by the SELinux protection mechanism and we need to add nginx to the SELinux whitelist.

Next we have some commands to solve this problem.

Yum Install policycoreutils-/var/log/audit/audit.log | grep Nginx | grep denied | Audit2allow-i mynginx.pp

Try to access again.

------------------------------------Installing the Supervisor--------------------------------------------------------------

Installation

Yum Install python-setuptoolseasy_install Supervisor

Configuration

mkdir/etc/supervisorecho_supervisord_conf >/etc/supervisor/supervisord.conf

Restart Supervisor Service  

$ supervisorctl Reread

If you restart the error: Error: <class ' Socket.error ';, [Errno 111] Connection refused:file:/usr/lib64/python2.6/socket. PY line:567

The service has not been started and is started first:

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

If you modify/etc/supervisor/supervisord.conf, you need to perform supervisorctl reload to reload the configuration file, otherwise it will not take effect.

Configure Supervisor Boot:

----------------------------supervisord.conf Configuration Instructions------------------------------------------------------------------------- ------
File=/tmp/supervisor.sock; Socket file path, supervisorctl with XML_RPC and Supervisord communication is through it; Of If not set, Supervisorctl can not be used without setting, the default is None. Not necessary to set; chmod=0700; The permission to modify the socket file above is 0700; if not set, the default is 0700. Not necessary to set; Chown=nobody:nogroup; Modify the above socket file belongs to the group of User.group; If not set, the default is the user and the group that started the Supervisord process. Not necessary to set; Username=user; When using the SUPERVISORCTL connection, the authenticated user. If not set, the default is no user is required. ;p assword=123 must not be set; And the above user name corresponding password, you can directly use the plaintext, you can also use SHA encryption; such as: {sha}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d; default not set ... must not be set; [Inet_http_server]; Socket,web server listening on TCP and remote SUPERVISORCTL all need to use him; If not set, the default is not to open. ;p ort=127.0.0.1:9001 must not be set; This is the listening IP and port, listening for all IPs by: 9001 or *:9001.; This must be set, as long as the above [Inet_http_server] opened, it must be set; username=user; This is the same as the uinx_http_server above. ;p assword=123 must not be set; This one is the same. Must not be set [Supervisord]; this is primarily a definition of some of the parameters of this server-side process Supervisord; This must be set logfile=/tMp/supervisord.log; This is the log path of the Supervisord this main process, note and the log of the child process does not match GA.; The default path $cwd/supervisord.log, $CWD is the current directory: LOGFILE_MAXBYTES=50MB must not be set; This is the maximum size of the log file above, and a new log file will be generated when it exceeds 50M.   When set to 0 o'clock, the file size is not limited; The default value is 50M and must not be set. logfile_backups=10; The number of log files maintained, a new file is generated when the above log file is greater than 50M.                           File, the number is greater than 10 o'clock, the original old file is overwritten by the new file, the number of files will remain at 10, and when set to 0 o'clock, the number of files is not limited. ; 10 ... by default ... Loglevel=info must not be set; Log level, with critical, error, warn, info, debug, trace, or blather, etc.; default is info, not required to set the item Pidfile=/tmp/super Visord.pid; supervisord's pid file path. The default is $cwd/supervisord.pid ... Nodaemon=false must not be set; If the True,supervisord process will be running in the foreground; The default is false, which is to run the daemon ...                   minfds=1024 must not be set; This is the minimum system idle file descriptor, below which supervisor will not start. The system file descriptor is set here Cat/proc/sys/fs/file-max ; 1024 ... by default ... MINPROCS=200 must not be set; minimum available process descriptor, lowSupervisor will not start properly with this value. Ulimit-u This command, you can see the maximum number of processes for Linux users, and the default is 200. umask=022; The mask for the process creation file defaults to 022:                user=chrism; This parameter can be set to a non-root user when we start Supervisord with the root user. The user I set up here can also manage Supervisord ; default is not set. Identifier=supervisor; This parameter is the identifier of the Supervisord, mainly for XML_RPC. When you have multiple; supervisor, and want to call XML_RPC Unified management, you need to set a different identifier for each; Supervisor the default is Supe Rvisord. Non-required settings;d irectory=/tmp; This parameter is used when the Supervisord is running as a daemon, set this parameter to start; Before the Supervisord process, it will switch to this directory first; Default Not set ... Not necessary to set; nocleanup=true; When this parameter is false, the previous child process will be supervisord when the process is started; The resulting log file (in the case of auto) is cleared out. Sometimes we want to see the history log, when; Do not want the log to be cleared. So it can be set to true; The default is False, students with debugging needs can be set to true ... Not necessary to set; childlogdir=/tmp; When the child process log path is auto, the path of the child process log file is stored.; The default path is this thing, execute the following command to see just OK, handle the thing on the default path; Python-c "Import Tempfile;print tEmpfile.gettempdir () ", not must be set; environment=key=" value "; This is used to set the environment variables, Supervisord in Linux to start the default inherited Linux; Environment variables, where you can set other environment variables that are specific to the supervisord process.; Supervisord when a child process is started, the child process copies the contents of the parent process's memory space. So set the; These environment variables are also inherited by the quilt process.; Default is not set ... strip_ansi=false; This option, if set to True, clears all ANSI sequences in the child process log. The default is False ... must not be set; The below section must remain with the config file for RPC; (Supervisorctl/web interface) to work, additional interfaces; Added by defining them in separate rpcinterface:sections [rpcinterface:supervisor]; This option is for XML_RPC, Of course, if you want to use Supervisord or Web server This option must be turned on supervisor.rpcinterface_factory = Supervisor.rpcinterface:make_main_ Rpcinterface [Supervisorctl]; This is mainly for the supervisorctl of some configuration serverurl=unix:///tmp/supervisor.sock;  This is the local UNIX socket path when Supervisorctl Local connection Supervisord, note that this is corresponding to the previous [Unix_http_server]; The default value is UNIX:///TMP/SUPERVISOR.SOck. Not necessary to set; serverurl=http://127.0.0.1:9001; This is the TCP socket path used by supervisorctl remote connection Supervisord; Note that this corresponds to the previous [Inet_http_server]. The default is http://127.0.0.1:9001 ... Non-essential items; username=chris; User name, default null: ;p assword=123 must not be set; Password default null: ;p Rompt=mysupervisor must not be set; Enter the user name password when the prompt default supervisor. Not necessary to set; history_file=~/.sc_history; This parameter is similar to the history in the shell, we can use the up and down keys to find the previous executed command, the default is no file: So we want to have this function, must specify a file ... must not be set; The below sample program sections shows all possible program subsection values,; Create one or more ' real ' program:sections to is able to control them under;  Supervisor. ; [Program:theprogramname]; This is the sub-process we are going to manage, ":" followed by a name, preferably with the actual process is a little related to the best. Such a program we can set one or more, a program is to be managed by a process; command=/bin/cat; This is our command path to start the process, can take parameters; One thing to note is that our command can only be the kind of process that runs at the terminal and cannot be; Daemon process. For example Command=service httpd start.;           HTTPD This process is managed by the Linux service, our supervisor to start the command again.         ; This is no longer a strictly sub-process. This is an item that must be set;p rocess_name=% (program_name) s; This is the process name, if we have the following numprocs parameter is 1, it is not necessary to control this parameter; , it defaults to% (program_name) s, which is the name of the program colon that follows it; But if Numprocs is more than one, then you can't do it.; Numprocs=1; The number of start processes. When not 1 o'clock, is the concept of the process pool, note that the Process_name setting defaults to 1. ;d irectory=/tmp must not be set; Before the process runs, switch to this directory before the session. Default not set ... Not necessary to set; umask=022; Process mask, default none, must not;p riority=999; The child process starts off priority, low priority, starts first, closes at the end. The default value is 999: Not necessary to set; autostart=true; If true, the child process will be started automatically after the Supervisord is started. The default is true: Not necessary to set; autorestart=unexpected; This is the setting of the child process after the automatic restart of the situation, there are three options, false,unexpected; and true. If False, no matter what the circumstances, will not be restarted; If for unexpected, only if the exit code of the process is not defined in the exitcodes below; When the code is out, it will be restarted automatically. When true, as long as the child process hangs, it will be unconditionally restarted; Startsecs=1; This option is how many seconds after the child process is started, if the state is running, we think the boot was successful; The default value is 1. Not necessary to set; startretries=3; The maximum number of attempts to start when a process fails to start: When more than 3 times, supervisor will set the status of this process to fail; The default value is 3. must not be set; Exitcodes=0,2; Note The autorestart=unexpected corresponds to the above: The definition of exitcodes inside; The exit code is expected.; stopsignal=quit; Process stop signal, can be term, HUP, INT, QUIT, KILL, USR1, or USR2 signal; The default is term: When using the set signal to kill the process, the exit code will be considered to be expected not must set; stopwaitsecs=10; This is when we send the stopsignal signal to the child process, to the system return information; To Supervisord, the maximum time to wait. Over this time, Supervisord will send a forced kill signal to the child process.; The default is 10 seconds. Not necessary to set; Stopasgroup=false; This thing is mainly used in the Supervisord management of the sub-process, the child process itself; Child process. So if we just kill Supervisord's child process, the subprocess of the child process; It could turn into an orphan process. So we can set an option to put the whole child process in; The entire process group is killed. If set to true, the general Killasgroup will also be set to true. It is important to note that the option is to send a stop signal; The default is false: Not required to set ...; killasgroup=false; This is similar to the above Stopasgroup, but sends a kill signal; user=chrism; If Supervisord is root, we set up this non-root user here, can be used to manage the program, not set by default ... Non-mandatory set of items; redirect_stderr=true; If true, the stderr log is written to the stdout log file by default to False, which must not be set; Stdout_logfile=/a/path; The stdout log path of the child process, which can be specifiedPath, Auto,none, etc. three options.; If set to None, no logs will be generated. Set to Auto, you will find a random place; Generate log files, and when Supervisord restarts, the previous log files will be; Empty. When the Redirect_stderr=true, Sterr will also be written into this log file; stdout_logfile_maxbytes=1mb; The maximum size of the log file, as defined in [Supervisord]. The default is stdout_logfile_backups=10; As defined by [Supervisord]. Default of ten; STDOUT_CAPTURE_MAXBYTES=1MB; This thing is to set the size of the capture pipeline, when the value is not 0, the child process can send information from stdout, and supervisor can be based on information, send the corresponding event. The default is 0, which is 0 when the expression closes the pipe, not the required item; stdout_events_enabled=false; When set to Ture, when the child process is written by stdout to the file descriptor, the event triggering Supervisord send the Process_log_stdout type will default to False ... Not necessary to set; Stderr_logfile=/a/path; This thing is set stderr to write the log path when redirect_stderr=true. This does not have to be set up, set up is useless. Because it will be written to the same file in Stdout_logfile; The default is auto, that is to find a place to save, Supervisord restart is emptied. STDERR_LOGFILE_MAXBYTES=1MB, stderr_logfile_backups=10, STDERR_CAPTURE_MAXBYTES=1MB, and Stdout_capture. Default is 0, off state; stderr_events_enabled=false; The default is false; Environment=a= "1", b= "2"; The environment variable for the subprocess, and the other child processes are not shared; sErverurl=auto; ; The below sample EventListener section shows all possible; EventListener subsection values, create one or more ' real '; Eventlistener:sections to being able to handle event notifications;  Sent by supervisor. ; [Eventlistener:theeventlistenername]; this thing is actually the same as program's status, but also Suopervisor initiates the sub-process, but it does the job is to subscribe Supervisord send the event. His name is called; listener. We can do a series of processing in listener, such as alarm and so on; Command=/bin/eventlistener; This, like the program above, represents the path to the listener executable file;p rocess_name=% (program_name) s; This is the same, the process name, when the following numprocs for multiple times, only need. Otherwise, the default is yes; Numprocs=1; The same number of listener starts; events=event; Event type, that is, only the type of event written in this place. will be sent; buffer_size=10; This is the event queue cache size, the unit is not very clear, landlord guess should be a bar. When buffer exceeds 10, the oldest event is cleared and the new event is put in. The default value is 10: Non-mandatory option;d irectory=/tmp; Before the process executes, it switches to this directory and executes the default to not switch ... Non-essential; umask=022; The default is none, do not say;p riority=-1; Start priority, Default-1, no tear; autostart=true; Whether to start with Supervisord startup, by default true; autorestart=unexpected; Whether to restart automatically, and program the same, sub-true,false,unexpected, etc., pay attention to unexpectedThe relationship with Exitcodes; Startsecs=1; Also, the process started running for a few seconds before it was identified as a successful start, default 1; startretries=3; The maximum number of failed attempts, default 3; exitcodes=0,2; Expected or expected process exit code; stopsignal=quit; Kill process Signal, default to term, such as set to quit, then if quit to do this process will be considered as normal maintenance, exit code is also considered expected; stopwaitsecs=10; Max num secs to wait b4 SIGKILL (default); stopasgroup=false; Send stop signal to the UNIX process group (default false); killasgroup=false; SIGKILL the UNIX process group (def false); user=chrism; sets a normal user that can be used to manage the listener process. Default is empty: Not necessary to set; redirect_stderr=true; If true, stderr log will be merged into STDOUT log with the default of false ...  Stdout_logfile=/a/path, STDOUT_LOGFILE_MAXBYTES=1MB, stdout_logfile_backups=10, stdout_events_enabled=false, not required; Stderr_logfile=/a/path; stderr_logfile_maxbytes=1mb; stderr_logfile_backups; stderr_events_enabled=false; environ Ment=a= "1", b= "2"; This is the child process environment variable default is empty ... Not necessary to set; Serverurl=auto; Override ServerURL computation (childutils); The below Sample group section shows all possible group values,; Create one or more ' real ' group:Sections to create "heterogeneous";  Process groups. ; [Group:thegroupname]; this thing is to group the programs, divided into the program within the group. We don't have to do it one at a-we can do a uniform operation on the group name. Note: Program is divided into the group, the equivalent of the original, the configuration from the Supervisor profile disappeared ... Supervisor will only manage the group, but not the individual program within the group;p rograms=progname1,progname2; Group members, separated by commas this is a necessary set of items;p riority=999; The priority, relative to the group and the group, is said to be the default of 999. Non-mandatory option; The [include] section can just contain the "files" setting. this; Setting can list multiple files (separated by whitespace or; newlines). It can also contain wildcards. The filenames is; interpreted as relative to the this file. Included files *cannot*;  Include files themselves. ; [include]; this thing is very useful, when we want to manage a lot of process, write in a file is a bit big.   We can write configuration information to multiple files and include them; files = Relative/directory/*.ini

  

CentOS7 Deploying a net core application

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.