php在iis上配置时报Fatal error: Call to undefined function mysql_connect() in 错误解决办法

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,高可用系列 2核4GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:
php5与apache工作没有问题,但是和iis整合不到一起,访问数据库时会报错:Fatal error: Call to undefined function mysql_connect() in

看phpinfo页面发现,没有加载到php.ini文件,即在phpinfo中查看时发现应该去到c:\windows里面找php.ini文件,可是没有读取到,但是在c:\windows目录中确实有php.ini文件,情况如下:

Configuration File (php.ini) Path C:\WINDOWS 
Loaded Configuration File (none) 

解决办法,说实话也不知道是哪一步是彻底解决问题的,反正一个是在系统的环境变量中加了一个PHPRC,让这个PHPRC去指向我的php安装目录,另外一个是执行了一下iisreset,之后就可以了,不过那也不是读取的c:\windows\php.ini,是读取的php安装目录中的ini文件,反正操作数据库是没错误了。

参考文章:

It seems every time I try to install PHP and MySQL something doesn't work - usually there's either a file missing from the PHP distro or something in the install notes is missing or incorrect.  This time it was both.

I first tried the PHP msi install - first mistake.  As it does not include the MySQL extensions - neither does the 5.2.6 PECL zip file (I mistakenly thought this would include all the extensions).  So if you've installed PHP using the MSI installer - uninstall it (via Control Panel - Add/Remove Programs).  Also - you may need to manually remove any remants of this PHP installation manually - I had to manually delete the php directory.

Now with a clean slate do the following:

   1. Download the PHP zip package from here.
   2. Extract the zip - in my case into C:\PHP5
   3. Copy php.ini-recommended and rename it to php.ini (within this same dir).
   4. Edit php.ini and make the following changes:
         1. Set the extension dir eg:
            extension_dir = "C:\PHP5\ext"
         2. Uncomment the extension setting for mysql eg remove the ';' from the beginning of the line:
            extension=php_mysql.dll
   5. Within IIS admin tool:
         1. Within Application Configuration (within 'Home Directory' of a site) add the php extension - mapping 'php' to php5isapi.dll (eg D:\php-5.2.6-Win32\php5isapi.dll).
         2. Within Web Service Extensions add one for php5isapi.dll (eg D:\php-5.2.6-Win32\php5isapi.dll) setting it to 'Allowed'.
   6. Update the PATH environment variable to include the php dir eg D:\php-5.2.6-Win32.
   7. Add a new environment variable called PHPRC and set to the php dir eg D:\php-5.2.6-Win32  (this part was missing from the install docs for IIS).
   8. Restart iis (eg run iisreset from the command prompt).

Bingo - that's it. To test create a file called phpinfo.php (and place in the web root) with the following:
<?php
phpinfo();
?>

The critical part to check here is that the output of this phpinfo shows the 'Loaded Configuration File' is set to the php.ini file you created above.  If PHP is configured correctly to use mysql it this (phpinfo output) will have a MySQL section - if this is missing - then something is wrong.


本文转自holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/387037


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
11天前
|
API C++
【Azure 环境】VS Code登录China Azure(Function)报错 An error occurred while signing in: invalid_request - AADSTS65002
An error occurred while signing in: invalid_request - AADSTS65002: Consent between first party application 'c27c220f-ce2f-4904-927d-333864217eeb' and first party resource '797f4846-ba00-4fd7-ba43-dac1f8f63013' must be configured via preauthorization - applications owned and operated by Microsoft mus
77 13
|
6月前
|
关系型数据库 MySQL Java
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
|
2月前
|
网络安全 Windows
Windows IIS 10如何配置自签名SSL并实现自动跳转
本文记录了IIS配置自签名证书及HTTPS跳转的注意事项。包括解决443端口占用问题、URL Rewrite插件安装与配置、web.config修改方法,以及避免因旧教程导致的配置错误。
Windows IIS 10如何配置自签名SSL并实现自动跳转
|
4月前
|
关系型数据库 MySQL Java
安装和配置JDK、Tomcat、MySQL环境,以及如何在Linux下更改后端端口。
遵循这些步骤,你可以顺利完成JDK、Tomcat、MySQL环境的安装和配置,并在Linux下更改后端端口。祝你顺利!
294 11
|
5月前
|
Ubuntu 关系型数据库 MySQL
在Ubuntu 22.04上配置和安装MySQL
以上就是在Ubuntu 22.04上配置和安装MySQL的步骤。这个过程可能看起来有点复杂,但只要按照步骤一步步来,你会发现其实并不难。记住,任何时候都不要急于求成,耐心是解决问题的关键。
564 30
|
5月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
1298 26
|
5月前
|
存储 Oracle 关系型数据库
MySQL 8.4 配置SSL组复制(八个步骤)
MySQL 8.4 配置SSL组复制(八个步骤)
233 0
|
6月前
|
SQL 关系型数据库 MySQL
seatunnel配置mysql2hive
本文介绍了SeaTunnel的安装与使用教程,涵盖从安装、配置到数据同步的全过程。主要内容包括: 1. **SeaTunnel安装**:详细描述了下载、解压及配置连接器等步骤。 2. **模拟数据到Hive (fake2hive)**:通过编辑测试脚本,将模拟数据写入Hive表。 3. **MySQL到控制台 (mysql2console)**:创建配置文件并执行命令,将MySQL数据输出到控制台。 4. **MySQL到Hive (mysql2hive)**:创建Hive表,配置并启动同步任务,支持单表和多表同步。
|
8月前
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
108 11
|
10月前
|
存储 SQL 关系型数据库
2024Mysql And Redis基础与进阶操作系列(1)作者——LJS[含MySQL的下载、安装、配置详解步骤及报错对应解决方法]
Mysql And Redis基础与进阶操作系列(1)之[MySQL的下载、安装、配置详解步骤及报错对应解决方法]

热门文章

最新文章

推荐镜像

更多