免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 18829 | 回复: 27
打印 上一主题 下一主题

[Web] RHEL AS4U3+httpd2.2+tomcat5.5+mysql5.0+php5.1详细安装文档 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-24 10:15 |只看该作者 |倒序浏览
在论坛里看了许多相关帖子,自己也实验了多次,终于在前几天测试成功,感谢cu里的前辈们为我们新人铺路,因为我实际工作中要用到这些,以前是兄弟公司的哥们帮我们配置。现在我也配置成功,和大家分享一下成果吧。一直从cu里吸取精华,希望我的文档能给一些新人有帮助。
   说明:实现WEB服务器能运行html、php、jsp等格式文件

一、        所用软件及版本
1、        操作系统:RHEL as4u3
2、        Apache:httpd-2.2.2.tar.gz
apr-util-1.2.7.tar.gz
apr-1.2.7.tar.gz
3、        Tomcat:apache-tomcat-5.5.15.tar.gz
4、        Mysql:mysql-5.0.22.tar.gz
5、        Jdk:jdk-1_5_0_07-linux-i586.bin
6、        Apache和Tomcat连接:tomcat-connectors-1.2.18-src.tar.gz
7、        Php: php-5.1.4.tar.gz
二、        安装步骤:
1、        安装操作系统:这里就不介绍了,主要将相关的开发包装上。我将所有开发包都安装了。
2、        Apache安装:将以上所需要的所有软件上传到/usr/local下。
先解压:
  1. tar xvfz httpd-2.2.2.tar.gz
  2. cd httpd-2.2.2
复制代码

首先可以看看里面的安装说明INSTALL和README。
在安装apache之前先安装apr-util-1.2.7.tar.gz和apr-1.2.7.tar.gz
首先安装apr。
  1. tar xvfz apr-1.2.7.tar.gz
  2. cd apr-1.2.7
  3. ./configure --prefix=/usr/local/apr-httpd
  4. make
  5. make install
  6. cd ..
复制代码

再安装apr-util-1.2.7.tar.gz
  1. tar xvfz apr-util-1.2.7.tar.gz
  2. cd apr-util-1.2.7
  3. ./configure --prefix=/usr/local/apr-util-httpd --with-apr=/usr/local/apr-httpd
  4. make
  5. make install
复制代码

3、        接下来继续安装apache
  1. cd ../httpd-2.2.2
  2. ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-module=most --with-apr=/usr/local/apr-httpd --with-apr-util=/usr/local/apr-util-httpd --enable-so
  3. make
  4. make install
复制代码

如果没有报错,apache基本安装完毕。
4、        安装JDK
回到local目录下:
  1. cd ..
  2. ./jdk-1_5_0_07-linux-i586.bin
  3. ln –s jdk1.5.0_07 jdk
复制代码

设置JDK环境变量
  1. vi /etc/profile
复制代码

再文件尾部增加以下几句:
  1. JAVA_HOME=/usr/local/jdk
  2. JRE=$JAVA_HOME/jre
  3. LC_ALL=zh_CN.GBK
  4. PATH=$JAVA_HOME/bin:$JRE/bin:$PATH
  5. CLASSPATH=.:$JAVA_HOME/bin/tools.jar:$JAVA_HOME/lib/dt.jar
  6. export JAVA_HOME JRE LC_ALL CLASSPATH PATH
复制代码

               
5、        安装MYSQL
  1. tar xvfz mysql-5.0.22.tar.gz
  2. cd mysql-5.0.22
  3. ./configure --prefix=/usr/local/mysql/ --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler
  4. make
  5. make install
  6. groupadd mysql
  7. useradd -g mysql mysql
  8. cp support-files/my-medium.cnf /etc/my.cnf
  9. cd /usr/local/mysql
  10. bin/mysql_install_db --user=mysql
  11. chown -R root  .
  12. chown -R mysql var
  13. chgrp -R mysql .
  14. bin/mysqld_safe --user=mysql &
  15. bin/mysqladmin -uroot password new-password
复制代码

6、        安装php
  1. tar xvfz php-5.1.4.tar.gz
  2. cd php-5.1.4
  3. ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
  4. make && make install
  5. cp php.ini-dist /usr/local/lib/php.ini
