本文包括 apache 2.2.15安装笔记,apache2.4.2安装,apache 2.2.15安装笔记,apache+tomcat整合支持jsp,apache+resion支持JSP等。
apache 2.2.15安装笔记
下载httpd-2.2.15.tar.gz
http://www.apache.org/
有些版本有问题,configure编译不成功,提示缺少apr等安装包
tar cvzf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure--prefix=/usr/local/apache-2.2.15 --enable-so --enable-mods-shared=most --with-mpm=worker
(./configure--prefix=/usr/local/apache-2.2.15 --enable-so --enable-mods-shared=most --with-mpm=worker--enable-rewrite=shared --enable-proxy=shared)添加proxy支持
如果发现gcc没有装,先安装GCC
make
make install
vi httpd.conf
149 #
150 #DocumentRoot"/usr/local/apache-2.2.15/htdocs"
151 DocumentRoot"/home/wwwyd" 修改为程序页面目录
177 #<Directory"/usr/local/apache-2.2.15/htdocs">
178 <Directory"/home/wwwyd"> 修改为程序页面目录
160 <Directory />
161 Options FollowSymLinks
162 AllowOverride None
163 Order deny,allow
164 allow from all 确保allow from all
165 </Directory>
出现错误:Could notreliably determine the server's fully qualified domain name, using 127.0.0.1for ServerName
编辑httpd.conf文件,搜索"#ServerName",添加ServerNamelocalhost:80
apache2.4.2安装
编译安装apache httpd2.4.2
安装apache 提示APR not found 解决方法
方法一
1.下载apr安装包:
http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz
tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure--prefix=/usr/local/apr
make && makeinstall
2.下载apr-util安装包:
http://labs.mop.com/apache-mirror//apr/apr-util-1.4.1.tar.gz
tar zxvfapr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && makeinstall
3.下载pcre安装包:
http://cdnetworks-kr-2.dl.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.zip
unzip pcre-8.30.zip
cd pcre-8.30
./configure--prefix=/usr/local/pcre
make && make install
4.安装httpd包:
http://labs.mop.com/apache-mirror/httpd/httpd-2.4.2.tar.gz
tar zxvfhttpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure --prefix=/usr/local/apache2.4.2--enable-so --enable-rewrite --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/bin/pcre-config
make && makeinstall
安装完成。
方法二
http://httpd.apache.org/dev/dist/httpd-2.4.2-deps.tar.bz2
http://httpd.apache.org/dev/dist/httpd-2.4.2.tar.bz2
解压安装 已集成APR,需安装pcre支持。
安装pcre同上方法一3,
tar jxvfhttpd-2.4.2.tar.bz2
tar jxvf httpd-2.4.2-deps.tar.bz2
cd httpd-2.4.2
./configure--prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-pcre=/usr/local/pcre/bin/pcre-config
make && make install
安装完成
配置http.conf
52 Listen 80
156 User wwwyd
157 Group wwwyd
193 #<Directory />
194 # AllowOverride none
195 # Require all denied
196 #</Directory>
197 <Directory />
198 Options FollowSymLinks
199 AllowOverride None
200 Order deny,allow
201 allow from all
202 </Directory>
216 #DocumentRoot"/usr/local/apache2/htdocs"
217 DocumentRoot "/home/wwwyd"
apache+php+mysql+oracle
mysql-5.0.67.tar.gz
httpd-2.2.11.tar.gz
oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
php-5.2.9.tar.gz
http://211.151.66.86:8001/
一、安装MYSQL 5
2.4.15.1.Source Installation Overview
This section does not apply to MySQLEnterprise Server users.
The basic commands that you must execute toinstall a MySQL source
distribution are:
shell>groupadd mysql
shell>useradd -g mysql mysql
shell>gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell>cd mysql-VERSION
shell>./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-extra-charsets=all
shell>make
shell>make install
shell>cp support-files/my-medium.cnf /etc/my.cnf
shell>cd /usr/local/mysql
shell>chown -R mysql .
shell>chgrp -R mysql .
shell>bin/mysql_install_db --user=mysql
shell>chown -R root .
shell>chown -R mysql data
shell>bin/mysqld_safe --user=mysql &
二、安装apache
修改头文件参数:
viserver/mpm/worker/worker.c
#ifndefDEFAULT_SERVER_LIMIT
#defineDEFAULT_SERVER_LIMIT 16 --> 1000
#endif
#ifndefDEFAULT_THREAD_LIMIT
#defineDEFAULT_THREAD_LIMIT 64 --> 2560
#endif
-----
#./configure --prefix=/usr/local/apache2 --with-mpm=prefork --enable-so
#make
#make install
[root@web103apache2]# bin/apachectl -l
Compiledin modules:
............
prefork.c
............
mod_so.c
[root@web103apache2]#
三、Oracle Database Instant Client
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html
[root@web103software]# rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
Preparing... ######################## [100%]
1:oracle-instantclient-ba############################[100%]
[root@web103software]# rpm -ivh oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
Preparing... ################################ [100%]
1:oracle-instantclient-de###############################[100%]
[root@web103software]#
第一个 RPM 将 Oracle 库置于/usr/lib/oracle/10.2.0.4/client64/lib/ 中,
第二个 RPM 在/usr/include/oracle/10.2.0.4/client64/ 中创建头 (header)。
四、安装php
./configure --prefix=/usr/local/php5 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-gd \
--enable-mbstring \
--with-iconv \
--with-oci8=instantclient \
--enable-sigchild
make
makeinstall
cpphp.ini-dist /usr/local/lib/php.ini
注意:要是支持mysql必须先安装mysql
--with-mysql=/usr/local/mysql 使用目录,--with-mysql指定的跟rhel5的默认mysql包有兼容的冲突。
如果mysql是rpm安装,则不需要指定路径
--with-mysql
--without-iconv[=DIR] Exclude iconv support
--with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
--enable-mbstring Enable multibyte string support
--with-gd[=DIR] Include GD support. DIR is the GD library base
--with-mysql[=DIR] Include MySQL support. DIR is the MySQLbase directory
--with-oci8[=DIR] Include Oracle (OCI8) support. DIRdefaults to $ORACLE_HOME.
Use--with-oci8=instantclient,/path/to/oic/lib
for an Oracle InstantClient installation
--with-pdo-oci[=DIR] PDO: Oracle OCI support. DIR defaults to$ORACLE_HOME.
Use--with-pdo-oci=instantclient,prefix,version
for an OracleInstant Client SDK.
For Linux with10.2.0.3 RPMs (for example) use:
--with-pdo-oci=instantclient,/usr,10.2.0.3
--enable-sigchild Enable PHP's own SIGCHLD handler
五、编辑httpd.conf
确认存在这一行:
LoadModulephp5_module modules/libphp5.so
添加:
AddTypeapplication/x-httpd-php .php
AddTypeapplication/x-httpd-php-source .phps
修改DirectoryIndex
<IfModuledir_module>
DirectoryIndex index.html
</IfModule>
变为:
<IfModuledir_module>
DirectoryIndex index.php index.html
</IfModule>
六、设置环境
(1)/etc/profile
PATH=/usr/local/php5/bin:$PATH
LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client64/lib/:${LD_LIBRARY_PATH}
TNS_ADMIN=/home
exportLD_LIBRARY_PATH TNS_ADMIN
(2)创建文件tnsnames.ora
[root@web103lib]# cat /home/tnsnames.ora
MESDB=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =211.151.66.89)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = mesdb)
)
)
[root@web103lib]#
七、测试
(1)测试php
[root@web103conf]# cat /usr/local/apache2/htdocs/index.php
<?php
phpinfo();
?>
[root@web103conf]#
http://211.151.66.86:8001/index.php
(2)测试oracle
[root@web103htdocs]# cat testoci.php
<?php
$conn= OCILogon("jxpush", "PASSWORD",'//211.151.66.89:1521/MESDB');
$query= 'select table_name from user_tables';
$stid= OCIParse($conn, $query);
OCIExecute($stid,OCI_DEFAULT);
while($succ = OCIFetchInto($stid, $row)) {
foreach($row as $item) {
echo$item." ";
}
echo"<br>\n";
}
OCILogoff($conn);
?>
[root@web103htdocs]#
注意:
$conn= OCILogon("ORACLEUSER", "PASSWORD",'//211.151.66.89:1521/ORACLE_SERVICE_NAME');
http://211.151.66.86:8001/index.php
http://211.151.66.86:8001/testoci.php
八、配置用户系统
(1)添加用户 jxpush, 并创建目录htdocs
(2)修改httpd.conf
Userjxpush
Groupjxpush
#DocumentRoot"/usr/local/apache2/htdocs"
DocumentRoot"/home/jxpush/htdocs"
#<Directory"/usr/local/apache2/htdocs">
<Directory"/home/jxpush/htdocs">
注意:如果出现问题,编辑php.ini
/usr/local/lib/php.ini
将php.ini中
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;extension=php_oci8.dll
前的分号(;)去掉
重起apache
九、php添加jpeg支持
如果在安装php前没添加jpeg支持
一般源码安装添加的GD库 是不支持 jpeg 格式的图片的,只支持如下格式
GDSupport enabled
GDVersion bundled (2.0.34 compatible)
GIFRead Support enabled
GIFCreate Support enabled
PNGSupport enabled
libPNGVersion 1.2.49
WBMPSupport enabled
XBMSupport enabled
下面们来 添加 jpeg 格式文件的支持
wgethttp://www.ijg.org/files/jpegsrc.v8b.tar.gz
tar-zxvf jpegsrc.v8b.tar.gz
cdjpeg-8b
./configure--prefix=/usr/local/jpeg --enable-shared --enable-static
make&& make install
重新编译和安装php
makeclean
./configure --prefix=/usr/local/php5 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-gd \
--with-jpeg-dir=/usr/local/jpeg \
--enable-mbstring \
--with-iconv \
--enable-sigchild
查看php信息
/usr/local/php5/bin
./php-r 'phpinfo();' >> b.txt
apache+tomcat整合支持jsp
1、准备
到Apache官方网站下载所需要的文件:
httpd-2.2.15.tar.gz
apache-tomcat-5.5.23.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz
2、安装
apache, tomcat
tar cvzf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure--prefix=/usr/local/apache-2.2.15 --enable-so --enable-mods-shared=most --with-mpm=worker
(./configure--prefix=/usr/local/apache-2.2.15 --enable-so --enable-mods-shared=most--with-mpm=worker --enable-rewrite=shared --enable-proxy=shared)添加proxy支持
tarxvzf apache-tomcat-5.5.23.tar.gz
mv apache-tomcat-5.5.23tomcat5
vi.bash_profile
exportCATALINA_BASE=/usr/local/tomcat5
exportCATALINA_HOME=/usr/local/tomcat5
exportCATALINA_TMPDIR=/usr/local/tomcat5/temp
3、编译生成mod_jk
#tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
#cd jakarta-tomcat-connectors-1.2.15-src/jk/native
#./configure --with-apxs=/usr/local/apache2/bin/apxs
#make
#cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/
4、配置
apache
在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
#vi mod_jk.conf
添加以下内容:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile/usr/local/apache2/conf/workers.properties
#Where to put jk logs
JkLogFile/usr/local/apache2/logs/mod_jk.log
#Set the jk log level [debug/error/info]
JkLogLevelinfo
#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"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount/servlet/* worker1
JkMount/*.jsp worker1
#vi workers.properties
添加以下内容:
#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
配置httpd.conf,作以下修改:
40Listen 13800
153ServerName localhost:13800
160DocumentRoot "/home"
169<Directory />
170 Options FollowSymLinks
171 AllowOverride None
172 Order deny,allow
173 allow from all
174</Directory>
187<Directory "/home">
200 Options Indexes FollowSymLinks
207 AllowOverride None
212 Order allow,deny
213 Allow from all
215</Directory>
216<Directory "/home/WEB-INF">
217 Order deny,allow
218 Deny from all
219</Directory>
增加关于加载mod_jk的语句:
106LoadModule jk_module modules/mod_jk.so
107Include /usr/local/apache-2.2.15/conf/mod_jk.conf
启动和关闭
/usr/local/apache-2.2.15/bin
./apachectlstop
./apachectlstart
tomcat
编辑Tomcat的配置文件server.xml,修改端口号。
77 <Connector port="13801" maxHttpHeaderSize="8192"
78 maxThreads="150"minSpareThreads="25" maxSpareThreads="75"
79 enableLookups="false"redirectPort="8443" acceptCount="100"
80 connectionTimeout="20000" disableUploadTimeout="true"/>
修改程序目录
203 <Context path="/"docBase="/home/apache" debug="0"reloadable="true" crossContext="true"/>
启动和关闭
/usr/local/tomcat5/bin
./shutdown.sh
./startup.sh
5、测试
/home目录下建立index.jsp,index.html文件
整合前
http://192.168.1.18:13800/index.html显示apache测试页
http://192.168.1.18:13801显示tomcat测试页
整合后
http://192.168.1.18:13800/index.jsp显示tomcat测试页
(默认显示tomcat系统页/usr/local/tomcat5/webapps/ROOT工程,更改为/usr/local/tomcat5/webapps/ROOTbak后可显示测试页)
apache+resion支持JSP
apache与resion整合支持JSP
一)下载j2dsk-1.4.0.i586.bin
resion-3.0
apache
二)安装
chmod 755j2dsk-1.4.0.i586.bin
./j2dsk-1.4.0.i586.bin
mv j2dsk-1.4.0/usr/java
vi /etc/profile
在最后加上:
unset i
exportJAVA_HOME=/usr/java
exportRESIN_HOME=/home/tramp //resion的安装目录
保存退出
tar xzvfhttpd-2.0.52.tar.gz
cd httpd-2.0.52
./configure--prefix=/usr/local/apache2 --enable-so --enable-rewrite=shared
make;make install
四)编译RESION
tar xzvf resion-3.0.tar.gz
cd resion-3.0
./configure--with-apxs=/usr/local/apache2/bin/apxs--with-apache-libexec=/usr/local/apache2/modules--with-apache-conf=/usr/local/apache2/conf
make;make install
vi resion.conf
修改如下:
<document_directory>/usr/local/apache2/htdocs</document>
重启RESION与apache
/sbin/httpd.sh //在resion bin下有个httpd.sh
vi/usr/local/apache2/htdocs/test.jsp
<%=2+2%>
测试页
apache_ProxyPass
<VirtualHost*:80>
ServerName 120.72.43.41
ProxyPass /test/ http://120.72.43.41:8080/test/
ProxyPass /miscapp/ http://120.72.43.41:8090/
</VirtualHost>
apache_基于端口的访问
设置 192.168.0.32 提供多个端口提供不同的web service
vi/etc/httpd/conf/httpd.conf
#Listen 80
Listen 9001
Listen 9002
<VirtualHost192.168.0.32:9001>
DocumentRoot /www1
ErrorLog logs/port-9001-error_log
CustomLog logs/port-9001-access_log common
</VirtualHost>
<VirtualHost192.168.0.32:9002>
DocumentRoot /www2
ErrorLog logs/port-9002-error_log
CustomLog logs/port-9002-access_log common
</VirtualHost>
[root@rhdb2 conf]#
[root@rhdb2 conf]#mkdir /www1 /www2
[root@rhdb2 conf]# cd/www1
[root@rhdb2 www1]#echo "192.168.0.32:9001" > index.html
[root@rhdb2 www1]# cd/www2
[root@rhdb2 www2]#echo "192.168.0.32:9002" > index.html
[root@rhdb2 www2]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@rhdb2 www2]#
Apache配置信息
1、可以通过 apachectl -v 查看apache是否安装,如果安装了的话会显示版本号;
2、如果通过rpm包安装的话可以用 rpm -q httpd 查看,如果安装的的话会显示包的名称
如果采用RPM包安装,安装路径应在 /etc/httpd目录下
apache配置文件:/etc/httpd/conf/httpd.conf
Apache模块路径:/usr/sbin/apachectl
web目录:/var/www/html
欢迎关注我的公众号 扫描二维码或公众号搜索 “我的工作”





