apache2.42.x和2.4.x有什么区别?为什么大多数用2.2.x的

TCP/IP网络应用(9)
ubuntu12.04默认安装apache2.2& 没找到查询版本号的方法。解决方法 sudo apt-get install apache2
提示安装以下软件: apache2-mpm-worker apache2.2-bin apache2.2-common libaprutil1-dbd-sqlite3 libaprutil1-ldap
之后,就可以正常使用apache2 -v命令了。一共三个:apache2&&&& apache2ctl& apachectl
ubuntu14.04默认安装apache2.4 使用 apache2 -v即可查询版本号。
httpd-2.2.x(prefork)
httpd-2.4.x(event) 编译时可以使用--with-mpm=prefork手动指定其使用prefork
PHP官方推荐httpd使用prefork(php能更稳定地运行),而不是线程化的worker和event,httpd-2.4.x默认使用线程化的event作为mpm.
Linux上很多PECL库都是非线程安全的,libphp5.so在线程化的httpd(event/worker)中运行可能会出现一些问题,为了保持兼容性和稳定性,PHP一般还是使用httpd-2.2.x(prefork)这个分支.
原因很简单,linux上升级软件很困难,没人敢冒险升级&& 如果不出大问题,服务器的软件很少有大的升级
2.4 apache2.conf 文件逻辑更清晰,直接修改directory.
2.2 在/etc/apache2/mods-available中建立python.load&&&&& python.conf
apache支持静态页,tomcat支持动态的,比如servlet等,
一般使用apache+tomcat的话,apache只是作为一个转发,对jsp的处理是由tomcat来处理的。
apche可以支持phpcgiperl,但是要使用java的话,你需要tomcat在apache后台支撑,将java请求由apache转发给tomcat处理。
apache是web服务器,tomcat是应用(java)服务器,它只是一个servlet(jsp也翻译成servlet)容器,可以认为是apache的扩展,但是可以独立于apache运行。
这两个有以下几点可以比较的:
1、两者都是apache组织开发的
2、两者都有HTTP服务的功能
3、两者都是免费的
Apache是专门用了提供HTTP服务的,以及相关配置的(例如虚拟主机、URL转发等等)
Tomcat是Apache组织在符合J2EE的JSP、Servlet标准下开发的一个JSP服务器
On Ubuntu, I am trying to get the httpd.conf file for apache2. My server does not show one.
Would apache2.conf be the same as httpd.conf?
apache2.conf: the main Apache2 configuration file. Contains settings that are global to Apache2.
httpd.conf: historically the main Apache2 configuration file, named after the httpd daemon. The file can be used for user specific configuration options that globally effect Apache2.
So to echo @slhck - I would source the httpd.conf from the
apache2.conf.
httpd.conf is empty (or nonexistent) in some distributions. If anapache2.conf is present you should probably not edit this, but include your ownhttpd.conf from the
apache2.conf. This is because apache2.conf may be overwritten by package updates.
Your apache2.conf therefore should include this line. If it doesn't already, you can add it yourself:
Include httpd.conf
/etc/apache2/conf.d is also a good place to put configuration files.
Apache2.2和Apache2.4中httpd.conf配置文件的异同
编辑: upupw 发布时间:
11:32:01 来源:
热度: 8780
Windows环境从Apache2.2改成Apache2.4后httpd.conf中的设置异同。
1、权限设定方式变更
2.2使用Order Deny / Allow的方式,2.4改用Require
apache2.2:
Order deny,allow
Deny from all
apache2.4:
Require all denied
此处比较常用的有如下几种:
Require all denied
Require all granted
Require ip 192.168.1 192.168.2
Require local
注意:若有设定在htaccess文件中的也要修改
2、设定日志纪录方式变更
RewriteLogLevel 指令改为 logLevel
LOGLEVEL设置第一个值是针对整个Apache的预设等级,后方可以对指定的模块修改此模块的日志记录等级
LogLevel warn rewrite: warn
3、Namevirtualhost 被移除
4、需载入更多的模块
开启Gzip在apache2.2中需载入mod_deflate,apache2.4中需载入mod_filter和mod_deflate
开启SSL在apache2.2中需载入mod_ssl,apache2.4中需载入mod_socache_shmcb和mod_ssl
5、在windows环境建议的设置
EnableSendfile Off
EnableMMAP Off
当Log日志出现AcceptEx failed等错误时建议设置
AcceptFilter http none
AcceptFilter https none
说明:Win32DisableAcceptEx在apache2.4中被AcceptFilter None取代
6、Listen设定的调整
以443为例,不可以只设定Listen 443
会出现以下错误:
(OS 10048)一次只能用一个通讯端地址(通讯协定/网路位址/连接) : AH00072: make_sock: could not bind to address [::]:443
(OS 10048)一次只能用一个通讯端地址(通讯协定/网路位址/连接) : AH00072: make_sock: could not bind to address 0.0.0.0:443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs
因此需指定监听的IP,可设定多个
Listen 192.168.2.1:443
Listen 127.0.0.1:443
ppeix:apache2$ apachectl start
/usr/sbin/apachectl: 87: ulimit: error setting limit (Operation not permitted)
Syntax error on line 15 of /etc/apache2/sites-enabled/000-default:
Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
Action 'start' failed.
The Apache error log may have more information.
解决办法:安装ppeix:apache2$ sudo apt-get install libapache2-mod-python
ppeix:apache2$ apachectl start
/usr/sbin/apachectl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:111934次
积分:3218
积分:3218
排名:第9101名
原创:205篇
转载:59篇
评论:11条
(3)(1)(2)(1)(8)(6)(2)(3)(1)(1)(13)(6)(7)(3)(1)(3)(7)(26)(29)(4)(10)(23)(7)(18)(12)(19)(22)(27)Apache2.4.x与Apache2.2.x的一些区别-爱编程
Apache2.4.x与Apache2.2.x的一些区别
    改用Apache2.4一段时间了,一直没发现它和Apache2.2的有什么区别,一些基本配置都是差不多,直到前几天配置虚拟主机是才发现了一些小小的不同
    一直以来我都是在htdocs目录下配置虚拟主机的,大体上使用的方法如下:
