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
?
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)这个分支.
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 Would |
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.
Windows环境从Apache2.2改成Apache2.4后httpd.conf中的设置异同。
1、权限设定方式变更
2.2使用Order Deny / Allow的方式,2.4改用Require
apache2.2:
Order deny,allow Deny from allapache2.4:
Require all denied此处比较常用的有如下几种:
Require all denied
Require all granted
Require host xxx.com
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.