Home Backend Development PHP Problem Detailed explanation of how to build a PHP environment under win7

Detailed explanation of how to build a PHP environment under win7

Aug 27, 2020 am 09:41 AM
php 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>
Copy after login

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"
Copy after login

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
Copy after login

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

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

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


<html>
<head>
<title>Test PHP5</title>
</head>
<body>
    <center>
    <h1>This is test information</h1>
    </center>
    <hr>
    <?php        phpinfo();    ?>
</body>
</html>
Copy after login

那么,就可以通过在浏览器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.
Copy after login

如下:

 

  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 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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles