apache安装
一:下载编译:
# tar xvf httpd-2.2.6.tar # cd httpd-2.2.6/ # ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --disable-userdir--enable-deflate --enable-headers
(说明:--enable-deflate --enable-headers 是编译 gzip 解压缩)
如果要编译ssl,加上--enable-ssl=static --with-ssl=/usr/local/ssl,前提需先安装openssl。默认安装在local/ssl里面!--enable-mods-shared=all 是一次性包含核心模块。
# make # make install # echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local //开机启动 # chmod 0700 /etc/rc.d/rc.local //添加权限
编译遇到了问题:error: mod_deflate has been requested but can not be built due to prerequisite failures的错误
输入命令:
# yum install zlib-develubuntu下可以采用:
apt-get install zlib1g-dev.
启动又遇到了问题:Could not reliably determine the server`s fully qualified domain name,命令:
# vi /etc/httpd/conf/httpd.conf加入一句 ServerName localhost:80 即可
为了安全,我们需要设置一下目录,在没有index的时候,目录设置不可见的,打开 http.conf,找到
Options Indexes 改为 Options Indexes None
添加到linux开机启动: /etc/rc.d/rc.local
查看:telnet ip 端口 如果不能打开就用下面方法试试,
如果外网不能打开,很有可能是80端口问题
解决方法:
# iptables -I RH-Firewall-1-INPUT -p tcp --dport 80 -j ACCEPT
然后:
service iptables save
最后:
service iptables restart