linux 下apache2 安装
Apache安装要求
安装APR、APR-Util、PCRE,gcc-c++等包
Apache HTTP Server http://httpd.apache.org/download.cgi#apache24
APR and APR-Util包 http://apr.apache.org/download.cgi
- APR 1.4.8, released June 21, 2013
- APR-util 1.5.2, released April 4, 2013
- APR-iconv 1.2.1, released November 26, 2007
PCRE包 https://sourceforge.net/projects/pcre/files/pcre/
文档URL地址http://httpd.apache.org/docs/2.4/install.html
Apache安装过程
1.安装包gcc或gcc-c++
yum list gcc-c++
yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel libtool -y
2.安装包APR和APR-Util
tar -zxf apr-1.4.8.tar.gz
cd apr-1.4.8
mkdir /usr/local/apr
./configure --prefix=/usr/local/apr
make
make install
--验证
ls -lrt
mkdir /usr/local/apr-util
tar -zxf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
3.安装包PRCE
unzip pcre-8.33.zip
cd pcre-8.33
mkdir /usr/local/pcre
./configure --prefix= /usr/local/pcre--with-apr=/usr/local/apr/bin/apr-1-config
make
make install
4.安装Apache Http Server
tar zxvf httpd-2.4.6.tar.gz
cd httpd-2.4.6
./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install
5. 启动Apache服务
/usr/local/apache/bin/apachectl start
6、安装Tomcat-connectors(mod_jk.so模块)
tar zxvf tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src/native/
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=/usr/local/jdk
make && make install
检查/usr/local/apache/modules下是否有mod_jk.so ,如果没有就复制过去。
注意conf/httpd.conf文件中ServerName xxx.xxx.com:80需要改为ServerName 127.0.0.1:80,可以使用apactrl -t进行语法分析
7、优化Apache
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd #编辑此服务,将前三行修改为
#!/bin/bash
# chkconfig: 35 85 15
# description:Apache httpd
service httpd restart
chkconfig --add httpd
chkconfig --level 35 httpd on