linux apache的安装与配置 ,局域网访问主页

来源:互联网 发布:医疗器械行业 知乎 编辑:程序博客网 时间:2024/04/26 16:01

  Apache web服务器的安装,其实主要是解决级几个依赖关系,其安装本身其实是相当的简单。但是就一般情况下,可以总结为:

   1.安装apr

   2.安装apr-util

   3.安装apache

   4.配置

   5.可选项:安装subversion

1.安装apr

下载得到apr-1.3.5.tar.gz

# tar zxvf apr-1.3.5.tar.gz

# cd apr-1.3.5

# ./configure

#make

#make install

2.安装apr-util

# tar zxvf apr-util-1.3.7.tar.gz

# cd apr-util-1.3.7

# . /configure --with-apr=/usr/local/apr

# make

# make install

3.安装apache

# tar zxvf httpd-2.2.11.tar.gz

# ./configure --prefix=/usr/local/apache2  --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config

# make

# make install

安装总结

  其实总结起来,很简单。分别从apache官网获得以上三个包,然后解压,分别执行configure、make、makeinstall即可。只是apr-util要指定apr的路径,apache则要指定apr和apr-util的路径。

安装问题总结:

1)apr not found  解决方法:安装apr包

2)apr-util not found 解决方法:安装apr-util包

3)cannot remove `libtoolT': No such file or directory  直接忽略过。

4)configure: error: You need a C++ compiler for C++ support  解决方法: yum install -y gcc gcc-c++  

5)安装以上包时,可能提示缺少pcre, 解决方法,安装pcre:

下载pcre,然后

#unzip  pcre-8.10.zip

#cd pcre-8.10

#./configure --prefix=/usr/local/pcre

#make

#make install

6).安装apache时提示:configure: error: APR-util version 1.3.0 or later is required

事实上我是1.5.*,是最新版本,竟然提示版本太低。于是,我换了一个版本,果然,过了。

4.配置 (并实现局域网访问主页)

1)启动服务器:

/usr/local/apache2/bin/apachectl start 

可能出现以下问题:

a. Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

这是因为未给服务器配置名称而已,只需进入/apache2/conf/httpd.conf 中配置服务器名称ServerName 即可。

b. /etc/init.d/apachectl: line 97: lynx: command not found

这是因为lynx命令不认识,只因缺少lynx包,安装即可:yum install lynx。

2)在自己的浏览器中访问自己的主页:

//localhost//  便会出现网页提示服务器正常安装。

3)再更改服务器名称后,并在hosts中增加服务器名称与IP的映射,就可用自己的网址访问了,比如:www.myapache.com

4 )局域网访问主页:

在httpd.conf中:

在httpd.conf中将以下

#   onlineoffline tag - don't remove

     Order Deny,Allow

     Deny from all

     Allow from 127.0.0.1

改为

#   onlineoffline tag - don't remove

     Order Deny,Allow

     Deny from none

     Allow from all

   其实,我根本没有发现以上内容,于是我自己在httpd.con中增加了Allow from all.

但是,之后从局域网其他主机依旧无法访问。我考虑是不是防火墙的原因,于是:

service iptables stop

   果然。再从局域网其他主机可以正常访问了。大功告成。当然,这时只能从IP访问,因为DNS中并没有自己的IP与网址的映射。

   我尝试用nat123软件实现外网访问自己的主页,未能成功。

  较为高级的配置比如listen和timeout等,其实从httpd.con中看注释已然可以知道大部分。

5.subversion的安装

 subversion是一个自由开源的版本控制系统,其实就是一个特殊的文件系统。安装方法可参考。




0 0
原创粉丝点击