文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>找不到php.ini,可能是PHP5.2.5的一个Bug

找不到php.ini,可能是PHP5.2.5的一个Bug

时间:2008-04-27  来源:cy_xiaoxiao

今天在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也可以安装了。期待高人指点!


  • 相关阅读 更多 +
    排行榜 更多 +
    西安交大通

    西安交大通

    生活实用 下载
    长江云通

    长江云通

    生活实用 下载
    translatez

    translatez

    生活实用 下载