ubuntu8.04.2下Apache+Resin+Mysql安装+虚拟主机配置

 一 Apache安装
# tar zxvf httpd-2.2.14.tar.gz(解压)
# cd httpd-2.2.14(进入解压后的目录)
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all
  (命令#./configure --help可以查看configure的配置参数
  --prefix=安装路径
  --enable-so //打开 DSO 支持的 apache 核心模块
  --enable-mods-shared=all //将全部的模板编译成DSO,对于不需要我们可以在httpd.conf去掉
  )
# make
# make install

configure时出现编译错误提示为没C编译工具,解决方法:
安装GCC
#sudo apt-get install build-essential

出现关于zlib的错误,原因是缺少zlib
linux下编译安装zlib
zlib官方网站:
http://www.zlib.net
上下载源码来安装zlib软件包。
目前最新版本zlib是zlib1.2.3,安装开始;
# wget http://www.zlib.net/zlib-1.2.3.tar.gz
# tar -xvzf zlib-1.2.3.tar.gz
# cd zlib-1.2.3.tar.gz
# ./configure
# make
# sudo make install

启动Apache(root用户才能)
# /usr/local/apache2/bin/apachectl start

查看编译进apache的模块
# /usr/local/apache2/bin/httpd -l

开机启动Apache
# cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
# sysvconfig(是图形界面,将apachectl选中)

=======================================================================================================================
二 Mysql安装
# tar zvxf mysql-5.1.39.tar.gz
# cd mysql-5.1.39
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_bin --with-extra-charsets=big5,ascii,gb2312,gbk,utf8,latin1
          //默认的字符集缺省为latin1。
          //其中,utf8对应可用的collation值为:utf8_bin、utf8_general_ci、utf8_unicode_ci
          //extra支持也可以使用 "--with-extra-charsets=all"。
          //默认configure参数下不会安装gbk编码
配置成功会提示:
MySQL has a Web site at [URL="http://www.mysql.com/"][COLOR=#000000]http://www.mysql.com/[/COLOR][/URL] which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.
Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MySQL!
# make
# makeinstall

编译安装完成后执行后续操作:
# useradd mysql //添加 mysql 用户
# cd /usr/local/mysql
# ./bin/mysql_install_db --user=mysql
# chown -R root:mysql . //设置权限,注意后面有一个 "."
# chown -R mysql ./var //设置 mysql 目录权限
# chgrp -R mysql ./var //注意后面有一个 "."
# cp share/mysql/my-medium.cnf /etc/my.cnf //也可使用该目录下的其他配置文件
# cp share/mysql/mysql.server /etc/init.d/mysqld //开机自动启动 mysql。
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld(用的是sysvconfig)

启动MySQL,注意使用用户为mysql:
# /etc/init.d/mysqld start 或者
# /usr/local/mysq/bin/mysqld_safe --user=mysql &

为了测试安装的程序是否正确及MySQL是否已经正常启动,最好的办法就是用MySQL客户端来连接数据库。
# mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 687 to server version: 3.23.58
Type help; or /h for help. Type /c to clear the buffer.
mysql>
如果连接失败则需要仔细分析出错原因:
# more /usr/local/mysql/var/`hostname`.err

为mysql命令做链接(ln),否则只能进入/usr/local/mysql/bin目录才能运行

===========================================================================================================================
三 JDK安装
# sudo chmod +x jdk-6u16-linux-i586.bin
# sudo ./jdk.bin
# vi .profile
  修改该文件加入环境变量
 JAVA_HOME=/home/flh/download/jdk1.6.0_16
 export JAVA_HOME
 CLASSPATH=.:$JAVA_HOME/lib
 export CLASSPATH
 PATH=$PATH:$JAVA_HOME/bin
 export PATH
重启系统。输入 java -version 能够查看到jdk版本,则表示成功安装和配置。

============================================================================================================================
四 Resin安装
必须先安装好jdk,并设置好其环境变量
下载的resin的安装包解开后应该可以直接单独运行的。解压后放/home/flh/software目录下
# tar xfz resin-3.1.19.tar.gz
# mv resin-3.0.10 /home/flh/software
# cd /home/flh/software/resin
# ln -s resin-3.0.10/ resin
启动resin
# /home/flh/software/resin/bin/httpd.sh start
现在就能够从http://localhost:8080/上能看到resin的页面,这也就表示单独的resin运行成功了。然后,为了整合resin和apache,我们需要重新编译一下,以生成mod_caucho给apache调用。(Apache需要启用DSO支持,即编译了mod_so.c模块,如果没有要重新编译Apache)
# cd /home/flh/software/resin
# ./configure --prefix=/usr/local/resin --with-apache=/usr/local/apache2
  //默认安装目录为当前目录
# make
# make install
修改resin.conf的root-directory的值修改成和Apache的DocumentRoot的值相同
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
  ...
  <server>
    ...
    <host id="">
      <web-app id='/' root-directory="/usr/local/apache/htdocs"/>
    </host>
    ...
  </server>
</resin>
上述的安装过程会自动更改httpd.conf文件。您还可以配置手动httpd.conf文件,或修改安装过程中创建的默认配置。
LoadModule caucho_module libexec/mod_caucho.so
ResinConfigServer localhost 6802
<Location /caucho-status>
  SetHandler caucho-status
</Location>
保存后重启Apache和resin
通过浏览器去访问http://localhost/caucho-status/,如果出现以下页面刚表示resin和apache已经成功整合了。

 

开机启动resin
# vi /home/flh/software/resin/contrib/init.resin
检查里面的JAVA_HOME是不是jdk的安装目录、RESIN_HOME是不是resin的安装目录,如果不是的话修改成对应的安装目录,按照上述安装过程,应为:
JAVA_HOME=/home/flh/download/jdk1.6.0_16
RESIN_HOME=/usr/local/resin
# cp /home/flh/software/resin/contrib/init.resin /etc/init.d/resin.sh
# chmod +x resin.sh
# sysvconfig(如果没有该命令,先安装,在图形界面选中根据提示操作,选择Enable/Disable->ok->选中resin.sh->ok->Finished->ok->ok->选中Quit->ok)
重启计算机发现resin已经开机启动了。


===============================================================================================================================
五 建立resin和apache的虚拟主机,部署java应用
修改httpd.conf
<VirtualHost *:80>
  DocumentRoot /home/flh/web/test1
  ServerName test1.jsp.com
 </VirtualHost>
<VirtualHost *:80>
  DocumentRoot /home/flh/web/test2
  ServerName test2.jsp.com
</VirtualHost>

修改resin.conf
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
  ...
  <server>
    ...
    <host id="">
      <web-app id='/' root-directory="/usr/local/apache/htdocs"/>
    </host>
    <host id="test1.jsp.com">
      <web-app id='/' root-directory="/home/flh/web/test1"/>
    </host>
    <host id="test2.jsp.com">
      <web-app id='/' root-directory="/home/flh/web/test2"/>
    </host>
    ...
  </server>
</resin>
保存重启apache和resin
test1.jsp.com  和test2.jsp.com 虚拟主机可以运行了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值