复制代码

7、        安装tomcat
  1. tar xvfz apache-tomcat-5.5.15.tar.gz
  2. mv apache-tomcat-5.5.15 tomcat
复制代码

8、        安装Apache和Tomcat连接
  1. tar zxvf tomcat-connectors-1.2.18-src.tar.gz
  2. cd tomcat-connectors-1.2.18-src/ native/
  3. ./configure --with-apxs=/usr/local/apache/bin/apxs
  4. make && make install
复制代码

三、        配置httpd.conf
  1. cd /usr/local/conf/
  2. vi httpd.conf
复制代码

1、        注释掉一下几行
  1. #ServerAdmin you@example.com
  2. #ServerName www.example.com:80
  3. #DocumentRoot "/usr/local/apache/htdocs"
复制代码

2、        修改里面相关内容
A、
  1. <Directory />
  2.     Options FollowSymLinks
  3. #    AllowOverride None
  4.      AllowOverride all
  5.      Order deny,allow
  6. #    Deny from all
  7.      Allow from all
  8. </Directory>
复制代码

B、
  1. #<Directory "/usr/local/apache/htdocs">
  2. <Directory "/usr/local/tomcat/webapps">
  3.     #
  4.     # Possible values for the Options directive are "None", "All",
  5.     # or any combination of:
  6.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  7.     #
  8.     # Note that "MultiViews" must be named *explicitly* --- "Options All"
  9.     # doesn't give it to you.
  10.     #
  11.     # The Options directive is both complicated and important.  Please see
  12.     # http://httpd.apache.org/docs/2.2/mod/core.html#options
  13.     # for more information.
  14.     #
  15. #    Options Indexes FollowSymLinks
  16.     #
  17.     # AllowOverride controls what directives may be placed in .htaccess files.
  18.     # It can be "All", "None", or any combination of the keywords:
  19.     #   Options FileInfo AuthConfig Limit
  20.     #
  21.     AllowOverride None

  22.     #
  23.     # Controls who can get stuff from this server.
  24.     #
  25.     Order allow,deny
  26.     Allow from all

  27. </Directory>
复制代码

因为我这里将网站放在/usr/local/tomcat/webapps下

C、将
  1. #Include conf/extra/httpd-vhosts.conf
复制代码
这行#除掉

3、        增加以下内容:
A、在AddType application/x-gzip .gz .tgz下增加以下两行
  1. AddType application/x-httpd-php .php .phtml
  2.    AddType application/x-httpd-php-source .phps
复制代码