&VirtualHost *:80&
DocumentRoot
"D:/www/Apache24/htdocs"
ServerName localhost
&Directory D:/www/Apache24/htdocs&
DirectoryIndex index.html index.php
Order Deny,Allow
Allow from all
&/Directory&
&/VirtualHost&
&  但是最近我想在目录htdocs之外配置虚拟主机,还是按照上面的老套路来配置,结果出现的403错误:
You don't have permission to access / on this server.
&  瞬间没了头绪,这是在Apache2.2所没有的出现过的情况啊,然后试着将虚拟主机的根目录改成htdocs目录之下,也就是
DocumentRoot
"D:/www/Apache24/htdocs/test"
  发现网站又能正常运行了,反复试了多次都是同一的结果。然后我就想到底是哪个地方出现了问题,这个问题困扰了我几天,百度找了无数答案,大部分都是说目录的权限有错误,需要修改权限,或者是selinux设置的问题,可是我运行的环境是windows,所以这些情况也被排除在外;有些说是需要设置Allow from all ,也没有效果。
  通过查看错误日志,发现有那么一行:
AH01630: client denied by server configuration: D:/www/
  但是我的Order指令设置都是正确的,这样我郁闷了一段时间,无意中发现了一篇文章描述Apache2.4与Apache2.2之间的一些指令的差异,刚好解决了我的问题,
  其中的一些指令已经无效,如:
Order Deny,AllowDeny from allAllow from al
   取而代之的是: 
Deny from all
Require all denied
Allow from all
Require all granted
  于是我将虚拟机配置为:
