apache2.05+openssl0.97e+php4.0+mysql4.1+tomcat2.5+jdk1.42+jk2 其他功能以后逐步添加:) 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 % !^443$ RewriteRule ^(.*)?$ https://%/ [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:localhost:8009] info=Ajp13 forwarding over socket debug=0 tomcatId=localhost:8009 keepalive=1 [ajp13:localhost:8009] 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> # /usr/local/httpd2/bin/httpd -l
CODE: [Copy to clipboard] Compiled in modules: core.c mod_access.c mod_auth.c mod_include.c mod_log_config.c mod_env.c mod_setenvif.c prefork.c http_core.c mod_mime.c mod_status.c mod_autoindex.c mod_asis.c mod_cgi.c mod_negotiation.c mod_dir.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_so.c
看到以上的信息表明apache支持dso方式了。 这样就可以用dso的方式把php和tomcat-connectors的模块加进来。
关于不加入tomcat 的虚拟主机及用户控制 虚拟主机这里的实验包括虚拟ip地址和更改端口两种。 注意不能用虚拟ip地址更改端口来做虚拟主机,如虚拟ip为192.168.0.101 虚拟主机为<Virtual Host 192.168.0.101:80 ….>
< /Virtual Host> 与<Virtual Host 192.168.0.101:81 ….>
< /Virtual Host> 访问是都是80所对应的目录,我也不清楚是为什么,请高手指教:) 1)创建虚拟ip 在/etc/sysconfig/network-scripts/下 cp ifcfg-eth0 ifcfg-eth0:0 创建一块虚拟网卡,eth0:此冒号后可以为任意数值。 vi ifcfg-eth0:0 我的内容如下: DEVICE=eth0:0(此处更改为你在cp时的编号) BROADCAST=192.168.0.255 HWADDR=00:0C:29:E9:7C:64 IPADDR=192.168.0.101 (改为与实际网卡不同的ip) NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes TYPE=Ethernet GATEWAY=192.168.0.1 然后重启网络 service network restart 关闭本页 |