Apache安裝要求html
安裝APR、APR-Util、PCRE,gcc-c++等包java
Apache HTTP Server http://httpd.apache.org/download.cgi#apache24c++
APR and APR-Util包 http://apr.apache.org/download.cgiapache
- 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/vim
文檔URL地址http://httpd.apache.org/docs/2.4/install.htmltomcat
Apache安裝過程bash
1.安裝包gcc或gcc-c++優化
yum list gcc-c++spa
yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel libtool -y.net
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
六、安裝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進行語法分析
七、優化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