Centos、Ubuntu 安装 Mono、Jexus,centosjexus


Mono是.NET的跨平台实现

在众多关于语言的争论中,.NET一直被以不能跨平台而诟病,Mono改变了这一现状。

有人当心Mono会涉及版权啥的问题。高深的偶不懂,不过我觉得Unity3D都能用,为什么我们不能用。 :)

 

Jexus是Linux下免费的服务器软件。Jexus作者宇内,已对Mono做了大量尝试,稳定靠谱。

我自己目前也有一个爬虫项目正在Mono上进行中。项目还没有完成。趁着空挡留个记录吧。

 

安装方法在以下环境测试过,均运行在VMware上

  • CentOS 6.2 32  最小安装
  • Centos 7.0 64  最小安装
  • Ubuntu 14.04 Server 64   默认

均使用root身份执行命令 

如果不安装Jexus,做到步骤5,你的Mono就可以使用了

 

1. 防火墙就直接关闭了,防止新手不知道为啥老是不能访问的情况

//Centos

Centos7 使用新的firewalld,不再使用iptables

systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --add-port=80/tcp //添加端口号到防火墙白名单 如果你不想关闭firewalld

如果是CentOS6则使用:

service iptables stop
chkconfig iptables off
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT service iptables save //低版本使用 /etc/rc.d/init.d/iptables save 保存 如果你不想关闭iptables

 //Ubuntu

 //Ubuntu默认没有防火墙,但是账号权限低,先开启root,安装SSH。

 //此步完成后,请改用Root账户登入,避免权限不足,安装过程结束后建议停用Root账号

sudo passwd root
//输入当前用户密码
//输入、重复 root 新密码

apt-get install ssh      //安装SSH,待会儿可以远程上传安装包
vi /etc/ssh/sshd_config  //然后按i进入编辑模式
//把 PermitRootLogin without-password 修改为 PermitRootLogin yes
//按ESC,退出编辑模式,输入:wq保存
sudo service ssh restart    //要求输入密码
//这样你就可以用SSH远程控制或者上传了
sudo passwd -l root 如果你想禁用root账号

 

2. 安装一些基础的包

//Centos

我在安装Centos的时候选择了最小安装,大部分组件是没有的。先用yum命令,安装一通(如果需要网络命令,yum install net-tools)

yum -y install wget glib2-devel libtiff libtiff-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel libX11 libX11-devel freetype freetype-devel fontconfig fontconfig-devel libexif libexif-devel gcc-c++ gettext unzip zip bzip2 bzip2-devel

安装需要执行一段时间,具体时间按照你的网络性能而定。安装完毕

 //Ubuntu用户

apt-get install build-essential automake autoconf libtool bison gettext pkg-config libgdiplus

 

3. 在/usr目录建立一个文件夹保存源码包

cd /usr
mkdir software
cd software

4. 先下载并编译安装libgdiplus,用来支持MONO的GDI  

//Ubuntu略过第四部,前面已APT安装libgdiplus,跳到5

方案1

wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.tar.bz2
tar -xjf libgdiplus-2.10.tar.bz2
cd libgdiplus-2.10
./configure --prefix=/usr
make && make install

 执行“./configure --prefix=/usr”后

 

方案2 #7楼 那一剑风情  提供。感谢宇内耐心指导

yum -y install libtool* git
git clone git://github.com/mono/libgdiplus.git
//速度比较慢,我已经Clone,并上传到园子里来了,你可以直接 wget
//wget http://files.cnblogs.com/Zendic/libgdiplus.zip
unzip libgdiplus.zip
cd libgdiplus
./autogen.sh --prefix=/usr
make
make install

 

 

5. 安装Mono

3.4,3.4这个版本官方的源码包,少了一些文件,以至于安装会出现问题。我们使用shanyou帖子里面发的Mono3.4

下载地址:http://pan.baidu.com/s/1eQ452Ie

引用shanyou帖子:http://www.cnblogs.com/shanyou/p/3655447.html

mono-3.4.0.tar.gz 下载后上传到 /usr/software 目录,使用FlashFXP,XShell等工具SSH上传即可  

   

然后开始按下面解压并安装

tar -xzf mono-3.4.0.tar.gz
cd mono-3.4.0
./configure --prefix=/usr
make && make install

安装过程比较漫长,我CPU:I3 380M,VM虚拟机, make install 估计去了半个小时

等到安装结束,可以使用 mono -V(大写)  命令,来查看版本信息

//到这,你已经可以使用  mono HelloWorld.exe 这样的方式来执行你.NET程序了。

//如果你不需要Jexus做Web服务器,到这即可结束

//随便写个控制台程序,然后从项目debug目录上传到linux运行一下

6. 可以安装Jexus了

cd /usr/software
wget linuxdot.net/down/jexus-5.6.1.tar.gz
tar -zxvf jexus-5.6.1.tar.gz 
cd jexus-5.6.1 
./install

这样,Jexus就安装好了

7. 启动JEXUS

启动
/usr/jexus/jws start
停止
/usr/jexus/jws stop
重启
/usr/jexus/jws restart

自此,使用 http://你的IP/info即可验证Jexus是否启动

 

8. 跟随Centos/Ubuntu启动Jexus

方案1. 添加到 /etc/rc.local,跟随启动 

//经尝试,Ubuntu跟Centos6,可使用方案1。Centos7不知道为啥不行,如果是Centos7请使用方案2,如果有大神知道麻烦说下为什么

vi /etc/rc.local
按 i 键进入编辑模式

添一句
/usr/jexus/jws start
按ESC退出编辑模式,输入 :wq保存文件
//Ubuntu用户请加在 exit 0 前面哈

方案2. 添加为系统服务,启动

cd /etc/init.d/       
vi jws

按i编辑模式,粘贴下面内容

#!/bin/bash
#chkconfig: 2345 80 05
#description:jws
#

. /etc/rc.d/init.d/functions

case "$1" in
start)
  echo "Jexus Start.."
  /usr/jexus/jws start
  ;;
stop)
  echo "Jexus Stop.."
  /usr/jexus/jws stop
  ;;
restart)
  echo "Jexus Restart"
  /usr/jexus/jws restart
  ;;
status)
  /usr/jexus/jws status
  ;;
*)
  exit 1
  ;;
esac

exit $RETVAL

按ESC后,输入:wq保存文件

把这个脚本作为“服务”加入

chkconfig --add jws

至此,JEXUS已跟随系统启动,可以reboot一下试试看

你也可以通过修改 /usr/jexus/siteconf 里面的文件,来修改站点配置。

相关内容

    暂无相关文章