發佈篇:html
CentOs 6.5 安裝 MySql (本地測試,能用爲主) 【傳送門】linux
CentOS 7 安裝 .Net Core (CentOS 6.5太坑,放棄了)nginx
CentOS 7 IP配置json
ip a
查看網卡名稱,對應修改(參考)centos
TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATA IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_PEERDNS=no IPV6_PEERROUTES=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 UUID=20bd5272-e84c-4893-867a-b854df14ec68 DEVICE=ens160 ONBOOT=yes IPADDR0=192.168.1.210 NETMASK=255.255.255.0 PREFIX0=24 DNS1=233.5.5.5
安裝 Dotnetbash
參考官方運行便可,通常不會有問題(須要CentOS網絡)【官方傳送門】網絡
dotnet --info
顯示以下標示成功app
.NET Command Line Tools (2.0.2) Product Information: Version: 2.0.2 Commit SHA-1 hash: a04b4bf512 Runtime Environment: OS Name: centos OS Version: 7 OS Platform: Linux RID: centos.7-x64 Base Path: /usr/share/dotnet/sdk/2.0.2/ Microsoft .NET Core Shared Framework Host Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
發佈asp.net
> cd /wwwwroot > dotnet publish -r centos.7-x64 #Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core #Copyright (C) Microsoft Corporation. All rights reserved. # Bundler: Begin processing bundleconfig.json # Bundler: Done processing bundleconfig.json # Lsxx.Static -> /wwwroot/Lsxx.Static/bin/Debug/netcoreapp2.0/centos.7-x64/Lsxx.Static.dll # Lsxx.Static -> /wwwroot/Lsxx.Static/bin/Debug/netcoreapp2.0/centos.7-x64/publish/
運行curl
> cd /wwwroot/Lsxx.Static/bin/Debug/netcoreapp2.0/centos.7-x64/publish > dotnet Lsxx.Static.dll #info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] # User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; #keys will not be encrypted at rest. #Hosting environment: Production #Content root path: /wwwroot/Lsxx.Static/bin/Debug/netcoreapp2.0/centos.7-x64 #Now listening on: http://localhost:5000 #Application started. Press Ctrl+C to shut down.
Nginx 安裝(簡易安裝)
curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm rpm -ivh nginx.rpm yum install nginx
安裝成功!
systemctl start nginx #啓動nginx systemctl enable nginx #設置nginx的開機啓動
配置Nginx
vi /etc/nginx/conf.d/default.conf 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; } nginx –s reload #生效配置
防火牆
#關閉firewall: systemctl stop firewalld.service #中止firewall systemctl disable firewalld.service #禁止firewall開機啓動 firewall-cmd --state #查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running) #安裝iptables yum install iptables-services vi /etc/sysconfig/iptables # ... # -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT # -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT # -A INPUT -p tcp -m state --state NEW -m tcp --dport 5000 -j ACCEPT # ... systemctl restart iptables.service #最後重啓防火牆使配置生效 systemctl enable iptables.service #設置防火牆開機啓動 #關閉SELINUX vi /etc/selinux/config #SELINUX=enforcing #註釋掉 #SELINUXTYPE=targeted #註釋掉 SELINUX=disabled #增長 setenforce 0 #使配置當即生效
謝謝
參考:
https://www.cnblogs.com/ants/p/5732337.html
http://asp.net