日期:2014-05-17  浏览次数:20733 次

Apache+PHP配置过程详解

经过两晚上的奋斗终于将Apache配置PHP成功,安装配置过程中走了不少弯路,特记录之。

1.Apache配置PHP个人认为首先要注意的是Apache和PHP的版本信息,不同的版本之间所要进行设置的参数是不同的,开始的盲目让自己受尽了苦头。

2.选择版本:Apache 2.2.14 ?PHP:5.2.5 具体细节不再赘述。。。

3.验证Apache和PHP是否安装成功:

? (1) Apache: http://localhost

?(2)PHP:在dos窗口下运行php -i

4.PHP配置文件php.ini

? (1)修改:

extension_dir = “./”?

? ? extension_dir = "C:/Program Files/PHP/ext" (自己安装PHP的实际目录下ext子目录的路径)

? (2)取消注释以支持mysql数据库

? ? ?extension=php_mysql.dll

? ? ?extension=php_mysqli.dll

? (3)环境变量:

PHPRC: C:\Program Files\PHP

Path中添加:C:\Program Files\PHP

将文件liblibmysql.dll 拷贝入C:\WINDOWS\system32

? (这一步不进行可能会报Httpd.exe错误)

5.Apache配置文件httpd.conf

?(1)添加对php的支持

? ?LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

? ?PHPIniDir "C:/Program Files/PHP"

?(2)实际工作的目录:

? ? DocumentRoot "F:/ApcheWork"

? ?<Directory "F:/ApcheWork">

? ?<Directory "F:/WWW" >

? ? Options FollowSymLinks

? ? AllowOverride None

? ? Order deny,allow

? ? allow from all

</Directory>

?(3)添加对index.php的支持

? ? <IfModule dir_module>

? ? DirectoryIndex index.php index.html

</IfModule>

? (4) 添加类型支持

? ? AddType application/x-httpd-php .php

? ? AddType application/x-httpd-php .html

? ? AddType application/x-httpd-php .php .phtml .php3 .php4?

AddType application/x-httpd-php-source .phps?

?

附:配置PhpMyAdmin过程中出现的问题及解决方法

问题1:没有找到 PHP 扩展 mbstring,而您现在好像在使用多字节字符集。没有 mbstring 扩展的 phpMyAdmin 不能正确分割字符串,可能产生意想不到的结果。

解决方法:

编辑PHP配置文件php.ini,

;extension=php_mbstring.dll

改成

extension=php_mbstring.dll

?

问题2:无法加载 mcrypt 扩展 请检查您的 php 配置。

解决方法:

(1)找到php目录下的libmcrypt.dll,并将libmcrypt.dll复制到C:\windows \system32目录中

(2)编辑PHP配置文件php.ini,,

将“;extension=php_mcrypt.dll”

改成

extension=php_mcrypt.dll?

?

问题3:链接表的额外特性尚未激活。

解决方法:

(1)选取目录下scripts/ create_tables.sql 文件,再点击执行,会自动生成一个名为phpmyadmin的数据库。

(2)用PHP编辑器打开config.inc.php文件,找到:

$cfg['Servers'][$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql

$cfg['Servers'][$i]['bookmarktable'] = ''; // 'pma_bookmark'

$cfg['Servers'][$i]['relation'] = ''; // 'pma_relation'

$cfg['Servers'][$i]['table_info'] = ''; // 'pma_table_info'

$cfg['Servers'][$i]['table_coords'] = ''; // 'pma_table_coords'

$cfg['Servers'][$i]['pdf_pages'] = ''; // 'pma_pdf_pages'

$cfg['Servers'][$i]['column_info'] = ''; // 'pma_column_info'

$cfg['Servers'][$i]['history'] = ''; // 'pma_history'

改成:

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; // 'phpmyadmin' - see scripts/create_tables.sql

$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; // 'pma_bookmark'

$cfg['Servers'][$i]['relation'] = 'pma_relation'; // 'pma_relation'

$cfg['Servers'][$i]['table_info'] = 'pma_table_info'; // 'pma_table_info'

$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; // 'pma_table_coords'

$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; // 'pma_pdf_pages'

$cfg['Servers'][$i]['column_info'] = 'pma_column_info'; // 'pma_column_info'

$cfg['Servers'][$i]['history'] = 'pma_history'; // 'pma_history'

问题4:配置文件现在需要一个短语密码。

解决方法:

编辑配置文件config.inc.php,修改下项参数:$cfg['blowfish_secret'] = '123456';