[转载]RHEL AS4U3+httpd2.2+tomcat5.5+mysql5.0+php5.1详细安装文档
<p>信息来源: CU</p><p>在论坛里看了许多相关帖子,自己也实验了多次,终于在前几天测试成功,感谢cu里的前辈们为我们新人铺路,因为我实际工作中要用到这些,以前是兄弟公司的哥们帮我们配置。现在我也配置成功,和大家分享一下成果吧。一直从cu里吸取精华,希望我的文档能给一些新人有帮助。 <br />说明:实现WEB服务器能运行html、php、jsp等格式文件 <br /><br />一、 所用软件及版本 <br />1、 操作系统:RHELas4u3 <br />2、 Apache:httpd-2.2.2.tar.gz <br />apr-util-1.2.7.tar.gz <br />apr-1.2.7.tar.gz <br />3、 Tomcat:apache-tomcat-5.5.15.tar.gz <br />4、 Mysql:mysql-5.0.22.tar.gz <br />5、 Jdk:jdk-1_5_0_07-linux-i586.bin <br />6、 Apache和Tomcat连接:tomcat-connectors-1.2.18-src.tar.gz <br />7、 Php:php-5.1.4.tar.gz <br />二、 安装步骤: <br />1、 安装操作系统:这里就不介绍了,主要将相关的开发包装上。我将所有开发包都安装了。 <br />2、 Apache安装:将以上所需要的所有软件上传到/usr/local下。 <br />先解压:</p><pre>tarxvfzhttpd-2.2.2.tar.gz<br />cdhttpd-2.2.2</pre><p><br />首先可以看看里面的安装说明INSTALL和README。 <br />在安装apache之前先安装apr-util-1.2.7.tar.gz和apr-1.2.7.tar.gz <br />首先安装apr。 <br /></p><pre>tarxvfzapr-1.2.7.tar.gz
<br />cdapr-1.2.7
<br />./configure--prefix=/usr/local/apr-httpd
<br />make
<br />makeinstall
<br />cd..</pre><p><br />再安装apr-util-1.2.7.tar.gz <br /></p><pre>tarxvfzapr-util-1.2.7.tar.gz
<br />cdapr-util-1.2.7
<br />./configure--prefix=/usr/local/apr-util-httpd--with-apr=/usr/local/apr-httpd
<br />make
<br />makeinstall</pre><p><br />3、 接下来继续安装apache <br /></p><pre>cd../httpd-2.2.2
<br />./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
<br />make
<br />makeinstall</pre><p><br />如果没有报错,apache基本安装完毕。 <br />4、 安装JDK <br />回到local目录下: <br /></p><pre>cd..
<br />./jdk-1_5_0_07-linux-i586.bin
<br />ln–sjdk1.5.0_07jdk</pre><p><br />设置JDK环境变量 <br /></p><pre>vi/etc/profile</pre><p><br />再文件尾部增加以下几句: <br /></p><pre>JAVA_HOME=/usr/local/jdk
<br />JRE=$JAVA_HOME/jre
<br />LC_ALL=zh_CN.GBK
<br />PATH=$JAVA_HOME/bin:$JRE/bin:$PATH
<br />CLASSPATH=.:$JAVA_HOME/bin/tools.jar:$JAVA_HOME/lib/dt.jar
<br />exportJAVA_HOMEJRELC_ALLCLASSPATHPATH</pre><p><br /><br />5、 安装MYSQL <br /></p><pre>tarxvfzmysql-5.0.22.tar.gz
<br />cdmysql-5.0.22
<br />./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
<br />make
<br />makeinstall
<br />groupaddmysql
<br />useradd-gmysqlmysql
<br />cpsupport-files/my-medium.cnf/etc/my.cnf
<br />cd/usr/local/mysql
<br />bin/mysql_install_db--user=mysql
<br />chown-Rroot.
<br />chown-Rmysqlvar
<br />chgrp-Rmysql.
<br />bin/mysqld_safe--user=mysql&
<br />mysqladmin–urootpasswordnew-password</pre><p><br />6、 安装php <br /></p><pre>tarxvfzphp-5.1.4.tar.gz
<br />cdphp-5.1.4
<br />./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-apxs2=/usr/local/apache/bin/apxs
<br />make&&makeinstall
<br />cpphp.ini-dist/usr/local/lib/php.ini</pre><p><br />7、 安装tomcat <br /></p><pre>tarxvfzapache-tomcat-5.5.15.tar.gz
<br />mvapache-tomcat-5.5.15tomcat</pre><p><br />8、 安装Apache和Tomcat连接 <br /></p><pre>tarzxvftomcat-connectors-1.2.18-src.tar.gz
<br />cdtomcat-connectors-1.2.18-src/native/
<br />./configure--with-apxs=/usr/local/apache/bin/apxs
<br />make&&makeinstall</pre><p><br />三、 配置httpd.conf <br /></p><pre>cd/usr/local/conf/
<br />vihttpd.conf</pre><p><br />1、 注释掉一下几行 <br /></p><pre>#ServerAdminyou@example.com
<br />#ServerNamewww.example.com:80
<br />#DocumentRoot"/usr/local/apache/htdocs"</pre><p><br />2、 修改里面相关内容 <br />A、</p><pre><Directory/>
<br />OptionsFollowSymLinks
<br />#AllowOverrideNone
<br />AllowOverrideall
<br />Orderdeny,allow
<br />#Denyfromall
<br />Allowfromall
<br /></Directory></pre><p><br />B、</p><pre>#<Directory"/usr/local/apache/htdocs">
<br /><Directory"/usr/local/tomcat/webapps">
<br />#
<br />#PossiblevaluesfortheOptionsdirectiveare"None","All",
<br />#oranycombinationof:
<br />#IndexesIncludesFollowSymLinksSymLinksifOwnerMatchExecCGIMultiViews
<br />#
<br />#Notethat"MultiViews"mustbenamed*explicitly*---"OptionsAll"
<br />#doesn'tgiveittoyou.
<br />#
<br />#TheOptionsdirectiveisbothcomplicatedandimportant.Pleasesee
<br />#[url]http://httpd.apache.org/docs/2.2/mod/core.html#options[/url]
<br />#formoreinformation.
<br />#
<br />#OptionsIndexesFollowSymLinks
<br />#
<br />#AllowOverridecontrolswhatdirectivesmaybeplacedin.htaccessfiles.
<br />#Itcanbe"All","None",oranycombinationofthekeywords:
<br />#OptionsFileInfoAuthConfigLimit
<br />#
<br />AllowOverrideNone
<br />
<br />#
<br />#Controlswhocangetstufffromthisserver.
<br />#
<br />Orderallow,deny
<br />Allowfromall
<br />
<br /></Directory></pre><p><br />因为我这里将网站放在/usr/local/tomcat/webapps下 <br /><br />C、将</p><pre>#Includeconf/extra/httpd-vhosts.conf</pre><p>这行#除掉 <br /><br />3、 增加以下内容: <br />A、在AddTypeapplication/x-gzip.gz.tgz下增加以下两行 <br /></p><pre>AddTypeapplication/x-httpd-php.php.phtml
<br />AddTypeapplication/x-httpd-php-source.phps</pre><p><br />B、结尾增加 <br /></p><pre>#addmod_jkmodule
<br />LoadModulejk_modulemodules/mod_jk.so
<br />#Updatethispathtomatchyourmoduleslocation
<br />#Wheretofindworkers.properties
<br />#Updatethispathtomatchyourconfdirectorylocation(putworkers.propertiesnextto#httpd.conf)
<br />JkWorkersFile/usr/local/apache/conf/workers.properties
<br />#Wheretoputjklogs
<br />#Updatethispathtomatchyourlogsdirectorylocation(putmod_jk.lognexttoaccess_log)
<br />JkLogFile/usr/local/apache/logs/mod_jk.log
<br />#Setthejkloglevel[debug/error/info]
<br />JkLogLevelinfo
<br />#Selectthelogformat
<br />JkLogStampFormat"[%a%b%d%H:%M:%S%Y]"
<br />#JkOptionsindicatetosendSSLKEYSIZE,
<br />JkOptions+ForwardKeySize+ForwardURICompat-ForwardDirectories
<br />#JkRequestLogFormatsettherequestformat
<br />JkRequestLogFormat"%w%V%T"
<br />#Sendeverythingforcontext/examplestoworkernamedworker1(ajp13)
<br />JkMount/*.jspworker1</pre><p><br /><br />C、在/usr/local/apache/conf下增加一个workers.properties文件,内容如下: <br /></p><pre>#Define1realworkerusingajp13
<br />worker.list=worker1
<br />#Setpropertiesforworker1(ajp13)
<br />worker.worker1.type=ajp13
<br />worker.worker1.host=localhost
<br />worker.worker1.port=8009
<br />worker.worker1.lbfactor=50
<br />worker.worker1.cachesize=10
<br />worker.worker1.cache_timeout=600
<br />worker.worker1.socket_keepalive=1
<br />worker.worker1.reclycle_timeout=300</pre><p><br />D、再编辑/usr/local/apache/conf/extra/下httpd-vhosts.conf文件 <br /></p><pre>vihttpd-vhosts.conf</pre><p><br />将里面例子修改一下 <br /></p><pre><VirtualHost192.168.0.170:80>
<br /><Directory"/usr/local/tomcat/webapps/ROOT">
<br />DirectoryIndexindex.htmindex.htmlindex.jspindex.php
<br /></Directory>
<br />ServerAdminxxx@126.com
<br />DocumentRoot/usr/local/tomcat/webapps/ROOT
<br />ServerName192.168.0.170
<br />ErrorLoglogs/170-error_log
<br />CustomLoglogs/170-access_logcommon
<br /></VirtualHost></pre><p><br />因为没有做域名解析,我这里在ServerName下直接用的是IP地址。 <br />四、 测试 <br />先启动tomcat,再启动apache。启动apache之前可以到apache/bin下测试一下虚拟域是否配置正确。./httpd–S如果配置有错误会提示你。 <br />没有问题后,在IE地址栏输入[url]http://192.168.0.170[/url]此时将显示的是tomcat的默认界面,证明可以正常访问jsp文件了。再将/usr/local/tomcat/webapps/ROOT下index.jsp换一个index.php文件,只要在index.php里输入以下内容即可测试: <br /></p><pre><?echophpinfo()?></pre><p>重启apache,再在IE地址栏输入[url]http://192.168.0.170[/url]将能看到php的相关信息。 <br />主要参考文章有: <br />[url]http://www.chinaunix.net/jh/13/669895.html[/url] <br />[url]http://www.chinaunix.net/jh/13/770898.html[/url] <br />[url]http://httpd.apache.org/docs/2.2/[/url]<br /></p>
页:
[1]
