在 Linux 上使用 mono 和 JBOSS 集成 Asp.Net 和 JSP 页面
在 Linux 上使用 mono 和 JBOSS 集成 Asp.Net 和 JSP 页面
引言
1) .Net Framework 是平台特定的,因为它由 Microsoft 开发。
2) 它在 Linux 上无法运行。
3) 要使 .Net 应用程序能够在 Linux 上运行,第三方 Novell 公司开发了 mono。 Mono 就像 .Net framework 一样,是平台无关的。
4) Mono 是一个开源项目,包含 .Net Framework 中定义的大部分类和类型库。
• 一个与 ECMA 标准兼容的通用语言运行时 (CLR)
• 一个 C# 编译器
• 一套类库
• 辅助工具,如反汇编器、调试器、IDE 等。
5) Mono 有自己的 Web 服务器,名为 xsp。xsp 是一个轻量级的 Web 服务器,用 c# 编写。
在 Linux OS 上安装 Mono
1) 从 www.go-mono.com/downloads 页面下载符合您操作系统规格的 mono rpm 或安装程序。
2) 我下载了类似 mono-1.1.17.1_2-installer.bin 这样的文件。
3) 进入 Linux 的 root bash 提示符。
4) cd 到上述安装程序所在的目录。
5) 输入以下命令:
[root@dotnetlinux.com] # md5sum mono-1.1.17.1_2-installer.bin (检查安装程序)
898cb6e5076455d72a4786bb2584656d mono-1.2.3.1_0-installer.bin
(输出)
[root@dotnetlinux.com] # chmod 777 mono-1.1.17.1_2-installer.bin (更改用户访问权限)
[root@dotnetlinux.com] # ./mono-1.1.17.1_2-installer.bin (运行安装程序)
安装向导窗口将打开。请按照说明进行操作,Mono 将被安装。
6) 现在,要启动 xsp Web 服务器,请进入 bash 提示符并键入以下命令,假设 mono 在 mono (一个文件系统文件夹) 中,进入 mono-1.1.17.1。
[root@dotnetlinux.com] # mono mono-.17.1/usr/lib/xsp/2.0/xsp.exe
Web 服务器将在默认的 8080 端口上启动。
打开 mozilla 浏览器并输入以下地址:https://:8080/ 您将看到包含所有 .Net 控件和示例的窗口。
9) 现在,将您的应用程序 (xcopy) 部署到 Linux 机器上,并在该文件夹中启动 xsp 服务器。
然后在浏览器中浏览该页面。
10) 对于构建 .cs 文件,Mono 提供了一个编译器。要编译 .cs 文件,请进入 bash 提示符并 cd 到该目录,然后输入以下命令。可以像这样引用 dll:
[root@dotnetlinux.com] # mcm TestPage.cs –r:System.Data.dll out:TestPage.exe
以下命令将运行 exe。
[root@dotnetlinux.com] # mono TestPage.exe
11) 如果您的应用程序包含 DAL,请使用 mcm 编译它,并引用 mcm 编译的 dll。
Linux 上的 Oracle 10 g
1) 按照以下网站上的说明在 Linux 上安装 Oracle 10 g。
http://www.oracle.com/technology/pub/articles/smiley_10gdb_install.html
2) 设置环境变量。
3) 使用 sqlplus 检查连接。
4) 使用 lsnrctl start 命令启动监听器。
Linux 上的 JBoss
1) 将 JBoss 复制到 Linux 机器上。我将其复制到了 /opt/usr/share/oss。
2) 以及 Linux 的 jdk1.4 放在 /usr/java/jdk1.4。
3) 转到以下路径:
/opt/oss/share/jboss-4.0.2/server/default/deploy/jbossweb-tomcat55.sar
打开 server.xml 文件并将端口 8080 更改为 8088。
4) 使用 sh run.sh 命令启动 JBoss Apache 服务器。编辑 sh run.sh 以设置 JAVA_HOME。
5) 我 Linux 机器上的导出参数是:
export ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export JAVA_HOME=/usr/java/jdk1.4
6) 打开 https://:8088/,您将看到 JBOSS 窗口。
由于两个 Web 服务器现在都在不同的端口上运行,因此可以实现 .aspx 和 .JSP 页面之间的任何重定向。
Linux 上的一些重要命令
如果您是 Linux 新手,以下一些命令将会有所帮助。
/bin - essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode
/boot - files used during booting and possibly the kernel itself are stored here
/dev - contains device files for various devices on system
/etc - files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc.
/etc/profile.d - contains scripts that are run by /etc/profile upon login.
/etc/rc.d - contains a number of shell scripts that are run on bootup at different run levels. There is also typically an rc.inet1 script to set up networking (in Slackwar), an rc.modules script to load modular device drivers, and an rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS.
/etc/rc.d/init.d - contains most of the initialization scripts themselves on an rpm-based system.
/etc/rc.d/rc*.d - where ``*'' is a number corresponding to the default run level. Contains files for services to be started and stopped at that run level. On rpm-based systems, these files are symbolic links to the initialization scripts themselves, which are in /etc/rc.d/init.d.
/etc/skel - directory containing several example or skeleton initialization shells. Often contains subdirectories and files used to populate a new user's home directory.
/etc/X11 - configuration files for the X Window system
/home - home directories of individual users
/lib - standard shared library files
/lib/modules - modular device driver files, most with .o extensions
/mnt - typical mount point for many user-mountable devices such as floppy drives, cd-rom readers, etc. Each device is mounted on a subdirectory of /mnt.
/proc - virtual file system that provides a number of system statistics
/root - home directory for root
/sbin - location of binaries used for system administration, configuration, and monitoring
/tmp - directory specifically designed for programs and users to store temporary files.
/usr - directory containing a number of subdirectory with programs, libraries, documentation, etc.
/usr/bin - contains most user commands. Should not contain binaries necessary for booting the system, which go in /bin. The /bin directory is generally located on the same disk partition as /, which is mounted in read-only mode during the boot process. Other file systems are only mounted at a later stage during startup, so putting binaries essential for boot here is not a good idea.
/usr/bin/X11 - most often a symbolic link to /usr/X11R6/bin, which contains executable binaries related to the X Window system
/usr/doc - location of miscellaneous documentation, and the main location of program documentation files under Slack ware
/usr/include - standard location of include files used in C programs such as stdio.h
/usr/info - primary location of the GNU info system files
/usr/lib - standard library files such as libc.a. Searched by the linker when programs are compiled.
/usr/lib/X11 - X Window system distribution
/usr/local/bin - yet another place to look for common executables
/usr/man - location of manual page files
/usr/sbin - other commands used by super user for system administration
/usr/share - contains subdirectories where many installed programs have configuration, setup and auxiliary files
/usr/share/doc - location of program documentation files under Mandrake and Red Hat
/usr/src - location of source programs used to build system. Source code for programs of all types are often unpacked in this directory.
/usr/src/Linux - often a symbolic link to a subdirectory whose name corresponds to the exact version of the Linux kernel that is running. Contains the kernel sources.
/var - administrative files such as log files, used by various utilities
/var/log/packages - contains files, each of which has detailed information on an installed package in Slack ware. The same file can also be found at /var/adm/packages, since the adm subdirectory is a symbolic link to log. Each package file contains a short description plus a list of all installed files.
/var/log/scripts - package installation scripts in Slack ware are stored here. You can inspect these scripts to see what special features are included in individual packages.
/var/spool - temporary storage for files being printed, mail that has not yet been picked up, etc.
摘要
只需遵循这些步骤,您就可以轻松地在 Linux 上集成 Asp.Net 和 JSP 页面。