Home php教程 php手册 Windows下搭建PHP开发环境 && php+apache的搭建 结

Windows下搭建PHP开发环境 && php+apache的搭建 结

Jun 06, 2016 pm 07:59 PM
amp php windows develop build environment

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

第一篇

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时,并没有特殊规定,只要输入的信息符合格式即可。

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

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

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

 

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

  

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

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

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

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

 

  三、整合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,输入内容:

 

<span><?php <span>phpinfo</span>();
?>
Copy after login

 

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

Windows下搭建PHP开发环境   &&   php+apache的搭建 结

Windows下搭建PHP开发环境   &&   php+apache的搭建 结




第二篇

windowsXP下搭建Apahce2.2和php5.3.4开发环境

安装Apache服务器
      ssl.msi
      安装,下一步,在network...、server... 中输入localhost,第三个填写管理员邮箱地址即可,然后出现安装路径界面,选择自己的安装路径,我安装在E:/Apache2.2/目录下,继续next,最终完成!
默认情况下,安装完成,apache自动启动,在浏览器地址栏里出入:http://localhost,如果出现“It works!”,安装成功!
安装(版本:5.3.4)
      php-5.3.4-src.zip
配置PHP
      1、配置php:将PHP目录下的php.ini文件重命名为php.ini,这个就是php的配置文件,然后在php.ini文件里修改下面几个地方:
           a:查找extension_dir="E:/PHP/ext";
           b:查找doc_root="E:/PHP";(这里要跟Apache配置文件httpd.conf中的DocumentRoot一致);
           c:修改字符集,找到default_charset,修改成自己的需要的编码,我这里是default_charset="UTF-8"。
           d:设置register_globals=Off为register_globals=On,使传递全局变量有效。
           e:查找extension,并去掉这些项前面的分号
               extension=php_dba.dll
               extension=php_dbase.dll
               extension=php_gd2.dll     GD库做图,一般用于图形验证码;
               extension=php_mysql.dll   用于连接MYSQL数据库;
       2、将D:/PHP目录下的php5ts.dll 和php5apache2_2.dll文件拷贝到 C:/WINDOWS/system32目录下
配置Apache
      打开E:/Apache2.2/conf目录下的httpd.conf文件
      1、找到DocumentRoot,这里是指定主页放置的目录,默认:E:/Apache2.2/htdocs,可以使用默认,我这里是修改成了DocumentRoot "E:/phpApp"
      2、查找DirectoryIndex,这里是设置默认打开的首页文件名。可以在index.html后面加上index.php等,注意各项之间用空格隔开。
      3、找到,将Deny from all修改为allow from all,可以防止You don't have permission to access / on this server这样的错误提示。尤其是在改变了默认主页的路径后。 
在apache中添加php模块
      打开E:/Apache2.2/conf目录下的httpd.conf文件
      1、找到#LoadModule ssl_module modules/mod_ssl.so,在其后面添加LoadModule php5_module D:/PHP/php5apache2_2.dll 
      2、找到AddType application/x-gzip .gz .tgz,在其后面添加AddType application/x-httpd-php .php
测试
     以上五步基本上完成了apache和php的安装配置工作,重启apache,在E:/phpApp目录下新建文件index.php,写如下代码:
    在浏览器地址栏里输入http://localhost,如果看到页面上输出Hello World!信息,恭喜整个环境搭建成功!!!
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 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)

Unable to access mysql from terminal Unable to access mysql from terminal Apr 08, 2025 pm 04:57 PM

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

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 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 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'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.

See all articles