&VirtualHost *:80&
DocumentRoot "D:/www/sphinx/api"
ServerName
&Directory "D:/www/sphinx/api"&
DirectoryIndex index.html index.php
Require all granted
&/Directory&
&/VirtualHost&
  发现还是提示403错误,只不过这次的错误日志的错误变成:
AH01276: Cannot serve directory D:/www/sphinx/api/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
  这是因为里面的根目录里面没有index.html 或者 index.php,我们可以添加index.html文件或者将设置改成如下:
&VirtualHost *:80&
DocumentRoot "D:/www/sphinx/api"
ServerName
&Directory "D:/www/sphinx/api"&
Options FollowSymLinks Indexes
Require all granted
&/Directory&
&/VirtualHost&
  这样就算大功告成了,不过我敢肯定Apache2.4与Apache2.2的区别不止于此,只是我还没有发现而已,期待进一步的发现。
版权所有 爱编程 (C) Copyright 2012. . All Rights Reserved.
闽ICP备号-3
微信扫一扫关注爱编程,每天为您推送一篇经典技术文章。apache&2.4.x&特殊性
在apache2.4版本之前做客户端访问控制,是用Allow Deny
Order指令做访问控制的,而在2.4的版本上是用的用法跟之前的版本大不相同,如下
################################################&
2.2上的配置&
Order&deny,allow&
Deny&from&all&
2.4上的配置&
Require&all&denied&
################################################&
2.2上的配置&
Order&allow,deny&
Allow&from&all&
2.4上的配置&
Require&all&granted&
#################################################&
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
下面给出了几个例子在2.4版本上的配置
1. 仅允许IP为192.168.1.1的主机访问
&&/span&RequireAll&&
&&&&&&require&all&&granted&
&&&&&&require&ip&192.168.1.1&
&/&/span&RequireAll&&
2.仅允许192.168.0.0/24网络的主机访问
&&/span&RequireAll&&&
&&&&&&require&all&&granted&&
&&&&&&require&ip&192.168.1.0/24&
&/&/span&RequireAll&&&
3.禁止192.168.1.2的主机访问,其他的都允许访问,
&&/span&RequireAll&&
&&&&&&require&all&&granted&
&&&&&&require&not&ip&192.168.1.2&
&/&/span&RequireAll&&
4.允许所有访问,
require&all&&granted&&
注,这个可以不用加容器&......&
直接,写在& .....里面就可以了
5.拒绝所有访问,
require&all&&denied&&
apache &alias &别名
最近设置虚拟目录老是设置不成功,于是百度一下Apache Alias
找到如下资料终于明白了问题的根源,没有设置目录的访问权限!
You don't have permission to access the requested object. It is
either read-protected or not readable by the server.
可以做一个别名访问&
例如www目录下没有 /zen目录
但是通过url连接 访问 [url]/zen[/url]
指定到 系统下的一个目录 例如
/home/zen/www/
那么我们需要这么设置
Alias /zen /home/zen/www
&Directory /home/zen/www&
Order allow,deny
Allow from all
&/Directory&&
另外一个别名是在系统中使用的
做一个别名alias
例如做别名 alias aa=ls
那么我们输入aa 也会具有ls的效果
如果我们需要永久的使用aa来代替ls命令
那么我们可以编辑.bashrc
&&& 文件 在里面加上
alias aa=ls
那么这个用户每次都可以输入aa来达到文件列表的效果
编辑文件 想要让他立即生效 使用 下面这个命令 重新加在配置文件
重新加载 source /root/.bashrc
在 xampp &中
&访问出现以下情况&
Unknown: failed to open stream: Permission denied
in&Unknown&on
Fatal error:
Unknown: Failed opening required '/opt/lampp/htdocs/aa.php'
(include_path='.:/opt/lampp/lib/php')
in&Unknown&on
原因就是文件访问权限的问题 &设置权限 775
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 apache2.4 配置 的文章

 

随机推荐