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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
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


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
存储 SQL 关系型数据库
创建并配置RDS实例
在阿里云上创建RDS实例涉及登录控制台、进入RDS管理页面、创建实例、选择数据库引擎和版本、配置实例规格与存储、设定网络与安全组、设置实例信息、确认订单并支付,最后初始化数据库。操作步骤可能因界面更新或数据库引擎不同略有差异。
19 1
|
1月前
|
关系型数据库 MySQL 开发工具
MySQL5.7主从配置(Docker)
MySQL5.7主从配置(Docker)
728 0
|
2月前
|
存储 监控 关系型数据库
rds迁移前准备资源评估与配置
rds迁移前准备资源评估与配置
37 5
|
3月前
|
关系型数据库 MySQL API
|
16天前
|
SQL 缓存 关系型数据库
mysql性能优化-慢查询分析、优化索引和配置
mysql性能优化-慢查询分析、优化索引和配置
83 1
|
22天前
|
缓存 关系型数据库 MySQL
MySQL查询优化:提速查询效率的13大秘籍(合理使用索引合并、优化配置参数、使用分区优化性能、避免不必要的排序和group by操作)(下)
MySQL查询优化:提速查询效率的13大秘籍(合理使用索引合并、优化配置参数、使用分区优化性能、避免不必要的排序和group by操作)(下)
|
28天前
|
应用服务中间件 Linux PHP
Linux下安装php环境并且配置Nginx支持php-fpm模块
Linux下安装php环境并且配置Nginx支持php-fpm模块
29 0
|
1月前
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
15 1
|
1月前
|
弹性计算 关系型数据库 MySQL
rds子网配置
在阿里云中配置RDS子网涉及五个关键步骤:1) 创建或选择VPC作为私有网络环境;2) 在VPC内创建子网并确保IP地址不重叠;3) 关联路由表和安全组以控制流量及访问权限;4) 创建RDS实例时指定VPC和子网;5) 确保ECS实例与RDS在同一VPC或配置相应跨VPC访问,并调整安全组规则。这样可保障RDS与其他资源的通信及网络性能。
19 6
|
1月前
|
NoSQL 关系型数据库 MySQL
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
216 0