注:本人使用的是雲服務器,具體CentOS怎麼安裝這裏不做贅述。javascript
網站架設效果能夠查看https://www.resape.comcss
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'
sudo yum update sudo yum install libunwind libicu sudo yum install dotnet-sdk-2.1.4
具體介紹可參考以下地址:html
https://www.microsoft.com/net/learn/get-started/linuxcentosjava
sudo yum -y install httpd mod_ssl
在/etc/httpd/conf.d/路徑下建立resape.conf,內容以下:mysql
<VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://127.0.0.1:5000/ ProxyPassReverse / http://127.0.0.1:5000/ ErrorLog /var/log/httpd/resape-error.log CustomLog /var/log/httpd/resape-access.log common </VirtualHost>
sudo service httpd configtest
sudo systemctl restart httpd
sudo systemctl enable httpd
在/etc/systemd/system/路徑下建立kestrel-resape.service,內容以下:linux
[Unit] Description=Example .NET Web API App running on CentOS 7 [Service] WorkingDirectory=/var/www/html ExecStart=/usr/share/dotnet/dotnet /var/www/html/Resape.dll Restart=always # Restart service after 10 seconds if dotnet service crashes RestartSec=10 SyslogIdentifier=dotnet-example User=apache Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target
systemctl enable kestrel-resape.service systemctl start kestrel-resape.service systemctl status kestrel-resape.service
sudo journalctl -fu kestrel-resape.service
具體介紹可參考以下地址:nginx
https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-apacheweb
若是一切正常,到目前爲止,網站已經能夠訪問了。sql
yum install mariadb-server mariadb
systemctl start mariadb systemctl enable mariadb
/usr/bin/mysql_secure_installation
use mysql; GRANT ALL PRIVILEGES ON *.* to 'root'@'%' identified by '123456'; flush privileges;
systemctl start firewalld.service
sudo firewall-cmd --add-port=80/tcp --permanent sudo firewall-cmd --add-port=443/tcp --permanent firewall-cmd --permanent --zone=public --add-port=3306/tcp firewall-cmd --permanent --zone=public --add-port=3306/udp
sudo firewall-cmd --reload
將以前的resape.conf修改成以下內容:apache
<VirtualHost *:80> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [R,L] </VirtualHost> <VirtualHost *:443> ProxyPreserveHost On ProxyPass / http://127.0.0.1:5000/ ProxyPassReverse / http://127.0.0.1:5000/ ErrorLog /var/log/httpd/resape-error.log CustomLog /var/log/httpd/resape-access.log common SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:!RC4+RSA:+HIGH:+MEDIUM:!LOW:!RC4 SSLCertificateFile /etc/pki/tls/certs/resape.crt SSLCertificateKeyFile /etc/pki/tls/private/resape.key SSLCertificateChainFile /etc/pki/tls/certs/1_root_bundle.crt </VirtualHost>
注意把證書放入配置文件指定的位置。
sudo service httpd configtest sudo systemctl restart httpd
至此,一切大功告成。