PHP中,Apache的配置至关重要,特别是httpd.conf这个文件,它是Apache中的核心文件。好了,废话不说,今天将这个文件中的一些内容讲解一番。
ServerRoot "d:/wamp/bin/apache/apache2.2.21" //这个文件表示的是服务器,本地就是Apache,在计算机 中的位置
Listen 80 //这里表示监听的端口号,这里是80
LoadModule actions_module modules/mod_actions.so //表示的加载的模型,这个表示的是action
LoadModule alias_module modules/mod_alias.so //需要加载的模型,这里的这个表示需要加载的虚拟目录
其他的加载模块也是类似的
User daemon //用户进程
Group daemon //
这两个其实也没有什么,原文解释:
If you wish httpd to run as a different user or group, you must run httpd as root initially and it will switch.
User/Group: The name (or #number) of the user/group to run httpd as.
把它理解成进程就行。
ServerAdmin admin@localhost //服务器管理员的邮件地址,这里可以设置为你的有效邮件地址,这样的话,有什么问题就能发到你的邮箱中去提醒你
ServerName localhost:80 //服务器的用户名和对应的端口号
DocumentRoot "d:/wamp/www/" //这个目录下放的是我们编写的程序,然后通过localhost就能访问。例如,我在这个www目录下,有一个test.php .那么我就可以通过www.localhost/test.php或者是
www.127.0.0.1/test.php去访问(别忘了开启Apache)。当然你也可以把它改为其他目录。一般不建议改动。
如果改了上面那个文件夹,那么这个下面的文件夹也需要进行改正
<Directory "d:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
文件夹改正之后,其它的就不需要改
ErrorLog "d:/wamp/logs/apache_error.log" //这个是记录错误的日志以及它在计算机的位置
LogLevel warn
<IfModule log_config_module>
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog "d:/wamp/logs/access.log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog "logs/access.log" combined
</IfModule>
这个里面是关于错误的一些配置,可以不作了解
Include "d:/wamp/alias/*" //将alias目录下的文件包含进来,alias里面也可以放我们编写的程序,但需要进行修改