1.apache简单介绍
?
?我们常常要浏览网页,提供这种服务是apache。提供apache服务的软件是httpd服务。
?
?Apache支持許多特性,大部分通过编译的模块实现。這些特性從伺服器端的程式語言支援到身份認證方案。一些通用的语言接口支持
Perl,
Python,
Tcl,
和
PHP。流行的认证模块包含mod_access,mod_auth和mod_digest。其它的样例有
SSL和
TLS支持(mod_ssl),
代理server(proxy)模块,非常实用的URL重写(由mod_rewrite实现),定制日志文件(mod_log_config),以及过滤支持(mod_include和mod_ext_filter)。Apache日志能够通过网页浏览器使用免费的脚本
AWStats或
Visitors来进行分析。
?
?apache的服务配置是很有讲究的,我们首先来提供服务,包含Perl、Python、PHP。最后在提供服务的基础上要实现它的安全性。
?

?
?上图就是我们apacheserver的一个基本架构。
?
?2.配置apache服务
?1)首先我们要来安装apache服务,安装文件是httpd:
?
?

?
?还好,我们的httpd是已经安装了的。启动httpd服务,发现我们的主机名是须要改动的:
?
?
?改动/etc/hosts文件,加入?本机IP和域名之间的对比:
?
?

?
?

?
?再次启动之后,我们发现之前的提示已经不见了:

?
?服务最终启动了,我们的apache的默认公布文件夹是:
/var/www/html,默认的公布文件是那个文件夹地下的
index.html.
?
?我们先简单的写一个index.html文件(就在默认公布文件夹底下创建):
?
?

?
?

?
?我们能够看到这个文件对于不论什么人都是可读的:
?
?

?
?接着我们来訪问这个server:
?
?

?
?呵呵,但是看不到所公布的内容。想想我们刚刚看到了权限是可读的,那问题应该是出在了防火墙上了。我们在没有涉及防火墙学习的情况下,先关闭它:
?
?

?
?
?

?然后重新启动httpd服务,再次訪问本server:
?
?

?
?再次訪问:
?
?

?
?这次就能够看到了。
?
?2.设置自己的默认公布文件夹
??
?有的时候我们并不想设置默认公布文件夹为:/var/www/html,假设要设置其它文件夹为默认公布文件夹,我们得改动httpd的配置文件:
?
?

?
?我们改动httpd的默认公布文件夹为/www/html:
?

?
?1)首先我们要创建这个文件夹,然后创建默认公布文件index.html:
?
?

?

?
?重新启动httpd服务,然后查看默认公布内容(此时我们的防火墙已经关闭了):
?
?

?
?

?
?能够看到这个界面,记住,一旦出现这个问题。那就是selinux的权限不够,我们一定要对默认公布文件夹的安全上下文进行设置:
?
?首先我们要来安装一个能够改动安全上下文的软件:
?
?

?
?改动/www/html的安全上下文:
?
?

?
?查看/www/html的安全上下文,确实已经变为能够訪问的安全上下文:
?
?

?
?再次查看之后,我们已经能够看到默认公布的内容了:
?
?

?
?上面的内容我们已经实现了httpd服务的默认公布文件夹的设定,而且实现了html内容的公布。可是对于权限和安全的方面考虑的问题不够多.我们能够对訪问用户的身份进行设定从而避免非法用户的訪问。
?
?1)假如我们仅仅同意本机的訪问。
?
?1.改动配置文件:
?
?

?在这个Directory中,我们仅仅同意了本机的IP进行訪问。
?
?重新启动服务后用另外一台主机訪问看看有什么结果:
?
?

?
?然后本机的訪问结果:
?
?
?2)假如我们仅仅同意本网段的用户訪问。
?
?还是要改动配置文件:
?
?

?
之后重新启动服务,本网段192.168.0.0/24的用户都能够对该apache訪问.
?
?小结:
?
?本节解说了apache服务的基本配置,对于加密和内外网的訪问规则设置我们在以后的帖子中进行解说。
?
?
?
?
?
?
?
?
?
?