windows平台下快速配置Apache+PHP服务器环境
一直以来,Apache是PHP应用理想的Web服务器,已经成为PHP应用的首选Web服务器软件。Apache与PHP均提供了详细的配置参数,但是在一般情况下,我们只需对其中的少数参数进行设置,其它的取默认即可。windows平台下快速配置Apache+PHP服务器环境如下:1.安装Apache
在http://httpd.apache.org网站上可以下载到最新的Apache的安装包,记住选用Win32 binary(MSI Installer)版本的。我使用的是apache_2.2.10-win32-x86-openssl-0.9.8i.msi,估计也不是新的了。运行安装程序,由于我已经在机器上安装了Apache,而且进行了一些配置,所以不方便重装并截图,请谅解,只能文字说明。安装中注意的就是设置Network Domain(服务器所在域)和 Server Name(服务器名,一般填127.0.0.1).我建议大家安装的时候可以安装在C:\Apache2.2下.以便于操作和配置。
2.安装PHP
在http://www.php.net网站上下载PHP,我的不是安装版本的,但是可以导入注册表,我使用的是php-5.2.6-Win32.zip。
3.配置Apache
进入Apache的安装目录,我的是C:\Apache2.2\conf,编辑该目录下的httpd.conf文件,用一般的记事本打开即可,如果打开的时候文件不规整,可以使用专门的IDE工具打开,如UltraEdit打开编辑。在该文件中以“#”开始的行为为注释行,而且注释行中都给出了具体的说明,我现给出我的配置详细参数:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule php5_module "c:/php5/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php5"
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_alias_module modules/mod_authn_alias.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
(采用动态链接库的方式配置,使得PHP和Apache能一起工作)
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "e:/bookmage"
#
# 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 None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
(设置Web文件的根目录,Apahe将客户端的请求指向该目录,并在该目录下搜索被请求的页面)
DirectoryIndex index.php index.html
(设置目录文件中的默认检索文件)
4.配置PHP
将php5目录下的php.ini-recommended复制一份,更名为php.ini,然后放入php5目录下,这个文件便成为PHP的配置文件,在PHP运行时将使用它。具体配置如下:
; Allow the
页:
[1]