日期:2014-05-16  浏览次数:20780 次

linux下面安装apache

?

1. 如果实用wget-install 安装,默认安装到/etc目录下面

2. apachectl 用法:sudo apachectl -f /home/work/httpd/httpd.conf -k start
首先切换到root权限,安装apache需要 apr,apr-util,zlib-dev

3. 加入sudo组,编辑/etc/sudoer

步骤:

1. 下载
wget http://labs.renren.com/apache-mirror//httpd/httpd-2.2.22.tar.gz
wget http://labs.renren.com/apache-mirror/apr/apr-1.4.6.tar.gz
wget http://labs.renren.com/apache-mirror/apr/apr-util-1.3.12.tar.gz

---------------------------------------------------------
2. 解压
tar xvf httpd-2.2.19.tar.gz
tar xvf apr-1.4.5.tar.gz
tar xvf apr-util-1.3.12.tar.gz

---------------------------------------------------------

3.安装
? a.安装apr
??? ./configure --prefix=/usr/local/apr
??? make

??? make install


? b.安装apr-util
??? ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
??? make
??? make install


? c.安装zlib-devel
??? apt-get install zlib1g-dev


? d.安装httpd

./configure --prefix=/atlas/dist/sys/httpd --enable-rewrite=static --with-mpm=worker --enable-so --enable-proxy --enable-proxy-http --enable-deflate --with-apr=/atlas/dist/sys/apr --with-apr-util=/atlas/dist/sys/apr-util --with-included-apr
??? make
??? make install

---------------------------------------------------------
4.修改启动脚本权限
sudo chmod a+s apachectl
sudo chmod a+s httpd

?

---------------------------------------------------------
问题记录:
1.明明安装了apr-util,还是提示错误:configure: error: APR version 1.2.0
注意要增加 –with-included-apr 参数。

2. 出现错误提示:checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

zlib-devel 没装的原因:
ubunt: apt-get install zlib1g-dev

centos:? yum install zlib-devel.i686

3.出现错误:configure: error: C compiler cannot create executables
检查gcc版本,发现gcc版本是gcc-4.4,编译需要gcc-4.5,remove掉,重新安装,ok
apt-get remove gcc-4.4
apt-get install gcc-4.5

如果发现无法安装GCC,可以试试:sudo ? apt-get ?? install ?? build-essential

4.非root无法启动:(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80,no listening sockets available, shutting down

修改./apachectl权限:

sudo chown root:root apachectl

sudo chown root:root httpd
sudo chmod u+s apachectl
sudo chmod u+s httpd

?

cronolog可选
------------------------------------------
cronolog安装
1, wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
2, tar zxvf cronolog-1.6.2.tar.gz
3, cd cronolog-1.6.2
4, ./configure
5, make
6, sudo make install
7, which cronolog (查看是否安装成功)