CentOS7 .NetCore+Nginx 部署
安裝DotNet SDK 官方文件
新增映象訂閱
rpm --import https://packages.microsoft.com/keys/microsoft.asc
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'
安裝SDK
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.1.3
檢視安裝
dotnet --version
上傳站點 官方文件
psftp [主機地址]
put D:\website.7z
解壓檔案,使用的是 p7zip
7za x website.7z
建立服務
vi /etc/systemd/system/website.service
[Unit]
Description=Web API Application running on CentOS
[Service]
WorkingDirectory=/home/website
ExecStart=/usr/bin/dotnet /home/website/website.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=website
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
啟動服務
systemctl start website
systemctl enable website
測試站點
curl localhost:8010
安裝Nginx
yum install -y nginx
啟動,測試
systemctl start nginx
nginx -v
修改配置檔案
cd /etc/nginx
vi /etc/nginx/conf.d/vhost_website.conf
server {
server_name [test.xxx.com];
location / {
proxy_pass http://localhost:8010;
}
}
Https配置[可選]
編輯nginx.conf
vi /etc/nginx/nginx.conf
server {
listen 443 ssl http2 default_server;
listen[::]:443 ssl http2 default_server;
server_name _;
root /usr/share/nginx/html;
ssl on;
ssl_certificate /etc/pki/nginx/certificate.pem;
ssl_certificate_key /etc/pki/nginx/certificate.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
編輯vhost_website.conf
vi /etc/nginx/conf.d/vhost_website.conf
server {
listen 443 ssl http2;
listen[::]:443 ssl http2;
server_name [test.xxx.com];
location / {
proxy_pass http://localhost:8010;
}
}
測試
重新啟動nginx
systemctl restart nginx
瀏覽器開啟
http://[test.xxx.com]
其它異常
1.Unable to bind to http://localhost:5000 on the IPv6 loopback interface: ‘Error -99 EADDRNOTAVAIL address not available’.
新增hosting.json
{
"server.urls": "http://*:8010"
}
修改Program
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseStartup<Startup>()
.Build()
.Run();
}
相關文章
- CentOS7上部署httpsCentOSHTTP
- CentOS7離線部署JDKCentOSJDK
- centos7部署djangoCentOSDjango
- CentOS7 docker安裝部署教程CentOSDocker
- CentOS7部署geoserver和postgisCentOSServer
- CentOS7 輕鬆部署 Laravel 應用CentOSLaravel
- asp.net core 2.1 部署 centos7ASP.NETCentOS
- Centos7系統部署django專案CentOSDjango
- Centos7安裝安裝部署dockerCentOSDocker
- Centos7部署Redis叢集CentOSRedis
- CentOS7 Hbase-1.3.1 分散式部署CentOS分散式
- CentOS7部署Docker(聯網)CentOSDocker
- centos7下zookeeper叢集安裝部署CentOS
- Centos7部署nmon監控工具CentOS
- centos7後臺服務部署jar包CentOSJAR
- CentOS7下Elasticsearch叢集部署記錄CentOSElasticsearch
- CentOS7 Tomcat JSP 安裝部署CentOSTomcatJS
- CentOS7 Hadoop-2.7.4 分散式部署CentOSHadoop分散式
- CentOS7 Apache+Mono Web站點部署CentOSApacheMonoWeb
- Centos7搭建部署confluence7.4.6CentOS
- CentOS7系統GitLab安裝部署教程。CentOSGitlab
- asp.net core 應用docke部署到centos7ASP.NETCentOS
- 虛擬化架構與Centos7系統部署架構CentOS
- 在CentOS7環境下部署weblogic叢集CentOSWeb
- 阿里雲centos7部署Django專案阿里CentOSDjango
- Centos7安裝jenkins+docker部署tomcatCentOSJenkinsDockerTomcat
- linux centos7部署anaconda3LinuxCentOS
- Docker實踐(6)—CentOS7上部署KubernetesDockerCentOS
- java在centos7下部署執行jar包JavaCentOSJAR
- Centos7安裝部署openstack--nova計算服務CentOS
- CentOS7配置中文支援與部署GitLab伺服器CentOSGitlab伺服器
- etcd學習(4)-centos7中部署etcdCentOS
- CentOS7系統手動部署LNMP環境操作演示CentOSLNMP
- Centos7部署RabbitMQ的映象佇列叢集CentOSMQ佇列
- 使用passenger在Centos7部署nginx+Ruby on RailsCentOSNginxAI
- Liunx(CentOS7)中介軟體Weblogic的安裝與部署CentOSWeb
- CentOS7下單機部署RabbltMQ環境的操作記錄CentOSMQ
- 專案部署到centos7雲端驗證碼出現亂碼CentOS