How to build a php environment under win: 1. Download apache and configure it; 2. Download PHP and extract it to the php folder in the wamp directory; 3. Download and install mysql; 4. Modify the configuration file That’s it.

The operating environment of this article: Windows 7 system, PHP version 5.6, Dell G3 computer.
Building a PHP operating environment under window10
Before development, I have always used the PHP integrated environment (eg: phpstudy, xampp, etc.), but I have never tried to use PHP mysql Apache independently builds a PHP running environment locally, so I suddenly wanted to try setting it up today to see what troubles I might encounter along the way. First of all, the building tools we need are:
- windows operating system (my computer is win10)
- apache
- MySQL
- php
First of all, I installed apache,
1. Apache installation:
apache download address http://www.apachelounge.com/download/, according to Your computer configuration download

#Determine whether the download is 32-bit or 64-bit based on your computer configuration. Here I created a wamp folder on the D drive and unzipped the downloaded apache in this directory. Next, run cmd as an administrator, then step by step into the d:\wamp\Apache\bin directory, and execute httpd -k install # in this directory. ##Command,

httpd -k install installation command, I encountered the problem shown above, which should be caused by httpd.confThe default path in the configuration file is wrong, you can manually rewrite it to your actual path.
During the process, I also encountered the situation where apache could not be installed. Later, I checked that the previously installed apache had been set as a system service and could be deleted. The deletion operation is as follows (note that it is also performed as an administrator):
services.msc in the start bar , open the system service list: as shown

Apache2.4 in the above picture -》Properties

"regedit" in the startup search barOpen the registry inHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services Find the required service Apache2.4 under \ and change its "ImagePath" key value to the actual path. Of course, the introduction here is only for the situation where your apache cannot be started. If you execute the
sc delete apache2.4command, you do not need to perform the above operations. When you finish executing httpd -k install and the following content appears, it means that your local apache has been successfully installed

http://localhost
in the browser, if the following page appears, It means your apache has been installed successfully.
Installation reference link reference link
然后将下载的文件解压到wamp目录下的php文件夹(不要下载非线程安全的版本,里面没有phpX(5,7)apache2_4.dll的拓展文件),配置apache的时候要用到。
3.下载MySQL
接下来就是下载MySQL链接地址https://dev.mysql.com/downloads/mysql/,

我是下载的MySQL5.7版本的,根据你的操作系统下载32bit或者64bit

将下载的文件解压到wamp目录下的mysql文件夹。
4.修改配置文件
打开D:/wamp/apache/conf文件夹下的httpd.conf文件
找到#LoadModule xml2enc_module modules/mod_xml2enc.so这一行,在这一行下面添加一下内容
PHPIniDir "C:/wamp/php5.6/" LoadModule php5_module "C:/wamp/php5.6/php5apache2_4.dll"

然后再找到 AddType application/x-gzip .gz .tg 这一行再下面添加
AddType application/x-httpd-php .php

apache的配置算是完成了。
然后再打开D:/wamp/php 文件夹下的php.ini-developement文件的文件名改为php.ini,然后对文件进行编辑,

; extension_dir = "./"
; On windows:
extension_dir = "d:/wamp/php5.6/ext"
date.timezone = Asia/Shanghai
取消此行的注释,并且填写ext文件夹的实际路径.
然后就是开启一些php的扩展文件

接下来就是配置MySQL了,打开进入到D:/wamp/mysql目录下新建my.ini配置文件,贴入一下内容
[mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=D:\wamp\mysql # 设置mysql数据库的数据的存放目录 datadir=D:\wamp\mysql\data # 允许最大连接数 max_connections=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB
以管理员的身份运行cmd,进入到D:/wamp/mysql/bin目录下安装MySQL服务,输入mysqld install(注意是mysqld不是mysql一定不要眼花)
命令行显示该行,表示安装成功

接下来输入mysqld --initialize创建data文件夹,否则后面无法启动MySQL服务;
然后输入net start mysql就可以启动MySQL服务了

输入mysql -u root -p,然后输入密码即可连接MySQL服务
可能会出现以下错误

这里现在下载的MySQL版本默认都不支持无密码验证,需要我们手动设置修改,打开my.ini文件,在文件末尾加上一句:
skip-grant-tables

然后重启MySQL(net stop mysql/net start mysql),此时可以不用密码进行连接,但许多功能受到了限制。先连接MySQL,然后选择user数据库修改root用户的密码。
update user set authentication_string=password("你设置的密码") where user = "root";
断开MySQL连接,将设置文件my.ini文件里刚刚加入的skip-grant-tables删除,重启MySQL服务,使用你设置的密码登陆。
推荐学习:《PHP视频教程》
The above is the detailed content of How to set up a php environment under win. For more information, please follow other related articles on the PHP Chinese website!
ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PMThe 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.Mar 26, 2025 pm 04:18 PMThe 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.Mar 26, 2025 pm 04:17 PMArticle 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.Mar 26, 2025 pm 04:16 PMThe 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.Mar 26, 2025 pm 04:15 PMThe 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.Mar 26, 2025 pm 04:13 PMThe 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.Mar 26, 2025 pm 04:12 PMThe 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.Mar 26, 2025 pm 04:11 PMThe 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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools







