ASP.NET MVC5 怒跨 Linux 平台


安裝CentOS

安裝Mono

#安裝yum工具包
yum -y install yum-utils
#通過rpm添加Mono源 rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" yum-config-manager --add-repo http://download.mono-project.com/repo/centos7/
#執行安裝 yum -y install mono-devel
#查看安裝結果 mono -V

 安裝Jexus

#下載安裝包
cd Downloads
wget linuxdot.net/down/jexus-5.8.2.tar.gz 

#解壓&安裝
tar -zxvf jexus-5.8.2.tar.gz 
cd jexus-5.8.2 
sudo ./install

設置Jexus開機啟動

   1.配置系統服務

#創建服務
vi /usr/lib/systemd/system/jexus.service

#內容
[Unit]  
Description=Jexus  
After=syslog.target network.target remote-fs.target nss-lookup.target  

[Service]  
Type=forking  

ExecStart=/usr/jexus/jws start
ExecReload=/usr/jexus/jws restart
ExecStop=/usr/jexus/jws stop

[Install]  
WantedBy=multi-user.target

 

   2.啟動&設置開機啟動

#立刻啟動
systemctl start jexus

#開機啟動
systemctl enable jexus

 

安裝&設置iptables

#安裝iptables
yum install iptables-services

#設置iptables
vim /etc/sysconfig/iptables

#新增80和8080端口(同理其它端口)
-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 8080 -j ACCEPT

#重新啟動
service iptables restart

測試Jexus

   1.啟動Jexus(默認80端口):sudo /usr/jexus/jws start

   2.在瀏覽器地址欄輸入 ip/info 回車出現下圖代表Jexus安裝成功:

部署ASP.NET MVC5 ON LINUX

   1.創建目錄/var/www/mvc5/

   2.拷貝/usr/jexus/siteconf/default並創建mvc5配置文件

   3.編輯mvc5配置文件

   4.創建ASP.NET MVC5應用程序

   5.用nuget卸載package(mono不支持roslyn編譯器

#roslyn編譯器相關的package
uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
uninstall-package Microsoft.Net.Compilers

   6.重新生成並發布ASP.NET MVC5應用程序

   7.將ASP.NET MVC5應用程序的發布文件拷貝到/var/www/mvc5/

   8.重新啟動Jexus:sudo /usr/jexus/jws restart

   9.Linux本地訪問

 

   10.Windows遠程訪問(如果無法訪問就需要關閉防火牆

防火牆常用指令

#查看防火牆狀態
sudo firewall-cmd --state

#禁止防火牆開機啟動
systemctl disable firewalld.service

#設置防火牆開機啟動
systemctl enable iptables.service 

#停止防火牆
systemctl stop firewalld.service 

#重啟防火牆使配置生效(必須重啟)
systemctl restart iptables.service

#查看當前系統打開的端口
netstat -lntp


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM