习惯性将东西都安装在/usr/local/下
一:安装apache
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# ./configure --prefix=/usr/local/apache --enable-module=so (module=so必须加上 否则后面编译php无法生成libphp5.so)
# make && make install
启动apache:
# /usr/local/apache/bin/apachectl start
IE访问,出现”It works!”,apache安装成功。
二:安装mysql,并配置
# tar zxvf mysql-5.0.22.tar.gz
# cd mysql-5.0.22
#./configure --prefix=/usr/local/mysql --with-charset=gb2312 --with-extra-charsets=all --with-named-curses-libs=/usr/lib/libncurses.so.5
配置成功出现“Thank you for choosing MySQL!”提示。
# make && make install
编译完毕。
# cp ./support-files/mysql.server /etc/init.d/mysqld
# groupadd mysql
# useradd -G mysql mysql
# chmod 777 /etc/init.d/mysqld
# /usr/local/mysql/bin/mysql_install_db //初始化数据库
# chown -R mysql:mysql /usr/local/mysql/data/
# service mysqld start //启动mysqld
# /usr/local/mysql/bin/mysqladmin –u root –p password 'rootpw' //设置密码为rootpw
Enter password: //默认密码为空,所以直接回车
# /usr/local/mysql/bin/mysql -u root -p
Enter password: //输入新密码后,登录成功
三:安装php
# tar zxvf php-5.2.10.tar.gz
# cd php-5.2.10
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache22/bin/apxs --with-mysql=/usr/local/mysql
# make && make test
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini //拷贝php配置文件
修改apache配置文件httpd.conf
# vi /usr/local/apache22/conf/httpd.conf
在#AddType application/x-tar.tgz下加一行:
AddType application/x-httpd-php .php
在#LoadModule foo_module modules/mod_foo.so下加一行: 如果原来有就去掉#号
LoadModule php5_module modules/libphp5.so
找到DirectoryIndex index.html在后面添加 index.php
保存httpd.conf文件.
重启动apache
# /usr/local/apache22/bin/apachectl stop
# /usr/local/apache22/bin/apachectl start
写一个测试页,放到apache的htdocs目录下,打开浏览器访问应该可以看到php的版本等信息。php测试页代码如下:
打开php测试页,查看是否有mysql项
四:安装JDK
#cd /usr/local/java
#chmod +x jdk-1_5_0_06-linux-i586.bin
# ./jdk-1_5_0_06-linux-i586.bin
#mv jdk-1_5_0_06
#vi /etc/profile
在该文件的末尾加上下面两行
export JAVA_HOME=/usr/local/java/jdk
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export JAVA_HOME CLASSPATH PATH CATALINA_HOME
使用# source /etc/profile 刷新文件
使用#java -version测试是否有版本信息 安装成功
五:安装Tomcat (类似JBoss,不需要安装,直接启动服务就可以)
#cd /usr/local/
#tar zxvf jakarta-tomcat-4.1.31.tar.gz
#mv jakarta-tomcat-4.1.31 tomcat
在/etc/profile文件最后加入如下一行
export CATALINA_HOME=/usr/local/tomcat
#/usr/local/tomcat/bin/shutdown.sh
#/usr/local/tomcat/bin/start.sh
访问 应该就会出来那个小猫我网页了
接下来就是端口整合
六:安装配置
[root@localhost bin]# cd /usr/local
[root@localhost local]# tar -zxvf jakarta-tomcat-connectors-1.2.13-src.tar.gz
为了简化操作
[root@localhost local]# mv jakarta-tomcat-connectors-1.2.13-src connector
进行编译配置,这几个参数中前三个是很重要的,必要时可以去相应的目录看看相关的文件是否存在。
[root@localhost local]# cd connector/jk/native
[root@localhost native]# ./buildconf.sh
[root@localhost native]#./configure --with-apxs=/usr/local/apache/bin/apxs --with-tomcat=/usr/local/tomcat --with-java-home=/usr/jdk --with-jni
[root@localhost native]#make
[root@localhost native]cd apache-2.0
[root@localhost apache-2.0]# /usr/local/apache/bin/apxs -n jk2 -i mod_jk.so
生成下列结果则正常:
/usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool' mod_jk2.so /usr/local/apache/modules
/usr/local/apache/build/libtool --mode=install cp mod_jk.so /usr/local/apache/modules/
cp mod_jk.so /usr/local/apache/modules/mod_jk.so
Warning! dlname not found in /usr/local/apache/modules/mod_jk.so.
Assuming installing a .so rather than a libtool archive.
[root@localhost apache-2.0]# cp mod_jk.so /usr/local/apache/modules/
[root@localhost apache-2.0]#chmod 755 /usr/local/apache/modules/mod_jk.so
[root@localhost apache-2.0]# ll /usr/local/apache/modules/mod_jk.so
-rwxr-xr-x 1 root root 709215 08-14 10:22 /usr/local/apache/modules/mod_jk.so
mod_jk.so生成成功了。
七:配置jsp
在Apache的conf目录中创建文件vim mod_jk.conf 和workers.properties
[root@localhost conf]# cd /usr/local/apache/conf
配置mod_jk.conf
[root@localhost conf]# vi mod_jk.conf
加入如下配置:
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# 将所有jsp、htm、action等请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /*.jsp worker1
JkMount /*.htm worker1
JkMount /*.action worker1
JkMount /*.do worker1
JKUnmount /*.html worker1
保存退出
配置workers.properties
[root@localhost conf]# vi workers.properties
加入如下配置:
#------start ---------
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
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.socket_timeout=300
# --------end ------------
保存退出
配置Apache的/usr/local/apache/conf/httpd.conf,使apache启动时加载mod_jk.so
[root@localhost conf]# cd /usr/local/apache/conf
[root@localhost conf]# vi httpd.conf
在LoadModule后加入下面三行
LoadModule jk_module modules/mod_jk.so
JkShmFile /usr/local/apache/logs/k2.shm
Include /usr/local/apache/conf/mod_jk.conf
完成
如果更改tomcat默认主目录tomcat/conf/server.xml
添加