Centos 6.5 Apache服务安装
<p><strong> Apache是什么:</strong></p><p> Apache HTTP Server(简称Apache)是Apache软件基金会的一个高性能、功能强大、稳定可靠、又很灵活的开发源代码的web服务软件,对linux的支持相对好,有很多产品可以支持ssl技术,支持多个虚拟主机,到目前为止,市场占有率44.9%,世界上很多注明的网</p>
<p>站如百度、阿里、淘宝、亚马逊、雅虎等都有在使用apache服务,它的成功之处主要在于他的开源、有一支开发的开发队伍、支持跨平台的应用(几乎可以在所有的windows、linux、unix系统运行)以及它的可移植性等是当前互联网最流行的web服务端软件之一。</p>
<p> Apache源于NCSA httpd服务,经过多次修改,成为世界上最流行的web服务器软件之一,Apache取自“a patchy server”的读音,意思是充满补丁的服务器,因为它是自由软件,所以不断有人来为它开发新的功能、新的特性、修复原来的缺陷,才成为我们今天使用的安全稳定的web服务器。</p>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190714001609217-2082309895.png" alt=""></p>
<p><strong>注:</strong>以上web serve排行信息来源于https://w3techs.com/technologies/overview/web_server/all</p>
<p><strong>Apache的特点及应用场合:</strong></p>
<p><sup><strong>优点:</strong></sup></p>
<ul>
<li>功能强大</li>
<li>配置简单</li>
<li>速度快</li>
<li>应用广泛</li>
<li>性能稳定可靠</li>
<li>可做代理服务器或负载均衡来使用</li>
</ul>
<p><sup><strong>应用场合:</strong></sup></p>
<ul>
<li>使用apache运行静态html网页、图片(处理静态小文件能力不及nginx)</li>
<li>使用apache结合php引擎运行php、perl、Python等程序,LAMP被称之为经典组合。</li>
<li>使用apache结合tomcat/resin运行jsp,java等程序,成为中小型企业的首先。</li>
<li>使用apache做代理、负载均衡rewrite规则过滤等等。</li>
</ul>
<p><strong>提示:</strong></p>
<p> 进年来,网上比较流行的nginx server,对于提供纯静态小文件HTML页、图片等服务,Apache确实要不nginx逊色一些,但在结合PHP引擎提供php服务及其它很多方面并不比nginx差,而apache的稳定性更好,这也是为什么Apache服务排名仍然第一的原因之一。</p>
<p><strong>下面我们来安装Apache服务:</strong></p>
<p><strong>环境<span style="color: rgba(0, 0, 255, 1)">→</span></strong>系统:centos 6.5 软件:httpd-2.2.27.tar.gz</p>
<div class="cnblogs_code">
<pre># wget http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">archive.apache.org/dist/httpd/httpd-2.2.27.tar.gz</span>
# ll
总用量 </span><span style="color: rgba(128, 0, 128, 1)">7344</span>
-rw-r--r-- <span style="color: rgba(128, 0, 128, 1)">1</span> root root <span style="color: rgba(128, 0, 128, 1)">7519677</span> 7月<span style="color: rgba(128, 0, 128, 1)">13</span> <span style="color: rgba(128, 0, 128, 1)">22</span>:<span style="color: rgba(128, 0, 128, 1)">39</span> httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span><span style="color: rgba(0, 0, 0, 1)">.tar.gz
# tar xf httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span><span style="color: rgba(0, 0, 0, 1)">.tar.gz
# ll
总用量 </span><span style="color: rgba(128, 0, 128, 1)">7348</span><span style="color: rgba(0, 0, 0, 1)">
drwxr</span>-xr-x <span style="color: rgba(128, 0, 128, 1)">11</span> nginx<span style="color: rgba(128, 0, 128, 1)">500</span> <span style="color: rgba(128, 0, 128, 1)">4096</span> 3月<span style="color: rgba(128, 0, 128, 1)">14</span> <span style="color: rgba(128, 0, 128, 1)">2014</span> httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>
-rw-r--r--<span style="color: rgba(128, 0, 128, 1)">1</span> rootroot <span style="color: rgba(128, 0, 128, 1)">7519677</span> 7月<span style="color: rgba(128, 0, 128, 1)">13</span> <span style="color: rgba(128, 0, 128, 1)">22</span>:<span style="color: rgba(128, 0, 128, 1)">39</span> httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span><span style="color: rgba(0, 0, 0, 1)">.tar.gz
# cd httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span><span style="color: rgba(0, 0, 0, 1)">
# <strong><span style="color: rgba(0, 0, 255, 1)">./configure \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--prefix=/application/apache2.2.27 </span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-deflate \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-expires \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-headers \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-modules=most \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-so \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--with-mpm=worker \</span></strong><br><strong><span style="color: rgba(0, 0, 255, 1)">--enable-rewrite</span></strong></pre>
</div>
<p><strong>参数解释:</strong></p>
<p>--prefix=/application/apache2.2.27 安装路径,默认路径为/usr/local/apache2<br>--enable-deflate 提供对内容的压缩传输编码支持,一般html,js,css等内容的站点,用此参数功能会大大提高传输速度,提升访问者访问体验,调优选项之一<br>--enable-expires 激活允许通过配置文件控制http的"Expires:"和"Cache-Control:"头内容,即对网站图片、js、css等内容,提供在客户端浏览器缓存的设置,调优选项之一<br>--enable-headers 提供允许对http请求头的控制<br>--enable-modules=most 可以将一些不常用的,不在缺省常用模块中的模块编译进来<br>--enable-so 激活apache服务的DSO(全称Dynamic Shared object,动态共享对象)支持,即在以后可以以DSO的方式编译安装共享模块,这个模块本身不能以DSO方式编译<br>--with-mpm=worker 选择apache mpm的模式为worker模式,因worker模式原理是更多的使用线程来处理请求,所有可以处理更多的并发请求,而系统资源的开销小于基于进程的MPM prefork。如果不指定此参数,默认的模式是prefork的进程模式,虽然消耗资源,但是更稳定,因此,选择prefork进程模式而不选择worker模式也是可以考虑的,调优选项之一<br>--enable-rewrite 提供基于URL规则的重写功能,即根据已知URL地址,转换其他想要的URL地址,伪静态模块。调优必选项 </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># <strong><span style="color: rgba(0, 0, 255, 1)">make</span></strong><br>...
......此处省略
# echo $?
<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
# <span style="color: rgba(0, 0, 255, 1)"><strong>make install</strong></span>
Making install </span><span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> srclib
make[</span><span style="color: rgba(128, 0, 128, 1)">1</span>]: Entering directory `/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>/srclib<span style="color: rgba(128, 0, 0, 1)">'
</span>Making install <span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> apr
make[</span><span style="color: rgba(128, 0, 128, 1)">2</span>]: Entering directory `/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>/srclib/apr<span style="color: rgba(128, 0, 0, 1)">'
</span>make[<span style="color: rgba(128, 0, 128, 1)">3</span>]: Entering directory `/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>/srclib/apr<span style="color: rgba(128, 0, 0, 1)">'
</span>make[<span style="color: rgba(128, 0, 128, 1)">3</span>]: Nothing to be done <span style="color: rgba(0, 0, 255, 1)">for</span> `local-all<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">.</span>
make[<span style="color: rgba(128, 0, 128, 1)">3</span>]: Leaving directory `/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>/srclib/apr<span style="color: rgba(128, 0, 0, 1)">'
</span>/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span>/srclib/apr/build/mkdir.sh /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/lib /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin /application/<span style="color: rgba(0, 0, 0, 1)">a
pache2.</span><span style="color: rgba(128, 0, 128, 1)">2.27</span>/<span style="color: rgba(0, 0, 0, 1)">build \
...
......此处省略
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/<span style="color: rgba(0, 0, 0, 1)">logs
Installing CGIs
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/cgi-<span style="color: rgba(0, 0, 0, 1)">bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/<span style="color: rgba(0, 0, 0, 1)">man
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/man/<span style="color: rgba(0, 0, 0, 1)">man1
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/man/<span style="color: rgba(0, 0, 0, 1)">man8
mkdir </span>/application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/<span style="color: rgba(0, 0, 0, 1)">manual
make[</span><span style="color: rgba(128, 0, 128, 1)">1</span>]: Leaving directory `/root/tools/httpd-<span style="color: rgba(128, 0, 128, 1)">2.2</span>.<span style="color: rgba(128, 0, 128, 1)">27</span><span style="color: rgba(128, 0, 0, 1)">'
</span># echo $?
<span style="color: rgba(128, 0, 128, 1)">0</span></pre>
</div>
<p><strong>做个软连接(快捷方式)便于区分当前使用版本、安全考虑隐藏版本、方便以后升级等:</strong></p>
<div class="cnblogs_code">
<pre># ln -s /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/ /application/<span style="color: rgba(0, 0, 0, 1)">apache
# ll /application/<span style="color: rgba(0, 0, 0, 1)">
总用量 </span><span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
lrwxrwxrwx</span><span style="color: rgba(128, 0, 128, 1)">1</span> root root <span style="color: rgba(128, 0, 128, 1)">26</span> 7月<span style="color: rgba(128, 0, 128, 1)">13</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">36</span> apache -> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/<span style="color: rgba(0, 0, 0, 1)">
drwxr</span>-xr-x <span style="color: rgba(128, 0, 128, 1)">15</span> root root <span style="color: rgba(128, 0, 128, 1)">4096</span> 7月<span style="color: rgba(128, 0, 128, 1)">13</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">29</span> apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span></pre>
</div>
<p><strong>到此,Apache服务安装已完成。</strong></p>
<p><strong><strong><sup>查看编译的生效模块:</sup></strong></strong>/application/apache/bin/apachectl -l</p>
<p><strong><sup>启动前检查配置文件语法:</sup></strong>/application/apache/bin/apachectl -t</p>
<p><sup><strong>启动Apache服务:</strong></sup>/application/apache/bin/apachectl start</p>
<p><sup><strong>重启Apache服务:</strong></sup>/application/apache/bin/apachectl graceful</p>
<p><strong><sup>查看服务状态:</sup></strong>lsof -i:80 或 ps -ef|grep httpd</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># /application/apache/bin/apachectl -<span style="color: rgba(0, 0, 0, 1)">t
httpd: apr_sockaddr_info_get() failed </span><span style="color: rgba(0, 0, 255, 1)">for</span> bqh-<span style="color: rgba(128, 0, 128, 1)">119</span><span style="color: rgba(0, 0, 0, 1)">
httpd: Could not reliably determine the server</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s fully qualified domain name, using 127.0.0.1 for ServerName</span>
<span style="color: rgba(0, 0, 0, 1)">Syntax OK
# /application/apache/bin/<span style="color: rgba(0, 0, 0, 1)">apachectl start
httpd: apr_sockaddr_info_get() failed </span><span style="color: rgba(0, 0, 255, 1)">for</span> bqh-<span style="color: rgba(128, 0, 128, 1)">119</span><span style="color: rgba(0, 0, 0, 1)">
httpd: Could not reliably determine the server</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s fully qualified domain name, using 127.0.0.1 for ServerName</span>
# lsof -i:<span style="color: rgba(128, 0, 128, 1)">80</span><span style="color: rgba(0, 0, 0, 1)">
COMMAND PID USER FD TYPE DEVICE SIZE</span>/<span style="color: rgba(0, 0, 0, 1)">OFF NODE NAME
httpd </span><span style="color: rgba(128, 0, 128, 1)">58405</span> root <span style="color: rgba(128, 0, 128, 1)">4u</span>IPv6<span style="color: rgba(128, 0, 128, 1)">54509</span> 0t0TCP *<span style="color: rgba(0, 0, 0, 1)">:http (LISTEN)
httpd </span><span style="color: rgba(128, 0, 128, 1)">58407</span> daemon <span style="color: rgba(128, 0, 128, 1)">4u</span>IPv6<span style="color: rgba(128, 0, 128, 1)">54509</span> 0t0TCP *<span style="color: rgba(0, 0, 0, 1)">:http (LISTEN)
httpd </span><span style="color: rgba(128, 0, 128, 1)">58408</span> daemon <span style="color: rgba(128, 0, 128, 1)">4u</span>IPv6<span style="color: rgba(128, 0, 128, 1)">54509</span> 0t0TCP *<span style="color: rgba(0, 0, 0, 1)">:http (LISTEN)
httpd </span><span style="color: rgba(128, 0, 128, 1)">58409</span> daemon <span style="color: rgba(128, 0, 128, 1)">4u</span>IPv6<span style="color: rgba(128, 0, 128, 1)">54509</span> 0t0TCP *<span style="color: rgba(0, 0, 0, 1)">:http (LISTEN)
# ps -ef|<span style="color: rgba(0, 0, 0, 1)">grep httpd
root </span><span style="color: rgba(128, 0, 128, 1)">58405</span> <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">40</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin/httpd -<span style="color: rgba(0, 0, 0, 1)">k start
daemon </span><span style="color: rgba(128, 0, 128, 1)">58406</span><span style="color: rgba(128, 0, 128, 1)">58405</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">40</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin/httpd -<span style="color: rgba(0, 0, 0, 1)">k start
daemon </span><span style="color: rgba(128, 0, 128, 1)">58407</span><span style="color: rgba(128, 0, 128, 1)">58405</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">40</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin/httpd -<span style="color: rgba(0, 0, 0, 1)">k start
daemon </span><span style="color: rgba(128, 0, 128, 1)">58408</span><span style="color: rgba(128, 0, 128, 1)">58405</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">40</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin/httpd -<span style="color: rgba(0, 0, 0, 1)">k start
daemon </span><span style="color: rgba(128, 0, 128, 1)">58409</span><span style="color: rgba(128, 0, 128, 1)">58405</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">40</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> /application/apache2.<span style="color: rgba(128, 0, 128, 1)">2.27</span>/bin/httpd -<span style="color: rgba(0, 0, 0, 1)">k start
root </span><span style="color: rgba(128, 0, 128, 1)">58493</span> <span style="color: rgba(128, 0, 128, 1)">1473</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">23</span>:<span style="color: rgba(128, 0, 128, 1)">41</span> pts/<span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> grep httpd</pre>
</div>
<p><strong> 我们用curl 测试一下:(192.168.0.119为安装apache的服务器的ip地址)</strong></p>
<div class="cnblogs_code">
<pre># curl <span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">0.119</span>
<html><body><h1><strong><span style="color: rgba(0, 0, 255, 1)">It works!</span></strong></h1></body></html></pre>
</div>
<p><strong>浏览器测试一下:</strong></p>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190713234951316-940145063.png" alt=""></p>
<p><strong>ok,到此apache服务安装成功!</strong></p>
<p><strong><span style="color: rgba(255, 0, 0, 1)">注:</span>如果未显示It works的页面,请查看是否关闭了iptables防火墙和selinux。</strong></p>
<p><strong>关闭防火墙:</strong>/etc/init.d/iptables stop</p>
<p><strong>允许通过防火墙:</strong>iptables -I INPUT -p tcp --dprot 80 -j ACCEPT</p>
<p><strong>临时关闭selinux,可执行:</strong></p>
<p> setenforce 0 // 设置selinux状态 1启用,0警告、不启用。</p>
<p> getenforce //检查selinux状态是否生效</p>
<p><strong>永久关闭selinux功能:</strong></p>
<p> cat /etc/selinux/config</p>
<p> cp /etc/selinux/config /etc/selinux/config.root</p>
<p> sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config</p>
<p><strong>如果要部署网站服务,需要把开发好的程序全部放置:</strong>/application/apache/htdocs</p>
<div class="cnblogs_code">
<pre># cd /application/apache/htdocs/<span style="color: rgba(0, 0, 0, 1)">
# vim index.html
# cat index.html
</span><html>
<head><title>bqh blog</title></head>
<bldy><span style="color: rgba(0, 0, 0, 1)">
Hello, welcome to bqh</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s blog. This is my blog address.</span>
<a href=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">https://www.cnblogs.com/su-root/#top</span><span style="color: rgba(128, 0, 0, 1)">"</span>>https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">www.cnblogs.com/su-root/#top</a></span>
<br></br><span style="color: rgba(0, 0, 0, 1)">
Email:</span><span style="color: rgba(128, 0, 128, 1)">1147076062</span><span style="color: rgba(0, 0, 0, 1)">@qq.com
</span></body>
</html></pre>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190714121543659-1238476300.png" alt=""></p>
<p>-------------------------------------------------</p>
<p><strong>优化httpd.conf配置文件,避免暴露目录结构:</strong></p>
<div class="cnblogs_code">
<pre># sed -n <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">132,160p</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> httpd.conf
</span><Directory <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/application/apache2.2.27/htdocs</span><span style="color: rgba(128, 0, 0, 1)">"</span>><span style="color: rgba(0, 0, 0, 1)">
#
# Possible values </span><span style="color: rgba(0, 0, 255, 1)">for</span> the Options directive are <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">None</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">All</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">MultiViews</span><span style="color: rgba(128, 0, 0, 1)">"</span> must be named *explicitly* --- <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Options All</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
# doesn</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">t give it to you.</span>
<span style="color: rgba(0, 0, 0, 1)"> #
# The Options directive </span><span style="color: rgba(0, 0, 255, 1)">is</span><span style="color: rgba(0, 0, 0, 1)"> both complicated and important.Please see
# http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">httpd.apache.org/docs/2.2/mod/core.html#options</span>
# <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> more information.
#
Options <strong><span style="background-color: rgba(0, 0, 0, 1); color: rgba(255, 255, 0, 1)">Indexes</span></strong> FollowSymLinks <span style="color: rgba(255, 0, 0, 1)">#如果没有首页的情况下会展示目录结构、 建议把Indexes删除 或改为</span></span><span style="color: rgba(255, 0, 0, 1)">-</span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(255, 0, 0, 1)">Indexes 、如果把目录展示禁用后、没有首页的情况下会报错403</span>
#
# AllowOverride controls what directives may be placed </span><span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> .htaccess files.
# It can be </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">All</span><span style="color: rgba(128, 0, 0, 1)">"</span>, <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">None</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can </span><span style="color: rgba(0, 0, 255, 1)">get</span> stuff <span style="color: rgba(0, 0, 255, 1)">from</span> <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)"> server.
#
Order allow,deny
Allow </span><span style="color: rgba(0, 0, 255, 1)">from</span><span style="color: rgba(0, 0, 0, 1)"> all
</span></Directory><span style="color: rgba(0, 0, 0, 1)">
# </pre>
</div>
<p><strong>Apache服务目录结构简要说明:</strong></p>
<p><strong>bin启动文件目录说明:</strong></p>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190714155935964-533835710.png" alt=""></p>
<p><strong>conf配置文件目录说明:</strong></p>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190714162811546-798376462.png" alt=""></p>
<p><strong>站点存放目录、日志存放目录、模块目录说明:</strong></p>
<p><img src="https://img2018.cnblogs.com/blog/1491353/201907/1491353-20190714164449968-833260872.png" alt=""></p><br><br>
来源:https://www.cnblogs.com/su-root/p/11182549.html
頁:
[1]