B、结尾增加
  1. #add mod_jk module
  2. LoadModule jk_module modules/mod_jk.so
  3. # Update this path to match your modules location
  4. # Where to find workers.properties
  5. # Update this path to match your conf directory location (put workers.properties next to #httpd.conf)
  6.   JkWorkersFile /usr/local/apache/conf/workers.properties
  7. # Where to put jk logs
  8. # Update this path to match your logs directory location (put mod_jk.log next to access_log)
  9.   JkLogFile     /usr/local/apache/logs/mod_jk.log
  10. # Set the jk log level [debug/error/info]
  11.   JkLogLevel    info
  12. # Select the log format
  13.   JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  14. # JkOptions indicate to send SSL KEY SIZE,
  15.   JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
  16. # JkRequestLogFormat set the request format
  17.   JkRequestLogFormat     "%w %V %T"
  18. # Send everything for context /examples to worker named worker1 (ajp13)
  19.   JkMount  /*.jsp worker1
复制代码


C、在/usr/local/apache/conf下增加一个workers.properties文件,内容如下:
  1. # Define 1 real worker using ajp13
  2.   worker.list=worker1
  3. # Set properties for worker1 (ajp13)
  4.   worker.worker1.type=ajp13
  5.   worker.worker1.host=localhost
  6.   worker.worker1.port=8009
  7.   worker.worker1.lbfactor=50
  8.   worker.worker1.cachesize=10
  9.   worker.worker1.cache_timeout=600
  10.   worker.worker1.socket_keepalive=1
  11.   worker.worker1.reclycle_timeout=300
复制代码

D、再编辑/usr/local/apache/conf/extra/下httpd-vhosts.conf文件
  1. vi httpd-vhosts.conf
复制代码

将里面例子修改一下
  1. <VirtualHost 192.168.0.170:80>
  2. <Directory "/usr/local/tomcat/webapps/ROOT" >
  3. DirectoryIndex index.htm index.html index.jsp index.php
  4. </Directory>
  5.     ServerAdmin xxx@126.com
  6.     DocumentRoot /usr/local/tomcat/webapps/ROOT
  7.     ServerName 192.168.0.170
  8.     ErrorLog logs/170-error_log
  9.     CustomLog logs/170-access_log common
  10. </VirtualHost>
复制代码

因为没有做域名解析,我这里在ServerName下直接用的是IP地址。
四、        测试
先启动tomcat,再启动apache。启动apache之前可以到apache/bin下测试一下虚拟域是否配置正确。./httpd –S 如果配置有错误会提示你。
没有问题后,在IE地址栏输入http://192.168.0.170 此时将显示的是tomcat的默认界面,证明可以正常访问jsp文件了。再将/usr/local/tomcat/webapps/ROOT下index.jsp换一个index.php文件,只要在index.php里输入以下内容即可测试:
  1. <? echo phpinfo() ?>
复制代码
重启apache,再在IE地址栏输入http://192.168.0.170 将能看到php的相关信息。
主要参考文章有:
http://www.chinaunix.net/jh/13/669895.html
http://www.chinaunix.net/jh/13/770898.html
http://httpd.apache.org/docs/2.2/

[ 本帖最后由 vepeta 于 2006-10-19 16:17 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2006-08-24 13:56 |只看该作者
apache2.2以上的版本,
可以直接连tomcat,
没必要装tomcat-connectors。

论坛徽章:
0
3 [报告]
发表于 2006-08-24 14:01 |只看该作者
jdk环境变量写到profile文件就变成全局变量了,
如果要用到多个不同的jdk就不好办了,
可以直接写到 tomcat 的 startup.sh 文件里面的。

论坛徽章:
0
4 [报告]
发表于 2006-08-25 13:49 |只看该作者
谢谢柳拂风兄的指教。

论坛徽章:
0
5 [报告]
发表于 2006-09-24 18:41 |只看该作者
好东东,先收藏!谢!!

论坛徽章:
20
CU大牛徽章
日期:2013-04-17 11:48:26羊年新春福章
日期:2015-03-10 22:39:202015年中国系统架构师大会
日期:2015-06-29 16:11:282015亚冠之平阳省
日期:2015-07-31 09:19:042015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-09-30 06:20:002015亚冠之柏太阳神
日期:2015-10-19 20:29:5915-16赛季CBA联赛之天津
日期:2016-11-29 14:03:4315-16赛季CBA联赛之北控
日期:2016-12-24 20:51:492015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-12 20:58:532014年中国系统架构师大会
日期:2014-10-14 15:59:00
6 [报告]
发表于 2006-09-25 21:42 |只看该作者
好东西

论坛徽章:
0
7 [报告]
发表于 2006-10-05 18:46 |只看该作者

apache2.2以上的版本可以直接连tomca,如何设置???在windows下能实现吗?

如果不装tomcat-connectors如何设置才能整合???在windows下能实现吗?

[ 本帖最后由 vacant 于 2006-10-5 18:49 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2006-10-19 16:22 |只看该作者
原帖由 柳拂风 于 2006-8-24 13:56 发表
apache2.2以上的版本,
可以直接连tomcat,
没必要装tomcat-connectors。


楼上的兄弟,如果不装tomcat-connectors如何整合apache和tomcat,新版apache文档有说明吗?谢谢了
------------------------------------------------------
system:Linux CentOS4U4 2.6.9-42.EL
apache:httpd-2.2.3
tomcat:tomcat-5.5.20

论坛徽章:
0
9 [报告]
发表于 2006-10-20 11:55 |只看该作者
是啊,不用tomcat-connectors如何整合?另外如何整合配置虚拟主机呢?

论坛徽章:
0
10 [报告]
发表于 2006-10-23 09:56 |只看该作者
收下
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP