Centos6用源码安装apache

  • A+
所属分类:apache

下载apache:http://pan.baidu.com/s/1pLUxQkF

[root@localhost 123]# tar -zxf httpd-2.4.23.tar.gz

[root@localhost 123]# cd httpd-2.4.23

[root@localhost httpd-2.4.23]# ./configure --prefix=/usr/local/apache --enable-modules=most --enable-mods-shared=all --enable-so

--prefix=安装路径

--enable-modules=most 表示将大部分模块静态编译到httpd二进制文件中

--enable-mods-shared=all 表示动态加载所有模块,如果去掉-shared就是静态加载所有模块

--enable-so DSO模块自动启动

报错:configure: error: APR not found. Please read the documentation. (安装Apache的时候,为什么要安装apr和apr-util呢

安装apr

[root@localhost 123]# tar -zxvf apr-1.5.2.tar.gz

[root@localhost 123]# cd apr-1.5.2

[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr

报错 rm: cannot remove `libtoolT': No such file or directory config.status: executing default commands config.status: include/apr.h is unchanged

解决方法:

vim configure

#     $RM "$cfgfile"

[root@localhost apr-1.5.2]# make

[root@localhost apr-1.5.2]# make install

安装apr-util

[root@localhost 123]# tar -zxvf apr-util-1.5.4.tar.gz

[root@localhost 123]# cd apr-util-1.5.4

[root@localhost apr-util-1.5.4]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@localhost apr-util-1.5.4]# make

[root@localhost apr-util-1.5.4]# make install

安装pcre

[root@localhost pcre-8.39]# tar -zxvf pcre-8.39.tar.gz

[root@localhost pcre-8.39]# cd pcre-8.39

[root@localhost pcre-8.39]# #./configure --prefix=/usr/local/pcre [root@localhost pcre-8.39]# make && make install

推荐用pcre,如用pcre2还会报错 再次编译apache ./configure --prefix=/usr/local/apache --enable-modules=most --enable-mods-shared=all --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

[root@localhost httpd-2.4.23]# make

[root@localhost httpd-2.4.23]# make install

添加apache服务脚本

# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

[root@localhost bin]#echo 'export PATH=$PATH:/usr/local/apache/bin' > /etc/profile.d/httpd.sh

[root@localhost bin]# chmod +x /etc/profile.d/httpd.sh

[root@localhost bin]# soure /etc/profile.d/httpd.sh

编辑配置文件

Vim /usr/local/apache/conf/httpd.conf

添加 ServerName localhost

然后保存退出 然后执行服务脚本启动httpd :

# service httpd start

查看是否正常监听80端口:

# netstat -anpt | grep "80"

如果想确保正常访问网页请关闭SElinux和iptables防火墙 或者自行添加iptables规则,我这里只临时关闭。

# setenforce 0

# service iptables stop

隐藏apache版本

进入Apache的源码目录下的include目录,然后编辑ap_release.h这个文件,你会看到有如下变量:

#define AP_SERVER_BASEVENDOR “Apache Software Foundation”

#define AP_SERVER_BASEPROJECT “Apache HTTP Server”

#define AP_SERVER_BASEPRODUCT “Apache”

#define AP_SERVER_MAJORVERSION_NUMBER 2

#define AP_SERVER_MINORVERSION_NUMBER 2

#define AP_SERVER_PATCHLEVEL_NUMBER 15 #define AP_SERVER_DEVBUILD_BOOLEAN 0

 

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: