在官网下载 源码包
apr-1.5.1.tar.gz
apr-util-1.5.3.tar.gz
httpd-2.4.10.tar.gz
安装用户是root
解压命令 tar -zxvf httpd-2.4.10.tar.gz
源码安装 apr ,apr-util
./configure --prefix=/usr/local/apr
报错:rm: cannot remove `libtoolT': No such file or directory
我直接忽略了,网上看有修改configure 解决这个 问题,此处没有尝试
make
make install
./configure --prefix=/usr/local/apr-util \
--with-apr=/usr/local/apr
make
make install
4 源码安装apache
4.1 安装
./configure --prefix=/usr/local/apache \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --enable-dav \ --enable-module=so \ --enable-mods-shared=all make make install
4.2 修改原80端口为8008
备份 cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak
修改点: Listen 8008
ServerName http://localhost:8008
4.3启动apache
/usr/local/apache/bin/apachectl start
curl http://127.0.0.1:8008
看到 <html><body><h1>It works!</h1></body></html>
成功
4.4配置 apachectl status 命令
备份 cp /usr/local/apache/conf/extra/httpd-info.conf /usr/local/apache/conf/extra/httpd-info.conf.bak 修改httpd-info.conf 整个文件修改如下 # # Get information about the requests being processed by the server # and the configuration of the server. # # Required modules: mod_authz_core, mod_authz_host, # mod_info (for the server-info handler), # mod_status (for the server-status handler) # # Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. <Location /server-status> SetHandler server-status Order deny,allow #Deny from all Allow from all # Require host .example.com # Require ip 127 </Location> # # ExtendedStatus controls whether Apache will generate "full" status # information (ExtendedStatus On) or just basic information (ExtendedStatus # Off) when the "server-status" handler is called. The default is Off. # #ExtendedStatus On ExtendedStatus On <IFModule mod_info.c> <Location /server-info> SetHandler server-info Order deny,allow #Deny from all Allow from all </Location> </IFModule> # # Allow remote server configuration reports, with the URL of # http://servername/server-info (requires that mod_info.c be loaded). # Change the ".example.com" to match your domain to enable. #
修改http.conf
首先检查文件里有没有
LoadModule status_module modules/mod_status.so
如果没有,需要重新编译 搜索
mod_status.so 可能是./configure 命令和apapche 版本问题
然后修改配置文件,使httpd-info.conf 生效
# Real-time info on requests and configuration #Include conf/extra/httpd-info.conf Include conf/extra/httpd-info.conf
最后修改/usr/local/apache/bin/apachectl
#STATUSURL=" 改为下面 STATUSURL="http://localhost:8008/server-status"
./apachectl status 配置完成
4.5 apache 配置系统服务
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd # cp /usr/local/apache/bin/apachectl /usr/local/bin/httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S61httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc4.d/S61httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc3.d/S61httpd 打开/etc/init.d/httpd文件在#!/bin/bash下面加入 #chkconfig:345 61 61 #description:Apache 执行chkconfig --list |grep httpd 就会出现httpd服务开机运行在345级别注册服务 chkconfig --add httpd 设置启动级别 chkconfig --levels 345 httpd on
4.6 在非本机访问apache 在防火墙打开8008端口
/etc/sysconfig/iptables
添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8008 -j ACCEPT
重启iptable
/etc/init.d/iptables restart
查看iptable 状态
/etc/init.d/iptables status
完工。
参考了很多网上的资料,谢谢前辈们~~~~