刚重装的centos7云服务器,现在重新部署lamp环境 , 官方文档 http://httpd.apache.org/docs/2.4/install.html
Apache篇
下载所需安装包
apr、apr-util、pcre这三个包是httpd编译安装依赖的包cd /usr/local/src/
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.33.tar.bz2
wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.3.tar.bz2
wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2
安装apr
yum install gcc gcc++ -y
tar -xf apr-1.6.3.tar.bz2
cd apr-1.6.3/
./configure --prefix=/usr/local/apr
make && make install
ls /usr/local/apr #检测是否安装成功
安装apr-util
yum install expat-devel -y #安装一个apr-util包需要的依赖
cd ..
tar -xf apr-util-1.6.1.tar.bz2
cd apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
ls /usr/local/apr-util
关于pcre
我的云服务器自带pcre-8.32版本,只需要yum安装devel版本就行,可以通过以下命令检测是否已经安装
rpm -qa pcre
所以我不需要再安装pcre,如果没有安装pcre通过以下命令cd ..
tar -xf pcre-8.42.tar.bz2
cd pcre-8.42/
./configure --prefix=/usr/local/pcre
make && make install
在我的安装过程中没有这一步,所以如果执行这个步骤,在后面的安装过程中需要适当的调整
yum安装pcre-devel包
yum install pcre-devel -y
安装httpd
cd ..
tar -xf httpd-2.4.33.tar.bz2
cd httpd-2.4.33/
cp -rf /usr/local/src/apr-1.6.3 /usr/local/src/httpd-2.4.33/srclib/apr
cp -rf /usr/local/src/apr-util-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr-util
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-so --with-pcre --with-included-apr
make && make install
如果是编译安装的pcre,替换configure命令,其他不变
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-so --with-pcre=/usr/local/pcre/ --with-included-apr