Windows平台下PHP环境配置之PHP安装篇
原文:http://www.phpiask.com/?p=43 入门很不错
在本系列的上两篇文章:Mysql的安装和配置,Apache的安装中我们安装了数据库和Web服务器,转眼间我们就说到了我们的重点PHP。
至于PHP为什么叫做PHP,战地至少听说过两种说法,但是这个不重要了。就像谢逊有时候被人叫做金毛狮王一样,我们知道他就是他就行了。
第一步当然还是下载,下载地址在这里:http://www.php.net
记住这个是net域名不是com它们完全不是一回事儿。
点击页面上的download链接,进入下载页面,找到Windows Binaries 标题,并找到 PHP 5.0.4 zip package 的链接,下载它。不要想当然,我们不下载那个Installer文件,因为它不包含Mysql扩展,如果下载他来安装的会有一些麻烦——其实也可以解决。不过我们还是下载那么个zip包吧。
下载完成后,当然是解压缩——解压到D:\php下吧;
找到一个叫php.ini-recommended 的文件,复制这个文件到Apache的目录,改个名字——。这个名字应该修改为:php.ini。
注意:Apache查找php.ini文件的顺序是这样的:
先是apache的目录,然后系统目录,再到path指定的目录,所以放在Apache的目录下最容易被找到,呵呵……
就这样了PHP安装完成了,虽然他还不能和Apache一起工作,但是他已经完成安装了。真的!
不能工作安装它有个鸟用啊?——不要愤怒兄弟,战地还没有说完,下边咱们就把Apache和PHP糅合到一起,让他们一起上路。
还记得咱们安装Apache目录不?我记得!在D:\apache
打开这个目录找到conf文件夹打开,找到一个叫httpd.conf的文件,这个就是Apache的设置文件,一定要记住哦,以后用的地方多着呢。用记事本打开这个文件。
搜索 ScriptAlias,应该看到类似如下的内容:
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing “/” apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ “D:/apache/cgi-bin/”
对于 /cgi-bin/来说,此条目告诉 Apache 如何处理任何包含 cgi-bin 目录的 URL。例如,如果您请求了 http://www.phpiask.com/cgi-bin/mail-me,Apache 不会在 cgi-bin 目录中查找一个名为 mail-me 的文件。相反,ScriptAlias 命令会告诉 Apache 查看另一个目录 —— 在本例中,这个目录是”D:/apache/cgi-bin/”。这是至关重要的,因为您不会希望将脚本存储在可通过 Web 访问的目录中。因此,您需要为 PHP 脚本添加一个条目。如下所示:
ScriptAlias /php/ “D:/php/”
接下来,您需要告诉 Apache 以 .php 结尾的文件必须作为应用程序处理;尤其是,您希望为 PHP 文件分配一个类型,然后您就能够指示 Apache 以特定方式处理它们。在 ScriptAlias 条目下,添加以下条目:
AddType application/x-httpd-php .php
仅仅这些还不够,回头看看吧,我们只告诉了Apache一个目录映射和遇到以php为扩展名的文件当作什么处理,我们还没有告诉他,这个处理到底有谁来做是不是?就像 死啦死啦(《我的团长我的团》的团长)说“我们遇到一只兔子,应该吃掉”,他没有说应该被谁吃掉——这会很麻烦。
现在我们来指定,遇到php扩展名的文件到底应该由谁来处理:
Action application/x-httpd-php “/php/php-cgi.exe”
看到了吧?我们直接.php类型的扩展名文件交给我php/目录下的php-cgi.exe文件来处理了,你可能会问是哪个php目录,看到了我们第一个设置没有:
ScriptAlias /php/ “D:/php/”
这个就是目录映射文件,Apache会知道/php/目录就是指D:/php/,Apache很聪明是不是?呵呵呵……
设置索引文件名称,就是默认的首页文件,搜索DirectoryIndex,并做如下设置:
DirectoryIndex index.html index.html.var index.php
重新启动Apache,控制面板->服务->找到Apache,重新启动
到此为止,你的Web服务器基本完成了,Apache也能运行.php程序了,咱们来看看吧。编写第一个PHP文件phpinfo.php,内容是:
phpinfo();
?>
放到apache目录的htdocs文件夹下,输入http://localhost/phpinfo.php执行他,你就会看到一个页面,这个页面包含了所有的PHP设置信息,包括所使用的php.ini的位置等。
还有一个问题,就是PHP如何连接到Mysql的问题,我们也在这里解决了吧。
找到PHP的设置文件D:/apache/php.ini,这个刚才说了在apache的安装目录下,打开搜索extension_dir,设置为
extension_dir = “D:/php/ext/” 扩展文件的存储路径,
搜索extension=php_mysql.dll
去掉前面的“;”,启用Mysql扩展
再次重新启动Apache,重新http://localhost/phpinfo.php 如果还算顺利的话,你会在这个页面上看到Mysql的一个模块,仔细看看吧,一定会有的。
好了到此为止,Apache、Mysql、PHP我们都安装了,也整合了,可以动手编程了!
这个安装过程只是诸多安装方法的一种,一种就够了其实。当然关于PHP和Apache的设置其实还有很多话要说,请关注本站随后推出的php.ini设置全攻略 和 httpd.conf设置全攻略。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools