Home php教程 php手册 Windows下搭建PHP开发环境

Windows下搭建PHP开发环境

Jun 14, 2016 am 12:01 AM
php windows code development environment Open source build programming programming language software development

 

 

  PHP集成开发环境有很多,如XAMPP、AppServ......只要一键安装就把PHP环境给搭建好了。但这种安装方式不够灵活,软件的自由组合不方便,同时也不利于学习。所以我还是喜欢手工搭建PHP开发环境,需要哪个模块自己安装就行了,或者那个软件需要升级,直接升级那个软件就行了,并不影响其他软件,非常方便。

 

  一、准备工作-下载所需软件

  • Apache  httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
  • PHP       php-5.3.10-Win32-VC9-x86.zip
  • MySQL   mysql-5.5.20-win32.msi

 

  二、安装软件

    安装Apache: 双击安装,与安装其他Windows软件没有什么区别,在填Server Infomation时,并没有特殊规定,只要输入的信息符合格式即可。

    安装完成之后,在浏览器输入http://localhost,如果显示It Works!,表示Apache安装成功。

 

    安装PHP:将php-5.3.10-Win32-VC9-x86.zip解压到一个目录即可。

  

    安装MySQL:双击安装,如果需要更改安装目录,则在Choose Setup Type选择Custom

    安装完成后开始配置MySQL,全部保持默认选项即可,但最好把MySQL默认编码改为utf8,在Modify Security Settings选项中设置密码,输入两次密码即可完成,最后点Execute完成配置。

 

  三、整合Apache+PHP+MySQL

    Apache : 首先修改Apache的配置文件,让Apache支持解析PHP文件。Apache配置文件在Apache安装目录的conf目录下的httpd.conf。

 

    1. 让Apache可以解析php文件,在配置文件中找到

        #LoadModule vhost_alias_module modules/mod_vhost_alias.so

      在下一行添加 (绿色的位置是根据PHP的所在目录而定的)

        LoadModule php5_module "D:/Develop/PHP/php5apache2_2.dll"
        PHPIniDir "D:/Develop/PHP"
        AddType application/x-httpd-php .php .html .htm

 

    2. 在配置文件中找到

        DirectoryIndex index.html

      改为

        DirectoryIndex index.php index.html

 

    3. 修改Apache站点目录,在配置文件中找到(Apache安装的目录不同,显示的值不一样)

        DocumentRoot "D:/Develop/Apache2.2/htdocs"

      改为

        DocumentRoot "D:/Workspace/PHP"

      

      再找到

        D:/Develop/Apache2.2/htdocs">

      改为

        D:/Workspace/PHP">  

 

 

 

    PHP : 把php.ini-development改名为php.ini,作为PHP的配置文件。修改php.ini

 

      1. 设置PHP扩展包的具体目录,找到

        ; On windows:
        ; extension_dir = "ext"

      改为 (值是ext文件夹的目录)

        ; On windows:
          extension_dir = "D:/Develop/PHP/ext"

 

      2. 开启相应的库功能,找到需要开启的库的所在行

        ;extension=php_curl.dll

        ;extension=php_gd2.dll

        ;extension=php_mbstring.dll

        ;extension=php_mysql.dll

        ;extension=php_xmlrpc.dll

         去掉前面的分号(注释),即改为

        extension=php_curl.dll

        extension=php_gd2.dll

        extension=php_mbstring.dll

        extension=php_mysql.dll

        extension=php_xmlrpc.dll

      

      3. 设置时区,找到

        ;date.timezone =

        改为

        date.timezone = Asia/Shanghai

       

    配置完成,检测一下配置是否成功。重启Apache,在站点目录下新建文件index.php,输入内容:

 

<?php <br>    <span style="color: #008080;">phpinfo</span>();<br>?>
Copy after login

 

  打开浏览器输入http://localhost,显示如下内容,则安装成功,并且成功关联MySQL。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

How to speed up the loading speed of PS? How to speed up the loading speed of PS? Apr 06, 2025 pm 06:27 PM

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) Apr 08, 2025 am 12:03 AM

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Apr 06, 2025 am 12:07 AM

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.

Explain strict types (declare(strict_types=1);) in PHP. Explain strict types (declare(strict_types=1);) in PHP. Apr 07, 2025 am 12:05 AM

Strict types in PHP are enabled by adding declare(strict_types=1); at the top of the file. 1) It forces type checking of function parameters and return values ​​to prevent implicit type conversion. 2) Using strict types can improve the reliability and predictability of the code, reduce bugs, and improve maintainability and readability.

See all articles