Linux 脚本编译安装http-2.4.27版本
运行脚本前请将国内的比较快的基础源和epel源配置好,剩下就不用管了,运行脚本,半个小时左右自动编译安装完,并且大部分功能都已编译进去。绝对的懒人福利。适用系统为centos7和redhat7系列,下面上脚本源码:
#!/bin/bash
#auther zsk_john
yum install -y -q autoconf automake apr apr-devel apr-util apr-util-devel \
bison bzip2-devel cpp fontconfig-devel freetype-devel gcc gcc-c++ compat-dapl \
compat-db-headers compat-db47 compat-gcc-44 compat-gcc-44-c++ compat-glibc \
compat-glibc-headers compat-libcap1 compat-libf2c-34 compat-libgfortran-41 \
compat-libtiff3 compat-openldap ncurses-deveal wget met-tools bzip2 openssl-devel
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.bz2
tar -jxf `find / -name apr-1.5.2.tar.bz2`
cd apr-1.5.2/
./configure --prefix=/usr/local/apr
make && make install
cd ~ && wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.bz2
tar -jxf `find / -name apr-util-1.5.2.tar.bz2`
cd apr-util-1.5.2/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
echo "/usr/local/apr-util/lib
/usr/lib64">>/etc/ld.so.conf && ldconfig
cd ~ && wget http://archive.apache.org/dist/httpd/httpd-2.4.27.tar.bz2
tar -jxf `find / -name httpd-2.4.27.tar.bz2` -C /usr/local/src/
cd /usr/local/src/httpd-2.4.27/
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --enable-deflate --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-apr-util=/usr/local/apr-util
make && make install
echo "[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
EnvironmentFile=/etc/httpd/httpd.conf
ExecStart=/usr/local/apache/bin/apachectl
ExecRestart=/usr/local/apache/bin/apachectl restart
ExecStop=/usr/local/apache/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
" >/usr/lib/systemd/system/httpd.service
systemctl daemon-reload && systemctl enable httpd && systemctl start httpd
systemctl status httpd
记录一下隐藏apache-httpd的版本号方法:
修改源码包内的include目录下的ap_release.h文件, 打开该文件 ,将40行到47行的值修改为自己想要显示的值。
保存后,重新编译,编译完成后,修改httpd的主配置文件,httpd.conf,找到
包含httpd-default.conf的行,并解开注释。
vim /etc/httpd/extra/httpd-default.conf,打开这个文件
55 ServerTokens Full
65 ServerSignature On
为:
ServerTokens Prod
ServerSignature Off
重启httpd服务,使用curl命令测试
curl -I 当前IP/index.html
标签:compat,httpd,27,http,apr,--,usr,Linux,local From: https://blog.51cto.com/u_15966109/6082637