在/etc/httpd/conf.d下添加配置文件时是否需要重启/重新加载Apache?
我知道编辑 httpd.conf 需要重新启动或重新加载,但不确定放置在 conf.d 中的文件是否需要 apache 重新启动。
谢谢您的帮助
编辑:我的印象是,添加到 /conf.d 需要定期/正常重启,但我添加到该目录中的配置文件多次生效而无需重启。这就是促使我提出这个问题的原因。
我正在一个网站上工作,我需要在 .htaccess 中使用重写命令。它不起作用,终于找到了我需要设置的问题
我的 Apache httpd.conf 中的“AllowOverride All”
我想知道当我将设置从“AllowOverride None”更改为“AllowOverride All”时是否应该注意任何安全问题?
谢谢!
在我的错误日志中,我看到:
server reached MaxClients setting, consider raising the MaxClients setting
Run Code Online (Sandbox Code Playgroud)
我的 MaxClients 设置是 150。但是,当我计算出似乎是最佳 MaxClients 设置时,我想出了:
Mem used by 1 Apache process = 16
Mem available to Apache = 197
MaxClients = 12 (197/16)
Run Code Online (Sandbox Code Playgroud)
那么我应该将 MaxClients 降低到 12,因为我的计算表明这是我可用的所有 RAM 还是我应该按照错误日志的建议提高限制(或者我的计算是否毫无价值,因为我误解了一些东西)?
我有一个只能通过 POST 方法访问的文件。
/var/www/folder/index.php
Run Code Online (Sandbox Code Playgroud)
文档根是/var/www/
和index.php
嵌套在文件夹内。
Apache 的版本是:2.4.4。
我的配置如下:
<Directory "/var/www/folder">
<Files "index.php">
order deny,allow
Allow from all
<LimitExcept POST>
Deny from all
</LimitExcept>
</Files>
</Directory>
Run Code Online (Sandbox Code Playgroud)
我访问我的服务器,127.0.0.1/folder
但我可以像往常一样获取和发布文件。
我也试过颠倒顺序order allow,deny
、、要求、限制除外和限制。
如何只允许一个文件夹中的一个文件处理 POST 请求?
我们目前在 为 IT 设置了一个内部站点it.example.com
,该站点托管一个Redmine站点。
我想设置 Apache,以便在用户访问时将kb.example.com
其重定向到http://it.example.com/some/path/to/knowledge-base
快捷方式。
我<VirtualHost>
在 httpd.conf 的末尾添加了一个,现在每当我尝试访问主站点 (it.example.com) 时,浏览器都会进入无限重定向循环:
这是我的httpd.conf
:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.37
PassengerDefaultRuby /usr/bin/ruby
</IfModule>
ServerName it.example.com
ServerAdmin support@example.com
DocumentRoot /var/www/redmine-2.4.3/public
ErrorLog logs/redmine_error_log
SetEnv RAILS_ENV production
SetEnv RailsEnv production
#If you are using mod_fcgid and are going to upload files larger than
#131072 bytes you should consider adding the following line
#that allows to upload files up to 20 …
Run Code Online (Sandbox Code Playgroud) 我们有一台运行七个域/子域的服务器。为了尽量减少这里的数量,我将包括其中的四个。
服务器在 90% 的时间内都运行良好,但偶尔我们会收到大量请求并且数据库服务器出现故障。这然后最大的 apache 连接,因为所有的数据库连接都在等待超时。一切顺利,我们强制重启数据库,连接恢复。但是,请求随后会进入 dfw.example.com 配置。该部署没有我们的代码库,这是一个大问题,我不明白为什么会发生这种情况。发生这种情况时,它也会始终进行该部署,而我们拥有的其他 5 个部署中的任何一个都不会。
从我阅读的文档中,我认为 Apache 通读了 httpd.conf 文件并查找了第一个 NamedVirtualHost 匹配项:
现在,当请求到达时,服务器将首先检查它是否使用与 NameVirtualHost 匹配的 IP 地址。如果是,那么它将查看
<VirtualHost>
具有匹配 IP 地址的每个部分,并尝试找到 ServerName 或 ServerAlias 与请求的主机名匹配的部分。如果找到,则使用该服务器的配置。如果未找到匹配的虚拟主机,则将使用与 IP 地址匹配的第一个列出的虚拟主机。
我们正在运行 Apache 2.2.15。
我认为与 httpd.conf 文件相关的部分:
Listen 80
Listen 255.255.255.255:443
Run Code Online (Sandbox Code Playgroud)
...
ServerName www.example.com
Run Code Online (Sandbox Code Playgroud)
...(这是确切的顺序,www (https/http),dfw,然后是所有其他版本)
NameVirtualHost www.example.com:80
<VirtualHost www.example.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/www.example.com
ServerName www.example.com
DirectoryIndex index.html
DirectoryIndex index.php
LogLevel notice
ErrorLog /var/log/httpd/www.example.com/error.log
CustomLog /var/log/httpd/www.example.com/access.log w3c_extended
</VirtualHost>
NameVirtualHost www.example.com:443
<VirtualHost www.example.com:443>
ServerAdmin webmaster@example.com
DocumentRoot …
Run Code Online (Sandbox Code Playgroud) 我目前有静态和动态页面的单独访问日志。我的httpd.conf有(在<VirtualHost> 内):
<LocationMatch "^/(img|js|css|thumb|banner)/(.+)$">
SetEnv static 1
</LocationMatch>
CustomLog /var/log/apache2/gopal.log myCustom env=!static
CustomLog /var/log/apache2/gopal-static.log myCustom env=static
Run Code Online (Sandbox Code Playgroud)
我想补充它
SetEnvIf Remote_Addr "127.0.0.1" dontlog
CustomLog /var/log/apache2/gopal.log myCustom env=!dontlog
Run Code Online (Sandbox Code Playgroud)
,但找不到使用 CustomLog expr=参数的示例并且无法猜测有效表达式:
expr=!(reqenv('static')||reqenv('dontlog'))
产生
语法错误,意外的 T_OP_OR
By default, httpd contains the following configuration:
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
...
</IfModule>
Run Code Online (Sandbox Code Playgroud)
This file contains a mapping from filename extensions to MIME types. Normally this is what I want, but I'd like to disable mapping for reverse proxies. How can I instruct mime_module to process /*
but exclude /proxy/*
?
mime_module contains the following line:
application/x-msdownload exe dll com …
Run Code Online (Sandbox Code Playgroud) 目前我有以下内容的“ports.conf”:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
Listen 443
NameVirtualHost *:443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Run Code Online (Sandbox Code Playgroud)
因此,要添加 IPv6,我必须将其更改为:
NameVirtualHost 91.64.99.215:80
Listen 91.64.99.215:80
NameVirtualHost [2a01:4f8:140:54e4::3]:80
Listen [2a01:4f8:140:54e4::3]:80
<IfModule mod_ssl.c>
Listen 443
NameVirtualHost 91.64.99.215:443
NameVirtualHost [2a01:4f8:140:54e4::3]:443
</IfModule>
<IfModule mod_gnutls.c>
Listen 91.64.99.215:443
Listen [2a01:4f8:140:54e4::3]:443
</IfModule>
Run Code Online (Sandbox Code Playgroud)
这样对吗?
我担心的是,如果我这样做,所有虚拟主机都设置为
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld
DocumentRoot /www/domain
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
会发疯。如果不是这种情况,请执行
<VirtualHost *:80 [*]:80>
ServerName www.domain.tld
ServerAlias domain.tld
DocumentRoot /www/domain
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
还应该通过 IPv6 使域可用吗?
我在这里有点困惑,无法从现有的“示例”中获得太多帮助,我们将不胜感激。
我是服务器维护的新手,正在 Ubuntu 14.10 上运行 Apache 2.4 在我昨天刚刚设置的 VPS 上。由于以下原因,我似乎在机器的不同位置安装了两个不同的 Apache。
当我跑步时sudo /usr/local/apache2/bin/apachectl start
,ps -A
我得到了这个:
4408 ? 00:00:00 httpd
4409 ? 00:00:00 httpd
4410 ? 00:00:00 httpd
4411 ? 00:00:00 httpd
Run Code Online (Sandbox Code Playgroud)
它/usr/local/apache2/logs/error_log
用类似的东西更新错误日志
[Sat Feb 14 00:16:49.963014 2015] [mpm_event:notice] [pid 4542:tid 140160010012544] AH00489: Apache/2.4.12 (Unix) mod_wsgi/4.4.8 Python/2.7.8 configured -- resuming normal operations
[Sat Feb 14 00:16:49.963260 2015] [core:notice] [pid 4542:tid 140160010012544] AH00094: Command line: '/usr/local/apache2/bin/httpd'
Run Code Online (Sandbox Code Playgroud)
由在以下位置找到的配置文件设置 usr/local/apache2/conf/httpd.conf
但是,如果我运行sudo apachectl start
(在停止 1 中的示例之后),然后ps -A …
httpd.conf ×10
apache-2.2 ×7
apache-2.4 ×2
httpd ×2
virtualhost ×2
centos ×1
http-headers ×1
ipv6 ×1
linux ×1
mime-type ×1
redirect ×1
security ×1
ubuntu-14.10 ×1