Ubuntu Server 10.04 搭建JSP环境


 1 安装java
sudo apt-get install sun-java6-jdk sun-java6-fonts sun-java6-plugin
可能会先要求装jre,装就是了
sudo update-java-alternatives -s java-6-sun

2 环境变量
sudo vim /etc/environment
加入 JAVA_HOME=/usr/lib/jvm/java-6-openjdk/


PATH改为如下
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-openjdk/bin/"


3 安装apache
sudo apt-get install apache2
然后 sudo /etc/init.d/apache2 start/stop/restart 可以进行启动之类的
启动后看看浏览器地址栏输入127.0.0.1看结果
其中/etc/init.d/apache2和/usr/sbin/apachectl 作用是相同的, 只是在/etc/init.d会自动执行
而有任何要改动的设定, 加在/etc/apache2/httpd.conf中

4 安装tomcat
sudo apt-get install tomcat6 tomcat6-common tomcat6-docs tomcat6-examples libtomcat6-java
同样/etc/init.d/tomcat6 start/stop/restart 进行启动

5 mod_jk的安裝
如此一来,apache跟tomcat应该都可以正常运行了,只是两者互不认识,www.linuxboy.net要把他們连在一起还要個mod_jk.
sudo apt-get install libapache2-mod-jk
/usr/lib/apache2/modules/mod_jk.so就是让负责apache将request交给tomcat处理的module.

然后将/usr/share/doc/libapache2-mod-jk/httpd_example_apache2.con内容直接copy到/etc/apache2/httpd.conf,

6 验证
sudo gedit /etc/apache2/httpd.conf
#gedit 吧,你可以直接粘贴到结尾
Alias /examples "/usr/share/tomcat6-examples/examples"
<Directory "/usr/share/tomcat6-examples/examples">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
#/tomcat6-examples/examples 来自 sudo apt-get install tomcat6 tomcat6-examples
重启apache2后浏览器输入http://localhost/examples查看是否成功。
 

相关内容

    暂无相关文章