源码编译安装httpd

时间:2020-05-30
本文章向大家介绍源码编译安装httpd ,主要包括源码编译安装httpd 使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.准备工作

1.1依赖apr及apr-util1.4以上

description:apache可移值运行环境(portable runtime),提供了一个C数据结构及程序的自由库,以达到一个系统可移植层到尽可能多的系统。类似于tomcat的运行环境JVM

1.2 编译安装apr-util-1.6.1、apr-1.7.0为例

tar xf apr-1.7.0.tar.bz2  
cd apr-1.7.0  
./configure  --prefix=/usr/local/apr  
make  
make install   

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/       #指定 apr的安装路径  
make  
make install    

2. 编译安装httpd

安装依赖库pcre-devel openssl-devel

yum –y install pcre-devel openssl-devel 
tar xf httpd-2.4.41.tar.bz2  
cd httpd-2.4.41  
./configure --prefix=/usr/local/apache  --enable-so --enable-rewrite --enable-ssl  --enable-cgi  --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/  
make  
make install  

添加环境变量
echo “export PATH=$PATH:/usr/local/apache/bin” >> /etc/profile.d/httpd.sh

3. 源码编译安装php

3.1准备工作

yum -y install libxml2 libxml2-devel bzip2 bzip2-devel  
rpm -ivh libmcrypt-devel-2.5.8-13.el7.x86_64.rpm  
rpm -ivh libmcrypt-devel-2.5.8-13.el7.x86_64.rpm  

3.2 编译安装

tar xf httpd-2.4.41.tar.bz2  
cd httpd-2.4.41  
./configure --prefix=/usr/local/php --with-mysqli --with-openssl \  
--enable-mbstring  \              #muti byte string  
--with-freetype-dir --with-jpeg-dir  --with-png-dir --with-zlib  --with-libxml-dir=/usr --enable-xml --enable-sockets  \  
--with-apxs2=/usr/local/apache/bin/apxs    \   #指定勾子函数路径,php模块化  
--with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d  --with-bz2  \  
--enable-maintainer-zts         #支持线程,即worker与event工作模型  
[--enbale=fpm]                  #支持fcgi,如果不使用模块化,编译此  

3.3编辑配置

cp php.ini-production /etc/php.ini   创建php的配置文件  
关联apache  
sed -i "/\<AddType application\/x-gzip .gz .tgz\>/a \    AddType application/x-httpd-php .php\n    AddType   application/x-httpd-php-source .phps"  httpd.conf  
sed  -i  '/DirectoryIndex index.html/ s/$/\ index.php/ '  httpd.conf

原文地址:https://www.cnblogs.com/zoer/p/12992835.html