标签:index linux发行版本 home pass rip params 启动 quit fastcgi
可参见官网安装教程。
Centos/Oracle
添加dotnet的yum仓库配置
$ sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
安装.net SDK
#更新系统软件
sudo yum update
#安装dotnet sdk
sudo yum install dotnet-sdk-2.1
使用dotnet --info
命令显示 .net core 的信息。
可参见官网安装配置教程。
/etc/yum.repos.d/nginx.repo
,并配置为以下内容:[nginx]
name=nginx repo
#baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
#OS为rhel或centos
#OSRELEASE为centos版本,6或7
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
wget nginx.org/keys/nginx_signing.key
rpm --import nginx_signing.key
sudo yum -y install nginx
#服务的说明
[Unit]
#描述服务
Description=nginx
#描述服务类别
After=network.target
#服务运行参数的设置
[Service]
#Type=forking是后台运行的形式
Type=forking
#服务的具体运行命令
ExecStart=/usr/local/nginx/sbin/nginx
#重启命令
ExecReload=/usr/local/nginx/sbin/nginx -s reload
#停止命令
ExecStop=/usr/local/nginx/sbin/nginx -s quit
#PrivateTmp=True表示给服务分配独立的临时空间
PrivateTmp=true
#运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3
[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
#启动nginx服务
systemctl start nginx.service
#停止开机自启动
systemctl disable nginx.service
#查看服务当前状态
systemctl status nginx.service
#重新启动服务
systemctl restart nginx.service
#查看所有已启动的服务
systemctl list-units --type=service
proxy_set_header Host $http_host
server {
#监听端口号
listen 8081;
#监听地址
server_name localhost 192.168.1.202;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
#设置代理
location / {
#Kestrel上运行的asp.net core mvc网站地址
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
nginx -s reload
dotnet myapp.dll
启动网站。#添加80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
#删除防火墙端口:
firewall-cmd --zone=public --remove-port=12345/tcp --permanent
#重新加载防火墙:
firewall-cmd --reload
#重启防火墙:
systemctl stop firewalld systemctl start firewalld
#新建配置文件
touch /etc/systemd/system/myapp.service
#编辑配置文件:
[Unit]
Description=myapp web
[Service]
WorkingDirectory=/home/myapp/web
ExecStart=/usr/bin/dotnet /home/myapp/web/WebPortals.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=myapp
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
#服务开机启动
systemctl enable myapp.service
#启动服务
systemctl start myapp.service
#查看服务状态
systemctl status myapp.service
centos7+nginx部署asp.net core mvc网站
标签:index linux发行版本 home pass rip params 启动 quit fastcgi
原文地址:https://www.cnblogs.com/yanziwen/p/9206491.html