总结源码安装步骤:
1>、利用wget下载
wget -c http://www.apache.org/dist/httpd/httpd-2.4.29.tar.gz (.bz2)
wget -c http://www.apache.org/dist/apr/apr-1.6.2.tar.gz (.bz2)
wget -c http://www.apache.org/dist/apr/apr-util-1.5.3.tar.gz (.bz2)
2>、 解压(对于不用的压缩对应不同的解压命令)
tar -zxvf apr-1.6.2.tar.gz (-jxvf --> .bz2)
tar -zxvf apr-util-1.5.3.tar.gz (-jxvf--> .bz2)
tar -zxvf httpd-2.4.29.tar.gz (-jxvf--> .bz2)
3>、安装编译(./configure --prefix=/安装目录 -参数)
apr:
cd apr-1.6.2
./configure --prefix=/usr/local/apr
apr-util:
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
apache:
cd httpd-2.4.29
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
4>、Make&&make install
make -j4 && make -j4 install
5>、配置(一般编辑文件的.conf)
一般按照自己的需求修改配置文件。文件完整路径: /usr/local/apache2/conf/httpd.conf
6>、重启服务
cd /usr/local/apache2/bin/ ./ apachectl start
解决:1. yum install libtool 2. 编辑apr的配置文件 vim configure注释 $RM "$cfgfile"
解决: yum install expat-devel
解决:yum install pcre pcre-devel
注: apr和apr-util尽量用稍低一点的版本!
yum install httpd httpd-devel 配置后 重启使用即可
yum安装和源码安装的区别:
用yum安装后的Apache配置文件具体位置:
/etc/httpd/ --------------------------Apache服务程序根目录
/etc/httpd/conf/httpd.conf --------- 主配置文件
/var/www/html --------------------- 网页文档默认根目录
/var/log/httpd/error_log ---------- 错误日志文件
/var/log/httpd/access_log -------- 访问日志文件
源码安装的目录文件(因为编译是文件目录不定所以就简单的写一下了):
主配置文件---------------编译时自己指定的目录--prefix=配置文件的路径
默认网页目录------------- 安装apache目录下的htdocs目录
日志文件位置-------------- 安装apache目录下的logs目录
apache服务程序的目录----------安装apache目录下的bin目录
总结: 源码安装其他软件 存在依赖关系时 先安装依赖软件之后./configure --help|grep xx 看看依赖软件怎么加入到该软件
#!/bin/bash
#describe: install and configure apache
#author:kange
#download apache apache-apr apache-apr-util
if [ ! -d "/tmp/soft" ]; then
mkdir -p /tmp/soft
fi
cd /tmp/soft/
echo "download http apr and apr-util"
wget -c http://www.apache.org/dist/httpd/httpd-2.4.29.tar.gz
#wget -c http://www.apache.org/dist/apr/apr-1.6.2.tar.gz
#wget -c http://apache.osuosl.org/apr/apr-1.6.3.tar.gz
wget -c http://www.apache.org/dist/apr/apr-1.6.3.tar.gz
#wget -c http://www.apache.org/dist/apr/apr-util-1.5.3.tar.gz
#wget -c http://apache.osuosl.org/apr/apr-util-1.6.1.tar.gz
wget -c http://www.apache.org/dist/apr/apr-util-1.6.1.tar.gz
echo "install the required plug-ins."
yum install libtool pcre pcre-devel expat-devel -y
#install apr software
echo "--install APR--"
tar -zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr #$RM "$cfgfile"
if [ $? -ne 0 ]; then
echo "configure failed,please check it out!"
exit -1
fi
make -j4
if [ $? -ne 0 ]; then
echo "make failed,please check it out!"
exit -1
fi
make -j4 install
#install apr-util software
echo "--install APR-util--"
cd ../
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
if [ $? -ne 0 ]; then
echo "configure failed,please check it out!"
exit -1
fi
make -j4
if [ $? -ne 0 ]; then
echo "make failed,please check it out!"
exit -1
fi
make -j4 install
#Install Apache Software
echo "--install HTTP--"
cd ../
tar -zxvf httpd-2.4.29.tar.gz
cd httpd-2.4.29
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
if [ $? -ne 0 ]; then
echo "configure failed,please check it out!"
exit -1
fi
make -j4
if [ $? -ne 0 ]; then
echo "make failed,please check it out!"
exit -1
fi
make -j4 install
#start apache web service
echo "restart httpd"
pkill httpd
/usr/local/apache2/bin/apachectl start