Bootstrap

源码编译安装httpd 2.4

1、下载 Apache 源代码:

wget https://archive.apache.org/dist/httpd/httpd-2.4.54.tar

2、解压源代码:

tar -zxvf httpd-2.4.54.tar.gz

3、进入源代码目录:

cd httpd-2.4.54

4、安装开发工具组:

yum groupinstall "Development Tools" -y

5、安装所需的依赖库:

yum install gcc glibc apr-devel apr-util-devel pcre-devel openssl-devel expat-devel make -y

6、配置 Apache 服务器:

./configure --prefix=/usr/local/httpd \

--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi \
--with-zlib \

--with-pcre \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork 

7、编译和安装 Apache:

make -j 4 && make install

8、创建用户和组:

groupadd -r apache

useradd -r -g apache -s /sbin/nologin apache

9、编辑 Apache 配置文件:

vim /usr/local/httpd/conf/httpd.conf

修改如下:

10、编辑 Apache 服务文件:

vim /etc/init.d/httpd

11、修改权限:

chmod +x /etc/init.d/httpd

12、添加并启用服务:

chkconfig --add httpd
chkconfig httpd on

13、启动和检查服务状态:

service httpd start
service httpd status

;