Home php教程 php手册 PHP入门:在Windows中安装PHP工作环境

PHP入门:在Windows中安装PHP工作环境

Jun 06, 2016 pm 07:43 PM
php windows getting Started Install Work environment

PHP入门:在Windows系统中分别安装PHP工作环境 一、什么是LAMP? Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应

PHP入门:在Windows系统中分别安装PHP工作环境

一、什么是LAMP?

        Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。

 

二、安装Apache服务器

        web服务器有很多种,主流的有Apache服务器、Lighttpd服务器、Tomcat服务器、IBM WebSphere服务器、Microsoft IIS等,我们今天要安装的就是世界上用得最多的Web服务器,其市场占有率达60%左右的Apache服务器。

2.1、下载地址:http://httpd.apache.org/

2.2、安装方式:http://jingyan.baidu.com/article/0964eca227a0fb8285f536a3.html

 

三、安装MySql数据库

        安装MySql的方法主要有两种,一种是解压版的,另一种是安装版的。两者的区别是解压版的需要手动配置一些参数。如果你云官网下载需要注册Oracle的账户,建议直接百度下载一个就行了。

3.1、解压版MySql安装方法:http://michael-wong.iteye.com/blog/976381

3.2、安装版MySql安装方法:http://wenku.baidu.com/link?url=e56Y84enINF6OjWyUMq1Oq4I_0INv6LZQVEmip1XLukPLKX4qnJHHwRkU8kVR6vd1zZfgjQTwLF3moUQI6M2WusQPGvZQYHzB7BK8ucYzWm

 

四、安装PHP

        这里选择下载php-5.2.6-Win32.zip版,之所以不下载最新版5.5.7,是因为对于这个版本的安装方式网络上没有资料,与前几个版本的安装方式有些区别?所以还是选这个版本,当然你也可以尝试安装最新版,不过对于刚初学的人来说,有必要一味追求新版吗?

4.1、下载地址:http://pan.baidu.com/share/link?shareid=822524062&uk=2318720427

4.2、具体安装:

        4.2.1、把下载的文件解压放到某一个目录,比如C:\lamp\php5.2.5\下面

        4.2.2、把php以模块的方式加载到apache服务器上:

                4.2.2.1、在Apache安装目录的conf下找到httpd.conf文件并打开它,比如我的是C:\lamp\apache\conf\httpd.conf;

                4.2.2.2、在打开的文件中找到这句代码,然后在它的上面插入一行写上:loadModule php5_module "c:/lamp/php5.2.5/php5apache2_2.dll",你需要改的是这里面的路径,如果安装目录是我一样就不需要改了。

 

        4.2.3、那还要干什么呢?那就是告诉服务器php文件的后缀名是什么,只有这样apache服务器才知道要去解析.php为后缀的文件。

                4.2.3.1、还是在httpd.conf文件里面,找到AddType application/x-gzip .gz .tgz这行代码,这里提醒的是如果你找到的这行代码有一个#号,那表示这行被注释掉了,你得没有被注释掉的这行代码,然后在它的下面插入:AddType application/x-httpd-php .php .phtml

        4.2.4、接下来还要指定php配置文件的位置,怎么指定呢?还是在刚才插入代码的下面加上一行:PHPIniDir "c:/lamp/php5.2.5",大小写其实是无所谓的,切记路径要改成你自己的,当然如果路径和我的一样就不用管了。

        4.2.5、是不是感觉要配置的东西很多,不要着急马上就结束了,待会你就能够看到测试页面了。我下载的这个版本是没有php.ini这个文件的,新版本有没有,不得而知,那怎么办呢?简单,我们去php的安装文件找到php-ini-recommerded文件,把这个文件给重命名成php-ini文件就可以了。我这边的地址是:C:\lamp\php5.2.5\php-ini-recommerded。

 http://www.cnblogs.com/roucheng/

4.3、测试一下安装是否成功

现在我们在apache服务器安装目录的htdocs中写一个文本文件(C:\lamp\apache\htdocs\test.txt),在这个文本文件里写上几句代码:


phpinfo();

 

就写两句代码吗?是的你照着写就行了,保存这个文件之后再把其后缀名改成.php即可。

 

4.4、启动apache服务器开始测试程序

       4.4.1、启动方式有两种,一是使用它自带的工具启动,另一种是直接在cmd的命令窗口里输入net start apache2.2回车。

       4.4.2、打开浏览器输入网址:http://localhost/回车就可以看见一句话It works!,那表示你服务正常启动了。接着在地址里输入http://localhost/test.php回车,你会发现出一个非常漂亮的php配置信息页面,那证明你成功了,骚年!


PHP入门:在Windows中安装PHP工作环境
 

        4.4.3、你以为事件到这里就结束了吗?现在我们只是把Apache服务器和php连接到一起了,但是php还是不能访问MySql数据库呀?默认是没有的,我们必须手动去开启。

                4.4.3.1、到php安装目录(我的是C:\lamp\php5.2.5\libmysql.dll)找到libmysql.dll这个文件并把它复制到C:\Windows这个目录下。需要说明的是你如果设置环境变量也可以,方法是你在环境变量里找到path,然后在最后面加入php安装目录的路径上去就可以了。

                 4.4.3.2、那现在php就可以找到mysql了,但我们想要扩展mysql的连接库,方法是在php安装目录下找到php.ini文件并打开它,在文件里找到;extension=php_bz2.dll这行代码,并在它的上面插入一行写上:extension_dir="c:/lamp/php5.2.5/ext",这是个什么意思了,表示我机器上安装的扩展库的位置是这里。具体位置根据你电脑上实际情况处理。

                 4.4.3.3、还是在这个php.ini文件里面找到两行代码extension=php_mysql.dll,extension=php_mysqli.dll,把这两行前面的;号去掉,这就表示打开或开启了这个功能。那怎么才知道是否正确的配置成功了呢?很简单现在马上重启服务器,然后再访问一次http://localhost/test.php,这时你在页面会发现如下图所示的信息

 
PHP入门:在Windows中安装PHP工作环境
 五、安装php优化软件

        是不是感觉配置太多了,没关系,这步你不做也可以,只是安装了这个东西之后,可以让你的php项目性能提升40%,你自己考虑吧!

       5.1、软件名称:ZendOptimizer-3.3.3-Windows-i386.zip

       5.2、下载地址:http://pan.baidu.com/share/link?shareid=3641277684&uk=1277919049&fid=1806952306

       5.3、安装方法:这个版本是下一步下一步安装的,所以就不演示了,如果还不知道就百度吧!打了太久字累了。

说明:PHP5.3开始ZendOptimizer正式改为Zend Guard Loader,(官方地址:http://www.zend.com/en/products/guard/downloads)

 (完)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP's Current Status: A Look at Web Development Trends PHP's Current Status: A Look at Web Development Trends Apr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP: Is It Dying or Simply Adapting? PHP: Is It Dying or Simply Adapting? Apr 11, 2025 am 12:13 AM

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

See all articles