免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2055 | 回复: 0
打印 上一主题 下一主题

找不到php.ini,可能是PHP5.2.5的一个Bug [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-27 11:53 |只看该作者 |倒序浏览
今天在XP下安装Discuz,运行安装程序的时候,总是提示:“服务器不支持 MySql 数据库,无法安装论坛程序!”

我很郁闷啊,配置文件中明明已经打开了mysql的支持库,为什么打不开?
并且我已经把PHP写入到了系统变量里面:

于是运行phpinfo(),这才发现问题,大家看下面这个图:



怎么回事呀?没有配置文件,但是却显示配置文件目录为:C:\WINDOWS,安装PHP的时候,我并没有拷贝任何配置文件和dll文件到系统文件夹下呀。
现在网上很多解决方法就是拷贝配置文件和DLL库到系统文件夹,这样很是麻烦啊,下次升级或者重装就傻脸了。并且官方不推荐这样做:
     
     Upgrading from a previous PHP version: Previous editions of the manual suggest moving various ini and DLL files into your SYSTEM (i.e. C:\WINDOWS) folder and while this simplifies the installation procedure it makes upgrading difficult. We advise you remove all of these files (like php.ini and PHP related DLLs from the Windows SYSTEM folder) before moving on with a new PHP installation. Be sure   to backup these files as you might break the entire system. The old php.ini might be useful in setting up the new PHP as well. And as you'll soon learn, the preferred method for installing PHP is to keep all PHP related files in one directory and have this directory available to your systems PATH.

到网上找了很多方法都不能解决,并且我又想遵从官方指南。所以到官网仔细搜索了一边,才发现:

The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI version, it happens on every invocation.

这也就告诉我们,通过SAPI方式安装的PHP要重启服务器才能生效配置。所以,记得重启服务器,以便使新配置生效。

读取配置文件的位置有哪些呢?请看下边:

  • SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)

  • The PHPRC environment variable. Before PHP 5.2.0 this was checked after the registry key mentioned below.

  • As of PHP 5.2.0, the following registry locations are searched in order: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath, HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z mean the PHP major, minor and release versions.

  • HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)

  • Current working directory (except CLI)

  • The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows)

  • Windows directory (C:\windows or C:\winnt) (for Windows), or --with-config-file-path compile time option
    第一个肯定不是啦,我没有利用Apache,CGI,NSAPI,THTTPD。
    第二个我的版本是5.2.5,暂且不用。
    第三个和第四个均为我最先考虑的方法。但是经过建立注册表,发现都行不通。
    第五个当前工作目录,这个就更不方便了,我不能建立一个PHP应用就弄一个配置吧。
    第六个服务器目录,我用的是IIS,如果系统崩溃,放在C盘的配置文件就丢了;或者是PHP文件夹,我里面已经存在了,为什么读不出来啊?
    第七个我更不想要。
    最后,还是使用了建立系统变量PHPRC,指向我的配置文件,保存之后,重启。
    再次运行phpinfo();

    Discuz也可以安装了。期待高人指点!


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/43023/showart_600260.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP