0

0

PHP学习启动,环境大搭建

php中文网

php中文网

发布时间:2016-06-13 10:38:34

|

829人浏览过

|

来源于php中文网

原创

PHP学习起步,环境大搭建

本文章教你如何一步一步搭起PHP开发环境

虽然在网上可以随便找到相关的PHP搭建环境,可是我觉得有几点不好,搭建的方式不一,使得开发者不知道相信谁的话,其二,对于开发者在搭建的过程中遇到的问题避而不答,我觉得这是最要命的。其三,搭配的版本不一,其涉及的搭配核心没有告诉开发者,于下,我将避重就轻,介绍PHP环境的搭建和测试。


  • 下载好所需的软件,由于我比较倾向较新的版本,所以我的搭建环境是Win 7+PHP5.2.17+MySql5.5.23+Apache2.2.22
  • 这里要注意的一点就是PHP,下载时候尽量选择压缩包格式,一方面压缩包说占用的空间较少,最重要的是如果使用安装包的话,那么安装之后你会发现安装目录中会缺少很多文件,不如拓展文件,这个问题让我很恼火,我重装了2次,问题还是依旧,所以我就断定安装包的问题,所以最好的处理方式就是使用压缩包,这里我选择的是VC6 x86 Thread Safe (2011-Mar-22 13:29:30)下载地址是:http://windows.php.net/downloads/releases/php-5.2.17-Win32-VC6-x86.zip这里没选择VC9是因为,给版本针对IIS(官网是这样说的)。
  • 至于软件的安装,我在这就不造轮子了,不同的版本大同都有些差异,比如MySql,由于我安装的是最新版的,其安装的变化之大,只有自己慢慢领悟,还有一点就是安装Apache时需要你填domain,这个不太重要,但是要填正确,我填的是本地的地址127.0.0.1(或者localhost).还有注意一点的是,安装目录最好自定义,不建议安装在Program Files文件中,安装的步骤自己安装说明来基本没什么大问题。
  • 软件的关联,这里需要关联的是,将PHP关联到Apache服务器上,将PHP关联的MySql数据库上
  1. 将PHP关联到Apache服务器上和数据库上,需要修改以下的配置文件,在Apache目录下的/conf/httpd.conf文件的末尾被PHP安装程序加增加了几句配置:httpd.conf
    1
    2
    3
    4
    #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    PHPIniDir "D:/PHP"
    LoadModule php5_module "D:/PHP/php5apache2_2.dll"
    #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    <span style="color: #008200;"><span style="font-size: 1em !important; line-height: 1.1em !important; white-space: pre !important;"></span></span><p style="font-size: 1em !important; line-height: 1.1em !important; white-space: pre !important; margin-bottom: 22px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-color: initial; vertical-align: baseline; background-color: #f7f7f7;">但现在Apache还不具备PHP5的功能,因为还需要对PHP进行一些配置,需要编辑PHP目录下的php.ini文件<span style="color: #008200 !important;">(</span><span style="color: #ff0000;">如果是PHP压缩包的话,要将<span >php.ini-dist”文件,将其重命名为“php.ini</span></span><span style="color: #008200;"></span></p> <p style="margin-bottom: 22px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-color: initial; vertical-align: baseline; background-color: #f7f7f7;"><span ><span style="font-size: 1em !important; line-height: 1.1em !important; white-space: pre !important;"><span style="color: #008200;">)</span>,查看一下externsion_ext变量是不是指定到PHP目录下的ext文件夹,这个文件夹下放置着一些可能会用到的功能dll文件:</span></span></p> <div style="color: #008200 !important; font-size: 1em !important; line-height: 1.1em !important; white-space: pre !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-color: initial; vertical-align: baseline; background-color: #f7f7f7;"><div class="syntaxhighlighter bash" style="margin-top: 1em !important; margin-right: 0px !important; margin-bottom: 1em !important; margin-left: 0px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-color: initial; font-size: 1em !important; vertical-align: baseline; width: 620px; background-color: white !important;"> <table style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; font-size: 1em !important; vertical-align: baseline !important; background-image: none !important; background-color: initial !important; border-collapse: collapse; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border-color: initial !important; float: none !important; height: auto !important; line-height: 1.1em !important; text-align: left !important; width: 620px; direction: ltr !important;">php.ini<tr style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-color: initial !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: initial !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: auto !important; direction: ltr !important;"> <td class="gutter" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: initial !important; border-color: initial !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: auto !important; direction: ltr !important; color: #afafaf !important;"><div class="line number1 index0 alt2" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.5em !important; padding-bottom: 0px !important; padding-left: 1em !important; border-top-width: 0px !important; border-right-width: 3px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-color: initial !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: white !important; float: none !important; height: auto !important; line-height: 1.1em !important; text-align: right !important; width: auto !important; direction: ltr !important; white-space: pre !important; border-right-style: solid !important; border-right-color: #6ce26c !important;">1</div></td> <td class="code" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: initial !important; border-color: initial !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: 591px; direction: ltr !important;"><div class="container" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-color: initial !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: initial !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: auto !important; direction: ltr !important;"><div class="line number1 index0 alt2" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 1em !important; padding-bottom: 0px !important; padding-left: 1em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-color: initial !important; font-size: 1em !important; vertical-align: baseline !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; background-color: white !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: auto !important; direction: ltr !important; white-space: pre !important;"> <code class="bash plain" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-color: initial !important; font-size: 1em !important; vertical-align: baseline !important; background-image: none !important; background-color: initial !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; float: none !important; height: auto !important; line-height: 1.1em !important; width: auto !important; direction: ltr !important; display: inline !important;">extension_dir="D:\PHP\ext"

    然后需要打开PHP的MYSQL功能,将如下行的注释(以分号;开头的行)去掉,并将其余暂时用不到externsion用注释(;)关闭掉。

    php.ini
    1
    2
    3
    4
    5
    6
    7
    8
    extension=php_curl.dll
    extension=php_gd2.dll
    extension=php_mbstring.dll
    extension=php_mysql.dll
    extension=php_pdo.dll
    extension=php_pdo_mysql.dll
    extension=php_pdo_odbc.dll
    extension=php_xmlrpc.dll
    配置完成,重启Apache服务器,如果没什么意外的话,这样的配置是不会出错的。
  • 还是Apache的配置文件,Ln 757,加入“AddType application/x-httpd-php .php”、“AddType application/x-httpd-php .html”两行,你也可以加入更多,实质就是添加可以执行php的文件类型,比如你再加上一行“AddType application/x-httpd-php .htm”,则.htm文件也可以执行php程序了,你甚至还可以添加上一行“AddType application/x-httpd-php .txt”,让普通的文本文件格式也能运行php程序。?
  • 链接数据库时最容易出现的问题就是提示?Fatal error: Call to undefined function,出现这个问题的原因是PHP加载mysql的拓展没有成功,网上对这个问题更是有千种的解决办法,如果你参考他们的话,最好做个备份,
  • 相关文章

    宝塔面板怎么导入数据库文件_SQL文件导入操作方法【说明】

    PHP 数组在中小项目中的应用方式

    宝塔面板如何设置网站的Session存储?在宝塔面板切换Session到Redis

    CodeIgniter数据库优化查询索引_CodeIgniter查询优化技巧【汇总】

    Hyperf常见配置冲突怎么排查_Hyperf设置问题诊断方法【解答】

    PHP速学教程(入门到精通)
    PHP速学教程(入门到精通)

    PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

    下载

    相关标签:

    本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

    上一篇:phpnegap文件上传 下一篇:php5.4.3装配教程

    热门AI工具

    更多
    DeepSeek
    DeepSeek

    幻方量化公司旗下的开源大模型平台

    豆包大模型
    豆包大模型

    字节跳动自主研发的一系列大型语言模型

    WorkBuddy
    WorkBuddy

    腾讯云推出的AI原生桌面智能体工作台

    腾讯元宝
    腾讯元宝

    腾讯混元平台推出的AI助手

    文心一言
    文心一言

    文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

    讯飞写作
    讯飞写作

    基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

    即梦AI
    即梦AI

    一站式AI创作平台,免费AI图片和视频生成。

    ChatGPT
    ChatGPT

    最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

    相关专题

    更多
    chatgpt使用指南
    chatgpt使用指南

    本专题整合了chatgpt使用教程、新手使用说明等等相关内容,阅读专题下面的文章了解更多详细内容。

    0

    2026.03.16

    chatgpt官网入口地址合集
    chatgpt官网入口地址合集

    本专题整合了chatgpt官网入口地址、使用教程等内容,阅读专题下面的文章了解更多详细内容。

    0

    2026.03.16

    minimax入口地址汇总
    minimax入口地址汇总

    本专题整合了minimax相关入口合集,阅读专题下面的文章了解更多详细地址。

    4

    2026.03.16

    C++多线程并发控制与线程安全设计实践
    C++多线程并发控制与线程安全设计实践

    本专题围绕 C++ 在高性能系统开发中的并发控制技术展开,系统讲解多线程编程模型与线程安全设计方法。内容包括互斥锁、读写锁、条件变量、原子操作以及线程池实现机制,同时结合实际案例分析并发竞争、死锁避免与性能优化策略。通过实践讲解,帮助开发者掌握构建稳定高效并发系统的关键技术。

    7

    2026.03.16

    TypeScript类型系统进阶与大型前端项目实践
    TypeScript类型系统进阶与大型前端项目实践

    本专题围绕 TypeScript 在大型前端项目中的应用展开,深入讲解类型系统设计与工程化开发方法。内容包括泛型与高级类型、类型推断机制、声明文件编写、模块化结构设计以及代码规范管理。通过真实项目案例分析,帮助开发者构建类型安全、结构清晰、易维护的前端工程体系,提高团队协作效率与代码质量。

    114

    2026.03.13

    Python异步编程与Asyncio高并发应用实践
    Python异步编程与Asyncio高并发应用实践

    本专题围绕 Python 异步编程模型展开,深入讲解 Asyncio 框架的核心原理与应用实践。内容包括事件循环机制、协程任务调度、异步 IO 处理以及并发任务管理策略。通过构建高并发网络请求与异步数据处理案例,帮助开发者掌握 Python 在高并发场景中的高效开发方法,并提升系统资源利用率与整体运行性能。

    141

    2026.03.12

    C# ASP.NET Core微服务架构与API网关实践
    C# ASP.NET Core微服务架构与API网关实践

    本专题围绕 C# 在现代后端架构中的微服务实践展开,系统讲解基于 ASP.NET Core 构建可扩展服务体系的核心方法。内容涵盖服务拆分策略、RESTful API 设计、服务间通信、API 网关统一入口管理以及服务治理机制。通过真实项目案例,帮助开发者掌握构建高可用微服务系统的关键技术,提高系统的可扩展性与维护效率。

    396

    2026.03.11

    Go高并发任务调度与Goroutine池化实践
    Go高并发任务调度与Goroutine池化实践

    本专题围绕 Go 语言在高并发任务处理场景中的实践展开,系统讲解 Goroutine 调度模型、Channel 通信机制以及并发控制策略。内容包括任务队列设计、Goroutine 池化管理、资源限制控制以及并发任务的性能优化方法。通过实际案例演示,帮助开发者构建稳定高效的 Go 并发任务处理系统,提高系统在高负载环境下的处理能力与稳定性。

    65

    2026.03.10

    Kotlin Android模块化架构与组件化开发实践
    Kotlin Android模块化架构与组件化开发实践

    本专题围绕 Kotlin 在 Android 应用开发中的架构实践展开,重点讲解模块化设计与组件化开发的实现思路。内容包括项目模块拆分策略、公共组件封装、依赖管理优化、路由通信机制以及大型项目的工程化管理方法。通过真实项目案例分析,帮助开发者构建结构清晰、易扩展且维护成本低的 Android 应用架构体系,提升团队协作效率与项目迭代速度。

    111

    2026.03.09

    热门下载

    更多
    网站特效
    /
    网站源码
    /
    网站素材
    /
    前端模板

    相关下载

    更多

    精品课程

    更多
    相关推荐
    /
    热门推荐
    /
    最新课程
    PHP课程
    PHP课程

    共137课时 | 13.7万人学习

    JavaScript ES5基础线上课程教学
    JavaScript ES5基础线上课程教学

    共6课时 | 11.3万人学习

    PHP新手语法线上课程教学
    PHP新手语法线上课程教学

    共13课时 | 1.0万人学习

    最新文章

    更多
    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送

    Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号