在论坛里看了许多相关帖子,自己也实验了多次,终于在前几天测试成功,感谢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下。
先解压:
tar xvfz httpd-2.2.2.tar.gz
cd httpd-2.2.2
首先可以看看里面的安装说明INSTALL和README。
在安装apache之前先安装apr-util-1.2.7.tar.gz和apr-1.2.7.tar.gz
首先安装apr。
tar xvfz apr-1.2.7.tar.gz
cd apr-1.2.7
./configure --prefix=/usr/local/apr-httpd
make
make install
cd ..
再安装apr-util-1.2.7.tar.gz
tar xvfz apr-util-1.2.7.tar.gz
cd apr-util-1.2.7
./configure --prefix=/usr/local/apr-util-httpd --with-apr=/usr/local/apr-httpd
make
make install
3、 接下来继续安装apache
cd ../httpd-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
make
make install
如果没有报错,apache基本安装完毕。
4、 安装JDK
回到local目录下:
cd ..
./jdk-1_5_0_07-linux-i586.bin
ln –s jdk1.5.0_07 jdk
设置JDK环境变量
vi /etc/profile
再文件尾部增加以下几句:
JAVA_HOME=/usr/local/jdk
JRE=$JAVA_HOME/jre
LC_ALL=zh_CN.GBK
PATH=$JAVA_HOME/bin:$JRE/bin:$PATH
CLASSPATH=.:$JAVA_HOME/bin/tools.jar:$JAVA_HOME/lib/dt.jar
export JAVA_HOME JRE LC_ALL CLASSPATH PATH
5、 安装MYSQL
tar xvfz mysql-5.0.22.tar.gz
cd mysql-5.0.22
./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
make
make install
groupadd mysql
useradd -g mysql mysql
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 &
mysqladmin –uroot password new-password
6、 安装php
tar xvfz php-5.1.4.tar.gz
cd php-5.1.4
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
make && make install
cp php.ini-dist /usr/local/lib/php.ini
7、 安装tomcat
tar xvfz apache-tomcat-5.5.15.tar.gz
mv apache-tomcat-5.5.15 tomcat
8、 安装Apache和Tomcat连接
tar zxvf tomcat-connectors-1.2.18-src.tar.gz
cd tomcat-connectors-1.2.18-src/ native/
./configure --with-apxs=/usr/local/apache/bin/apxs
make && make install
三、 配置httpd.conf
cd /usr/local/conf/
vi httpd.conf
1、 注释掉一下几行
#ServerAdmin you@example.com
#ServerName www.example.com:80
#DocumentRoot "/usr/local/apache/htdocs"
2、 修改里面相关内容
A、
Options FollowSymLinks
# AllowOverride None
AllowOverride all
Order deny,allow
# Deny from all
Allow from all
B、
#
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
因为我这里将网站放在/usr/local/tomcat/webapps下
C、将
#Include conf/extra/httpd-vhosts.conf
这行#除掉
3、 增加以下内容:
A、在AddType application/x-gzip .gz .tgz下增加以下两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
B、结尾增加
#add mod_jk module
LoadModule jk_module modules/mod_jk.so
# Update this path to match your modules location
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to #httpd.conf)
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /usr/local/apache/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /*.jsp worker1
C、在/usr/local/apache/conf下增加一个workers.properties文件,内容如下:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.reclycle_timeout=300
D、再编辑/usr/local/apache/conf/extra/下httpd-vhosts.conf文件
vi httpd-vhosts.conf
将里面例子修改一下
DirectoryIndex index.htm index.html index.jsp index.php
ServerAdmin xxx@126.com
DocumentRoot /usr/local/tomcat/webapps/ROOT
ServerName 192.168.0.170
ErrorLog logs/170-error_log
CustomLog logs/170-access_log common
因为没有做域名解析,我这里在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里输入以下内容即可测试:
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/
说明:实现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下。
先解压:
tar xvfz httpd-2.2.2.tar.gz
cd httpd-2.2.2
首先可以看看里面的安装说明INSTALL和README。
在安装apache之前先安装apr-util-1.2.7.tar.gz和apr-1.2.7.tar.gz
首先安装apr。
tar xvfz apr-1.2.7.tar.gz
cd apr-1.2.7
./configure --prefix=/usr/local/apr-httpd
make
make install
cd ..
再安装apr-util-1.2.7.tar.gz
tar xvfz apr-util-1.2.7.tar.gz
cd apr-util-1.2.7
./configure --prefix=/usr/local/apr-util-httpd --with-apr=/usr/local/apr-httpd
make
make install
3、 接下来继续安装apache
cd ../httpd-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
make
make install
如果没有报错,apache基本安装完毕。
4、 安装JDK
回到local目录下:
cd ..
./jdk-1_5_0_07-linux-i586.bin
ln –s jdk1.5.0_07 jdk
设置JDK环境变量
vi /etc/profile
再文件尾部增加以下几句:
JAVA_HOME=/usr/local/jdk
JRE=$JAVA_HOME/jre
LC_ALL=zh_CN.GBK
PATH=$JAVA_HOME/bin:$JRE/bin:$PATH
CLASSPATH=.:$JAVA_HOME/bin/tools.jar:$JAVA_HOME/lib/dt.jar
export JAVA_HOME JRE LC_ALL CLASSPATH PATH
5、 安装MYSQL
tar xvfz mysql-5.0.22.tar.gz
cd mysql-5.0.22
./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
make
make install
groupadd mysql
useradd -g mysql mysql
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 &
mysqladmin –uroot password new-password
6、 安装php
tar xvfz php-5.1.4.tar.gz
cd php-5.1.4
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
make && make install
cp php.ini-dist /usr/local/lib/php.ini
7、 安装tomcat
tar xvfz apache-tomcat-5.5.15.tar.gz
mv apache-tomcat-5.5.15 tomcat
8、 安装Apache和Tomcat连接
tar zxvf tomcat-connectors-1.2.18-src.tar.gz
cd tomcat-connectors-1.2.18-src/ native/
./configure --with-apxs=/usr/local/apache/bin/apxs
make && make install
三、 配置httpd.conf
cd /usr/local/conf/
vi httpd.conf
1、 注释掉一下几行
#ServerAdmin you@example.com
#ServerName www.example.com:80
#DocumentRoot "/usr/local/apache/htdocs"
2、 修改里面相关内容
A、
Options FollowSymLinks
# AllowOverride None
AllowOverride all
Order deny,allow
# Deny from all
Allow from all
B、
#
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
因为我这里将网站放在/usr/local/tomcat/webapps下
C、将
#Include conf/extra/httpd-vhosts.conf
这行#除掉
3、 增加以下内容:
A、在AddType application/x-gzip .gz .tgz下增加以下两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
B、结尾增加
#add mod_jk module
LoadModule jk_module modules/mod_jk.so
# Update this path to match your modules location
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to #httpd.conf)
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /usr/local/apache/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /*.jsp worker1
C、在/usr/local/apache/conf下增加一个workers.properties文件,内容如下:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.reclycle_timeout=300
D、再编辑/usr/local/apache/conf/extra/下httpd-vhosts.conf文件
vi httpd-vhosts.conf
将里面例子修改一下
DirectoryIndex index.htm index.html index.jsp index.php
ServerAdmin xxx@126.com
DocumentRoot /usr/local/tomcat/webapps/ROOT
ServerName 192.168.0.170
ErrorLog logs/170-error_log
CustomLog logs/170-access_log common
因为没有做域名解析,我这里在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里输入以下内容即可测试:
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/
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/556/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表