search
HomeBackend DevelopmentPHP ProblemDetailed explanation of how to build a PHP environment under win7

How to build a PHP environment under win7: first download apache24, php7 and phpStorm; then modify the "httpd.conf" file; then load the php module; finally configure the environment variables of php7 and restart Apache.

Detailed explanation of how to build a PHP environment under win7

Recommended: "PHP Video Tutorial"

The most detailed win7 Manually build a PHP environment: apache2.4.23 php7.0.11

##Resource download (apache24, php7, phpStorm9)

Modify apache24 configuration file

##Install and start ApacheService

Modifyphp7.0.11Configuration file Pre-configuration instructions: The computer needs to have a vc runtime library environment, otherwise it will

prompt that VCRUNTIME140.dll

is missing from the computer (because the version requires VC14 compilation, to avoid installation failure, you can install vc_redist.x86.exe or vc_redist.x64.exe first), if the computer has Compare installed If you have a higher version of .netFramework, you won’t have this problem Address: 64-bit version download address, 32-bit version download address

1. Resource download (apache24 , php7, phpStorm9)

1.1 php download:

http://windows.php. net/download (official website)

http://download.csdn.net/detail/sinat_31719925/9734797 (The version I downloaded)

Downloaded here is php-7.0.11-Win32-VC14-x64 (64-bit

thread-safe version). Note that you must download thread-safety

1.2 Apache HTTP Server (apache24) download: http://www.apachelounge.com/download/ (official website)

http://download.csdn.net/detail/sinat_31719925/9734773 (The version I downloaded)

http://download.csdn.net/detail/sinat_31719925/9734784 (The modified version based on this tutorial )

Downloaded here is httpd-2.4.23-win64-VC14

1.3

Unzip httpd-2.4.23-win64-VC14.zip and php-7.0 respectively .11-Win32-VC14-x64.zip to the specified directory: Here and unzip it to the E drive:

##2.Apache HTTP Serverapache24 )ConfigurationOpen E:\Apache24\conf with an editor (sublime3 is used here) httpd.conf file in the directory

2.1Modify apache Root directory: ServerRoot "E:/Apache24"

2.2

Modify the domain name configuration: ServerName 127.0.0.1:80 (Note: put the # before ServerName Remove the number,)

## 2.3  Modify the root directory of the website (change two lines) and configure DocumentRoot "E:/Apache24/Workspace/www" (Note: The www folder is the root directory of the website and needs to be created by yourself, otherwise an error will be reported. At the same time, as shown in the figure below, line 246 also needs to be modified)

The www folder was created by myself, and the path is:

2.4

Configure the welcome page (home page), DirectoryIndex index.html is changed to DirectoryIndex index.php index.html index.htm

<IfModule dir_module>  
    DirectoryIndex index.php index.html index.htm
</IfModule>

is as follows:


2.5Load php module

Add under #LoadModule xml2enc_module modules/mod_xml2enc.so

#load php module
LOadModule php7_module "E:/Php7/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
#指定php.ini的位置(注意:需要把E:/Php7下的php.ini-development 重命名为 php.ini)
PHPIniDir "E:/Php7"

is as follows:

代码说明:以 module 方式加载 php,指明 php 的配置文件 php.ini 的位置.

   2.6最后一步,检查刚刚配置的有没有错,在dos窗口(“win+r”快捷键输入cmd)里进入到apache安装目录apache24/bin 输入:httpd.exe -t 

如果显示如下图则表示apache配置文件已经修改无误(上面的2.1-2.5的操作没错):

如果错误的话,会提示你第几行出错的。

3.安装和启动Apache:

    3.1.安装服务:进入dos窗口(“win+r”快捷键输入cmd).进入到apache安装目录apache24/bin 输入  httpd.exe -k install

  (注意:httpd.exe -k install -n  是错的httpd.exe -k install 或者 httpd.exe -k install -n 服务名  才是对的,如果按httpd.exe -k install -n

    注册apache2.4服务的话,虽然可以注册,但是后期会因为这个导致无法启动服务,笔者就是因为这个导致无法启动apache,卡在这里两天。。羞涩,,) 

上边图中显示注册apache服务成功,你可以到系统的服务那里看下。

注意:Errors reported here must be corrected before the service can be started.不是错误而是提示你如果这行下边出现错误则解决错误后再启动!

 若想删除服务,可以继续看,否则可以跳过以下:

  成功安装服务后,可以在系统服务中看到Apache2.4,如果想删除此服务,进入到apache安装目录E:\Apache24\bin,

  方法一:可以在dos窗口中输入命令: sc delete 服务名(服务名在服务的属性中看,可以参考)

  

 方法二(推荐):通过删除服务命令: httpd.exe -k uninstall -n Apache2.4(服务名)

    3.2.启动服务:在dos窗口中进入E:\Apache24\bin目录,输入httpd.exe -k start   或者  net start apache2.4

 

 或者到apache安装目录 E:\Apache24\bin下 双击ApacheMonitor.exe,然后点击start,随后就可以在系统服务中看到apache2.4服务被启动了

   启动服务的过程中如果启动失败的话,可以参考博文:解决Apache/PHP无法启动的问题

  一般是80端口占用问题,解决:


# 查找占用80端口的进程pid  
netstat -ano|find ":80"  
  
# 假设该进程pid为2013,查看进程名称:  
tasklist /fi "pid eq 2013"  

# 杀掉该进程命令  
taskkill /f /pid 2013

  3.3在浏览器中输入http://localhost/如果出现以下信息,则表明配置成功(思维焦点博客园:xiezhidong.cnblogs.com):

 我们已经在apache指定了自定义的工作路径,如下所示:

而且,我们已经在路径下放了一个test.php文件,



<title>Test PHP5</title>


    <center>
    <h1 id="This-is-test-information">This is test information</h1>
    </center>
    <hr>
    <?php         phpinfo();    ?>

那么,就可以通过在浏览器url输入:  http://localhost/index.php  来测试apache成功加载php解释器:

 

 

3.php7.0.11配置

  3.1用编辑器打开E:\Php7目录下的php.ini文件,将 ;extension_dir = "ext" 修改为 extension_dir = "E:/Php7/ext"   (注意要把前面的分号去掉)

  3.2打开(也就是把前面的分号去掉)用于连接 数据库(Mysql)的模块


extension=php_mysql.

如下:

 

  3.3.配置php7的环境变量(可以略过

  顺便配置环境变量方便以后的pear安装,不然dos窗口下操作还要先找到安装目录:

① 右击我的电脑-属性-高级-环境变量

②找到 Path 这一项,在最后加入你的 PHP 目录和类库所在的路径,包括前面的“;”(例如:;E:\Php7;E:\Php7\ext

③点击系统变量的“新建”按钮并在“变量名”中输入“PHPRC”,在“变量值”中输入 php.ini 文件所在的目录(例如:E:\Php7) ,这个步骤是为了让windows找到php.ini.

 

 


 

The above is the detailed content of Detailed explanation of how to build a PHP environment under win7. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

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

MantisBT

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.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment