首页 > 学技术 > 技术网文 > Web服务器 > 正文

[精彩] RH4apache2+openssl+php+mysql+tomcat2.5配置说明


来源 chinaunix.net 酷勤网整理

Redhat AS 4(安装系统时添加了所有的编译工具)
apache2.05+openssl0.97e+php4.0+mysql4.1+tomcat2.5+jdk1.42+jk2

1)安装 openssl   http://www.openssl.org/source/
# tar -zxvf openssl-0.9.7e.tar.gz
# cd openssl-0.9.7e
# ./config
# make
# make install
我的这一过程未出现任何错误。
此时生成的openssl 库是静态的。Openssl 的安装路径是/usr/local/ssl
注:使用openssl-0.9.8.tar.gz时apache编译时会出现如下错误
ssl_engine_pphrase.c:684: error: `PEM_F_DEF_CALLBACK' undeclared (first use in this function) 
ssl_engine_pphrase.c:684: error: (Each undeclared identifier is reported only once 
ssl_engine_pphrase.c:684: error: for each function it appears in.) 
make[3]: *** [ssl_engine_pphrase.lo] Error 1 
make[3]: Leaving directory `/soft/httpd-2.0.54/modules/ssl' 
make[2]: *** [all-recursive] Error 1 
make[2]: Leaving directory `/soft/httpd-2.0.54/modules/ssl' 
make[1]: *** [all-recursive] Error 1 
make[1]: Leaving directory `/soft/httpd-2.0.54/modules' 
make: *** [all-recursive] Error 1
如果有知道原因的请告知解决办法,万分感谢
2)安装apache(httpd-2.0.54.tar.gz)   http://www.apache.org
# tar -zxvf httpd-2.0.54.tar.gz
# ./configure --prefix=/usr/local/httpd --enable-so --enable-ssl=static --enable-mods-shared=all --with-ssl=/usr/local/ssl
make
make install
在apache安装的根目录下的/bin下运行 ./apachectl startssl
注:不知道为什么此时用./apachectl start apache能以启动,但是不能访问,浏览器总是显示该业无法显示!!!
如果有知道原因的请告知解决办法,万分感谢!!!
如果你启动时出现 httpd: Could not determine the server's fully qualified domain name, using
127.0.0.1 for ServerName
只需要编辑 httpd.conf,找到 ServerName xxxx 这一行,去掉前面的注释,并把里面改成你的域名或 IP 即可。

3)证书生成

cd /usr/local/ssl/bin
openssl req -new -x509 -days 365 -nodes -out ssl.key -keyout ssl.key
这将会创建一个自己给自己签名
参数的含义:
-days 365
使这个证书的有效期是 1 年,之
-new
创建一个新的证书
-x509    
创建一个 X509 证书(自己签名
-nodes
这个证书没有密码
-out ssl.key
把 SSL 证书公钥写到哪里
-keyout ssl.key
把 SSL 私钥放到这个文件中
# cd /usr/local/httpd/conf/
# mkdir ssl.crt
# mkdir ssl.key
# touch ssl.crt/server.crt
# touch ssl.key/server.key
分别把 ssl.key 中的公钥、私钥拷贝到这两个文件中,server.crt 拷公钥,server.key 拷私钥
到此,证书建立完毕。
注意此时生成的只有ssl.key


-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----
之间的内容拷贝到server.key

-----BEGIN CERTIFICATE-----


-----END CERTIFICATE-----
之间的内容拷贝到server.crt

修改/usr/local/httpd/conf/ssl.conf
在最后一行加入
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
含义我也不太清楚,请高手能否说明一下其中的含义,谢谢

4)安装mysql 我用的是mysql.4.14.tar.gz  http://www.mysql.com
我用的是tar包安装的
安装法详细地可以看INSTALL-BINARY
以下是我的安装步骤:
groupadd mysql
     useradd -g mysql mysql
     tar –zxvf mysql.4.14.tar.gz
     cd mysql.4.14.tar.gz
     ./configure --prefix=/usr/local/mysql
     make
     make install
     cp support-files/my-medium.cnf /etc/my.cnf
     cd /usr/local/mysql
     bin/mysql_install_db --user=mysql
     chown -R root  .
     chown -R mysql var
     chgrp -R mysql .
     bin/mysqld_safe --user=mysql &
启动mysql
/usr/local/mysql/share/mysql/mysql.server start

5)安装php4.40
tar zxvf php-4.4.0.tar.gz
cd php-4.4.0
./configure --prefix=/usr/local/php --with-config-filepath=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-openssl=/usr/local/ssl
--with-mysql=/usr/local/mysql (这是tar包模式)
rpm模式
./configure --prefix=/usr/local/php --with-config-filepath=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-openssl=/usr/local/ssl 
--with-apxs2=/usr/local/httpd/bin/apxs --with-openssl=/usr/local/ssl

make
make install

