安装apache:

官网:http://httpd.apache.org/download.cgi#apache24

1.wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.10.tar.gz

2.tar zxvf httpd-2.4.10.tar.gz

3.cd httpd-2.4.10  &&  ./configure ...  && make && make install

**报错APR not found,解决办法(安装apache2.2.22版本没有问题,2.4才会有这个问题)

=======================================

1.下载所需软件包:

wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz

wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip

具体步骤如下:

a:解决apr not found问题>>>>>>

[root@xt test]# tar -zxf apr-1.4.5.tar.gz  
   [root@xt test]# cd  apr-1.4.5  
   [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  
   [root@xt apr-1.4.5]# make && make install

b:解决APR-util not found问题>>>>

[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz  
   [root@xt test]# cd apr-util-1.3.12  
   [root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr
   [root@xt apr-util-1.3.12]# make && make install

c:解决pcre问题>>>>>>>>>

[root@xt test]#unzip -o pcre-8.10.zip  
   [root@xt test]#cd pcre-8.10  
   [root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre  
   [root@xt pcre-8.10]#make && make install

2.最后编译Apache时加上:

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util/ \

--with-pcre=/usr/local/pcre

=======================================

4.重新编译安装:./configure --prefix=/usr/local/apache2  --with-apr=/usr/local/apr  --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre  --enable-so  --enable-rewrite

5.make && make install

安装完成后配置配置文件:

修改ServerName localhost.localdomain  (可通过hostname查看本机servername)

开启Include conf/extra/httpd-mpm.conf(配置prefork模式的选项,下边有介绍)

开启Include conf/extra/httpd-default.conf (下边有介绍)

Apache源码包安装的子配置文件介绍:

配置文件位置:/usr/local/apache2/etc/httpd.conf

子配置文件: /usr/local/apache2/etc/extra/*.conf

源码包安装的Apache的配置文件并不是在一个文件里,主配置文件里边只有400多行,里边加载了extra子配置文件,但默认都是注释的。

常用子配置文件介绍:

====================

1.httpd-autoindex.conf      #apache系统别名,设置别名目录在此配置文件中设置。

Alias /icons/ "/usr/local/apache2//icons/"        #通过www.domain.com/icons/访问

<Directory "/usr/local/apache2//icons">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

Alias /soft/ "/www/soft/"           #通过www.domain.com/soft访问

<Directory "/www/soft/">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

tips:别名目录不一定在apache根目录下,在任意目录下都可以,能够跳出网站主目录的限制,直接通.过www.domain.com/alias/访问。指定的别名目录下边一定要指定目录权限,即<Directory>。别名目录中 / 不能省略。

2.httpd-default.conf        #apache线程控制,必须开启。

Timeout 300   #超时时间

KeepAlive On  #开启线程控制(不开启的话用户访问页面会产生一个进程,访问其他页面会产生另一个进程,这样的话一个用户会产生好多个进程,会降低apache性能。开启此项,当用户访问网站时会产生一个进程,打开其他页面时会产生线程,保证了一个用户只产生一个进程。网站此项功能必须开启。)

MaxKeepAliveRequests 100   #最大线程连接数

3.httpd-info.conf    #apache状态统计

<Location /server-status>

SetHandler server-status

Order deny,allow

Deny from all

Allow from .example.com

</Location>

通过访问www.domain.com/server-status可以查看apache状态。如果页面显示not found 则需要修改目录权限,在Deny from all下加上allow from ip(允许的ip)。

4.httpd-manual.conf     #apache帮助文档

通过访问www.domain.com/manual 查看apache帮助文档,一般为英文,没用,可以到apache官网下载帮助文档。

5.httpd-languages.conf    #语言编码

要使其生效需要在主配置文件中打开,如果中文乱码不是浏览器编码的原因可能是此配置文件注释没打开。

6.httpd-mpm.conf     #最大客户端限制

<IfModule mpm_prefork_module>

StartServers          5

MinSpareServers       5

MaxSpareServers      10

MaxClients          150

MaxRequestsPerChild   0

</IfModule>

MaxClients为最大客户端数量,即进程数。里边有两个上边的<IFModule>默认mpm_worker_module生效。

最大客户端数量由服务器性能决定,可通过top命令查看当前状态,进行调整。

7.httpd-multilang-errordoc.conf       #报错页面

ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var

ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var

ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var

ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var

ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var

ErrorDocument 410 /error/HTTP_GONE.html.var

ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var

ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var

ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var

ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var

ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var

ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var

ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var

ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var

ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var

ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

可以到对应的页面下修改显示的报错页面。

7.其他:

httpd-ssl.confssl      #安全套接字访问   没讲,不用研究。

httpd-userdir.conf     #用户主目录配置  用的不多,不讲。

httpd-vhosts.conf虚拟主机,单独介绍。

Apache源码包安装和子配置文件介绍--update.2014-12-5的更多相关文章

  1. Apache 源码包安装

    系统:Centos 7.4 服务:Apache 2.4.33.apr 1.5.2.apr-util 1.5.4 依赖包: pcre.x86_64 pcre-devel.x86_64 openssl.x ...

  2. Apache源码包在LINUX(CENTOS6.8)中的安装(出现问题及解决)

    任务:在CENT6.8系统中安装Apache(版本为:httpd-2.4.41) 前提:由于源码包必须先编译后安装,所以必须先安装编译器:gcc 理论步骤: 1.检测gcc软件包,如果不存在则进行安装 ...

  3. 【Ubuntu 16】源码包安装Apache Httpd

    源码包安装适合初学者使用. 背景信息 APR (Apache Portable Runtime) Apache可移植运行的任务(APR)项目是创建和维护软件库,为底层平台的具体实现提供了一个可预见的和 ...

  4. CentOS源码包安装apache、nginx服务

    1.通过官网下载apache.nginx源码包 2.进入apache源码包所在目录,解压tar -xf httpd-2.4.12.tar.gz 3.cd httpd-2.4.12 4.阅读README ...

  5. Zabbix源码包安装

    Zabbix源码包安装 Cenos5.3 Basic server 安装顺序 Libxml2 Libmcrypt Zlib Libpng Jpeg:需要创建目录jpeg  /bin  /lib   / ...

  6. Linux源码包安装程序

    ★安装OS时,建议提前安装开发组件 CentOS 6:Development Tools.Server Platform DevelopmentCentOS 7:Development Tools.D ...

  7. linux 软件包安装方式选择、安装位置、源码包安装

    对外提供服务,比如apache,应使用源码包安装对内提供服务,比如gcc,只是我自己使用,使用rpm包安装 rpm包不需要指定安装位置,源码包的安装需要手动指定安装位置 rpm包默认安装位置/etc/ ...

  8. linux 源码包安装拾遗

    源码包安装和apt-get/yum的区别 安装前的区别:概念上的区别 rpm和dpkg包是经过编译过的包,并且其安装位置由厂商说了算,厂商觉得安装在哪里合适,就会装在哪里,而源码包则是没有经过编译的文 ...

  9. yum更换国内源、yum下载rpm包、源码包安装 使用介绍

    第5周第4次课(4月19日) 课程内容: 7.6 yum更换国内源7.7 yum下载rpm包7.8/7.9 源码包安装 7.6 yum更换国内源 当yum仓库的软件不好用时,例如很多yum源都是国外的 ...

随机推荐

  1. 折腾笔记之wordpress安装出现错误---【wordpress点击文章找不到网页的解决办法】

    本来写的好好的在后台,然后发表在前台,能够看见在网站首页,但是一点击进去,就提示找不到链接了.郁闷,经过查找资料.终于解决了 1,.htaccess要开放写权限,这样在自定义wp的永久链接时,wp会自 ...

  2. java-获取随机字符串

    import java.util.Random; public class getRandomString { public static String excute(int length) { St ...

  3. JavaScript的DOM操作-非重点部分

    1.DOM的基本概念 DOM是文档对象模型,这种模型为树模型:文档是指标签文档(HTML文档),对象是指文档中每个元素:模型是指抽象划的东西. 2.Windows对象操作 一.属性和方法 属性(值或者 ...

  4. C# 定时器运用

    在晚上12点执行任务 using System;using System.Collections.Generic;using System.ComponentModel;using System.Da ...

  5. ajax请求web服务返回json格式

    由于.net frameword3.5以上添加了对contenttype的检查,当ajax发送请求时,如果设置了contenttype为json,那么请求webservice时,会自动将返回的内容转为 ...

  6. 二叉查找树 C++实现(含完整代码)

    一般二叉树的查找是通过遍历整棵二叉树实现,效率较低.二叉查找树是一种特殊的二叉树,可以提高查找的效率.二叉查找树又称为二叉排序树或二叉搜索树. 二叉查找树的定义 二叉排序树(Binary Search ...

  7. DFS经典题,reachable or not in a 2D maze

    [[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0], ...

  8. 【BZOJ-4569】萌萌哒 ST表 + 并查集

    4569: [Scoi2016]萌萌哒 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 459  Solved: 209[Submit][Status] ...

  9. 【BZOJ-3573】米特运输 树形DP

    3573: [Hnoi2014]米特运输 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1023  Solved: 604[Submit][Statu ...

  10. [Noi2016十连测第五场]二进制的世界

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...