Windows平台下PHP+Apache开发环境搭建方法备忘录

来源:互联网 发布:ipad蜂窝移动数据在哪 编辑:程序博客网 时间:2024/05/16 08:14
我使用的版本是:PHP5.3.24 + Apache Httpd 2.2.21,需要注意的是,Windows下的apache需要配合线程安全版本的PHP,在PHP官网下载时,需特别注意。比如PHP和Apache均安装在D盘根目录。

1、修改PHP配置文件:
1)将PHP安装目录中的php.ini-development改名为php.ini,并打开该文件
2)将extension_dir配置项修改为"D:/PHP/ext"
3)将doc_root配置项修改为"D:/Apache/htdocs"
4)将"extension=php_mysql.dll"前面的分号去掉,以支持MySQL数据库

2、修改Apache配置文件,搜索LoadModule,并在最后一个LoadModule后增加如下配置
LoadModule php5_module "D:/PHP/php5apache2_2.dll"PHPIniDir "D:/PHP"AddType application/x-httpd-php .phpAddType application/x-httpd-php .html
3、启动Apache,在浏览器中输入http://127.0.0.1,如果提示"It Works",说明Apache的配置文件没有问题,但是否能够正确处理PHP呢?继续下一步尝试

4、在doc_root目录中创建一个测试文件test.php,调用phpinfo函数,然后在浏览器中输入http://127.0.0.1/test.php,如果能够正常打印出php的环境信息,说明PHP的配置也没有问题
<?php    phpinfo();?>
5、一般情况下,我都习惯把代码放在专门的项目目录,这就需要创建虚拟目录。在apache的httpd.conf的<IfModule alias_module>标签中增加这段,然后在浏览器中输入http://127.0.0.1/phptest/test.php,如果能够正常打印出php的环境信息,说明虚拟目录配置也没有问题
<IfModule alias_module>    #    # Redirect: Allows you to tell clients about documents that used to     # exist in your server's namespace, but do not anymore. The client     # will make a new request for the document at its new location.    # Example:    # Redirect permanent /foo http://www.bluerye.lab/bar    #    # Alias: Maps web paths into filesystem paths and is used to    # access content that does not live under the DocumentRoot.    # Example:    # Alias /webpath /full/filesystem/path    #    # If you include a trailing / on /webpath then the server will    # require it to be present in the URL.  You will also likely    # need to provide a <Directory> section to allow access to    # the filesystem path.    Alias /phptest "D:/PHP Test Project"    <Directory "D:/PHP Test Project">        Options Indexes FollowSymLinks        AllowOverride None        Order allow,deny        Allow from all    </Directory>        # ScriptAlias: This controls which directories contain server scripts.     # ScriptAliases are essentially the same as Aliases, except that    # documents in the target directory are treated as applications and    # run by the server when requested rather than as documents sent to the    # client.  The same rules about trailing "/" apply to ScriptAlias    # directives as to Alias.    #    ScriptAlias /cgi-bin/ "C:/Program Files (x86)/Apache Software Foundation/Apache/cgi-bin/"</IfModule>


0 0
原创粉丝点击