更改apache的配制文件:得加几行,目的是让apache能解释php程序。 
查找AddType application/x-tar .tgz 行,在下面添加 
AddType application/x-httpd-php .php 
AddType application/x-httpd-php .php3 
AddType application/x-httpd-php .phtml 
AddType application/x-httpd-php-source .phps 
找到下面一行在后面加上index.php,这表示网站的默认页也能够为index.php 
DirectoryIndex index.html index.html.var index.php
5)安装jdk
./j2sdk-1_4_2-linux-i586.bin
移动jdk1.5.0_03到/usr/local/下
mv jdk1.5.0_03 /usr/local
建立/usr/local/下的jdk连接
# ln -s /usr/local/jdk1.5.0_03 /usr/local/jdk
设置环境变量在/etc/profile文件的最后添加
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib
6)安装tomcat (我的版本是jakarta-tomcat-5.0.30.tar.gz)
tar –zxvf jakarta-tomcat-5.0.30.tar.gz –C /www/    (我的是www你可以确定自己的目录)
修改环境变量
我的是/etc/profile在最后一行加入(我的时装在了/www/tomcat目录)
export CATALINA_HOME=/www/tomcat
你的tomcat所在的目录.
启动tomcat
/usr/local/jakarta-tomcat-5.5.9/bin/startup.sh
7)安装jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
tar –zxvf  jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.4-src
./configure --with-apxs2=/usr/local/httpd2/bin/apxs
make
cd ../build/jk2/apache2/
cp *.so /usr/local/httpd2/modules/
8)配置过程
修改安装目录下的/conf/httpd.conf
在LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php4_module        modules/libphp4.so
下面添加LoadModule jk2_module modules/mod_jk2.so  
在你的安装目录下的/conf/创建workers2.properties,内容如下
[logger]  
level=ERROR 
[config:]  
file=/www/conf/workers2.properties  (此处改为你安装目录下的/conf/下的workers2.properties 我的装在了/www/conf)
debug=0  
debugEnv=0
# Alternate file logger  
[logger.file]  
#level=DEBUG  
level=ERROR  
file=/var/log/httpd/jk2.log 
[shm:]  
info=Scoreboard. Required for reconfiguration and status with multiprocess servers 
file=/var/log/httpd/jk2.shm
size=1048576 
debug=0
disabled=0
[channel.socket]  
info=Ajp13 forwarding over socket 
debug=0 
tomcatId=localhost:8009
keepalive=1
[ajp13] 
channel=channel.socket:localhost:8009
debug=0
[status:]
info=Status worker, displays runtime informations
[uri:/jkstatus/*]  
info=Display status information and checks the config file for changes. 
worker=ajp13:localhost:8009
[uri:/*.jsp]  
worker=ajp13:localhost:8009
context=/

修改/www/tomcat/conf/server.xml  (你的tomcat 的安装目录下的/conf/server.xml
在  
<Host name="localhost" debug="0" appBase="apps"  
unpackWARs="true" autoDeploy="true">;  
段中添加:  
<Context path="" docBase="/var/www/html" debug="0"  
reloadable="true" crossContext="true"/>;  
保存退出。  
附jsp测试脚本
<html>;
<head>;<title>;jsp</title>;</head>;
<body>;
<I>;<%out.println("hello world");%>;</I>;
</body>;</html>;



 sword_111 回复于:2005-09-07 08:28:36

我以后将在添加tomcat虚拟主机,vsftpd+mysql验证方式,mail服务器等争取打造成一个完整的服务器,我也是新手,大多东西都来自网络,希望大家多多支持:)


 saxon 回复于:2005-09-07 10:02:30

嘿嘿,不错,顶一下


 haoyufu 回复于:2005-09-07 10:09:17

8错,兄弟支持


 hfh08 回复于:2005-09-08 12:29:49

谢了 收藏


 sword_111 回复于:2005-09-09 10:06:21

关于虚拟主机与用户验证部分http://bbs.chinaunix.net/forum/viewtopic.php?t=608645&show_type=


 sword_111 回复于:2005-09-09 20:27:51

关于整合tomcat的更正
7)安装jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz 
tar –zxvf  jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz 
cd jakarta-tomcat-connectors-jk2-2.0.4-src 
./configure --with-apxs2=/usr/local/httpd2/bin/apxs 
此配置文件在jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2



 bjchenxu 回复于:2005-09-12 14:47:33

lz真是一个新手呀,不过勇气可嘉!

回答你的几个问题吧
1. 关于openssl 0.98的问题,问题是0.98版中将变量名称改了
解决方案参见
http://www.num5.com/docs/5587.html
3. RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
含义是这样的:为了让用户访问传统的http://转到https://上来,用了一下rewrite规则:
第一句:启动rewrite引擎
第二句:rewrite的条件是访问的服务器端口不是443端口
第三句:这是正则表达式,^是开头,$是结束,(.*)?是任何数量的任意字符
整句的意思是讲:启动rewrite模块,将所有访问非443端口的请求,url地址内容不变,将http://变成https://。

结束

(BTW,ssl模块编译成动态模块也可以)


 sword_111 回复于:2005-09-13 11:12:57

谢谢。楼上的帮助:)


 ericfanstudio 回复于:2005-09-15 17:24:42

有个问题想问一下;我按楼主的方法安装了一下,整个过程都顺利,就是我把测试的jsp页面放到tomcat的/examples下运行http://10.200.50.243:8080/examples/test.jsp时是正常的,但把他放到apache的htdocs下时运行http://10.200.50.243/test.jsp则没有反应,请问哪里出问题啦?请各位指教,谢谢!!急~~~~~~


 xiaojao 回复于:2005-09-23 14:52:47

在httpd.conf中增加alias /examples  $TOMCAT_HOME/webapps/examples


 GOD_Father 回复于:2006-01-09 05:09:41

/$




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=607020
转载请注明作者名及原文出处



收藏本页到: