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.配置系統服務linux

#建立服務
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.啓動&設置開機啓動ubuntu

#馬上啓動
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 startvim

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

部署ASP.NET MVC5 ON LINUX

   1.建立目錄/var/www/mvc5/瀏覽器

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

   3.編輯mvc5配置文件mvc

   4.建立ASP.NET MVC5應用程序tcp

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

#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
相關文章
相關標籤/搜索