鸿 网 互 联 www.68idc.cn

当前位置 : 主页 > 服务器相关 > linux > >

apache 2.2.15 + mysql 5.1.46 + php 5.3.2 + mod_jk 1.2.28 + t

来源:互联网 作者:佚名 时间:2012-08-23 22:21
apache 2.2.15 + mysql 5.1.46 + php 5.3.2 + mod_jk 1.2.28 + tomcat 6.0.20 虚 拟主机配置 1.下载apache2.2.15源码,然后编译安装 (1)./configure enable-so (2)make (3)make install 安装在目录/usr/local/apache2目录下面 2.下载安装mysql 5.1.46 (1)下
apache 2.2.15 + mysql 5.1.46 + php 5.3.2 + mod_jk 1.2.28 + tomcat 6.0.20 虚 拟主机配置
1.下载apache2.2.15源码,然后编译安装
(1)./configure –enable-so
(2)make
(3)make install
安装在目录/usr/local/apache2目录下面
2.下载安装mysql 5.1.46
(1)下载MySQL-server-community-5.1.46-1.rhel3.i386.rpm,MySQL-client-community-5.1.46-1.rhel3.i386.rpm 和MySQL-devel-community-5.1.46-1.rhel3.i386.rpm
(2)rpm -ivh MySQL-server-community-5.1.46-1.rhel3.i386.rpm MySQL-client-community-5.1.46-1.rhel3.i386.rpm MySQL-devel-community-5.1.46-1.rhel3.i386.rpm
如果server和client两个包不能rpm安装,可以编译源码安装,我在redhat 9上可以rpm安装 devel包的,devel包必须安装,php连接mysql需要的。
3.下载安装php 5.3.2
(1)./configure –with-mysql –with-apxs2=/usr/local/apache2/bin/apxs –with-gd –with-jpeg-dir=/usr/local
(2)make
(3)make install
(4)然后修改/usr/local/apache2/conf/httpd.conf,在<IfModule mime_module>……</IfModule>之 间增加
AddType application/x-httpd-php .php .phtml,
下面这行
LoadModule php5_module        modules/libphp5.so
已经被上面的make install命令自动添加进去了,就不用管了。
(5)
编写一个php测试文件/usr/local/apache2/htdocs/test.php,内容如下:
<?php
phpinfo();
?>
启动apache,
./apachectl -k start
测试http://ip/test.php, 看是否正常。
4.下载安装tomcat 6.0.20
5.下载mod_jk 1.2.18
将so文件放到/usr/local/apache2/modules/目录下面并改名为mod_jk.so
关闭apache,./apachectl stop
在httpd.conf里面添加以下内容:
Include conf/extra/httpd-vhosts.conf
也就是将这行取消注释。
编辑/usr/local/apache2/conf/extra/httpd-vhosts.conf文件,内容如下:
NameVirtualHost *
 
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
<VirtualHost *>
    ServerAdmin liliangpu@yahoo.com
    ServerName www.test1.com
    ServerAlias test1.com
    JkMount /* worker1
</VirtualHost>
 
<VirtualHost *>
    ServerAdmin liliangpu@yahoo.com
    DocumentRoot “/usr/local/apache2/htdocs”
    ServerName www.test2.com
    ServerAlias test2.com
    ErrorLog “logs/test2.com-error_log”
    CustomLog “logs/test2.com-access_log” common
</VirtualHost>
 
<VirtualHost *>
    ServerAdmin liliangpu@yahoo.com
    ServerName www.test3.com
    ServerAlias test3.com
    JkMount /* worker1
</VirtualHost>
其中第一个VirtualHost是默认网站,我默认第一个是转给tomcat,然后tomcat配置文件 server.xml配置如下:
<?xml version=’1.0′ encoding=’utf-8′?>
<Server port=”8005″ shutdown=”SHUTDOWN”>
 
  <Listener className=”org.apache.catalina.core.JasperListener” />
  <Listener className=”org.apache.catalina.mbeans.ServerLifecycleListener” />
 
  <Service name=”Catalina”>
    <Connector port=”8080″ protocol=”HTTP/1.1″ server=”iis” acceptCount=”1024″
               connectionTimeout=”20000″ enableLookups=”false” maxThreads=”1024″
               redirectPort=”8443″ />
    <Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
    <Engine name=”Catalina” defaultHost=”www.test1.com“>
      <Host name=”www.test1.com” appBase=”/opt/test1″ unpackWARs=”true” autoDeploy=”true” xmlValidation=”false” xmlNamespaceAware=”false”>
        <Alias>test1.com</Alias>
        <Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”/var/log/test1-access” prefix=”log” suffix=”.txt” pattern=”combined” resolveHosts=”false” />
      </Host>
      <Host name=”www.test3.com” appBase=”/opt/test3″ unpackWARs=”true” autoDeploy=”true” xmlValidation=”false” xmlNamespaceAware=”false”>
        <Alias>test3.com</Alias>
        <Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”/var/log/test3-access” prefix=”log” suffix=”.txt” pattern=”combined” resolveHosts=”false” />
      </Host>
    </Engine>
  </Service>
</Server>
然后编辑/usr/local/apache2/conf/workers.properties,内容如下:
worker.list=worker1
 
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
最后重新启动apache,php和tomcat都可以使用了。
网友评论