linux上安装apache(httpd)

安装包 httpd-2.2.29.tar.bz2 (可以去网站查看最新版本:http://httpd.apache.org/security_report.html)

tar -jxvf httpd-2.2.29.tar.bz2

cd httpd-2.2.29

[root@lulu httpd-2.2.29]# ./configure --prefix= /usr/local/apache

如出现编译错误,则需安装gcc rpm -ivh gcc-4.4.7-11.el6.x86_64.rpm(会提示需要其他包)
报这个依赖
        libmpfr.so.1 is needed by cpp-4.4.4-13.el6.i686
        libppl.so.7 is needed by cloog-ppl-0.15.7-1.2.el6.i686
        libppl_c.so.2 is needed by cloog-ppl-0.15.7-1.2.el6.i686

是缺了这两个包……
        mpfr-2.4.1-6.el6.x86_64.rpm
        ppl-0.10.2-11.el6.x86_64.rpm

这两个安装好之后就可以安装cpp和cloog-ppl了,之后就能安装gcc了……

[root@lulu httpd-2.2.29]# make
.....(编译)
[root@lulu httpd-2.2.29]# make install
.....(安装)
启动

[root@lulu httpd-2.2.29]# cd /usr/local/apache/bin

[root@lulu bin]#./httpd -k start
如报错:
出现 ServerName 错误

修改/usr/local/apache/conf/httpd.conf
加入 ServerName 127.0.0.1:80

如下
#ServerName www.example.com:80
ServerName 127.0.0.1:80


[root@lulu bin]#ps -ef |grep httpd
daemon   11894 11890  0 15:05 ?        00:00:00 ./httpd -k start
daemon   11895 11890  0 15:05 ?        00:00:00 ./httpd -k start
daemon   11900 11890  0 15:05 ?        00:00:00 ./httpd -k start

验证 http://localhost(安装主机)
如出现 it's work! 则成功.

关闭
[root@lulu bin]# ./httpd -k stop

配置 连接tomcat  需要加入模块 mod_proxy(参考文档:http://blog.csdn.net/shw2004/article/details/5781302)
实际操作

[root@ims-app proxy]# cd /usr/local/src/soft/apache/httpd-2.2.29/modules/proxy

[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy.c proxy_util.c
[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy_connect.c proxy_util.c
[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy_ftp.c proxy_util.c
[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy_http.c proxy_util.c
[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy_ajp.c ajp*.c
[root@ims-app proxy]# /usr/local/apache/bin/apxs -c -i -a mod_proxy_balancer.c proxy_util.c

配置 httpd.conf
[root@ims-app proxy]# cd /usr/local/apache/conf/
[root@ims-app conf]# vi httpd.conf

--在文件最后加上下面这段

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://target_host:prot/
        ProxyPassReverse / http://target_host:port/
        ProxyPassReverseCookiePath / /
</VirtualHost>


备注:target_host 及port 为需要apache转换tomcat 的主机及端口,通过这个链接就可以正常访问。

重启 httpd 服务(apache)

你可能感兴趣的:(apache)