当前位置:网站首页>A tutorial on how to build a php environment under win
A tutorial on how to build a php environment under win
2022-07-30 12:02:00 【51CTO】
win下搭建php环境的方法
- 下载apache并配置;
- 2、下载PHP并将其解压到wamp目录下的php文件夹;
- 3、下载安装mysql;
- 4、Just modify the configuration file.

本文操作环境:Windows7系统,PHP5.6版,Dell G3电脑.
window10下搭建php的运行环境
It has been used in development beforephp集成环境(eg:phpstudy,xampp等),Haven't tried to use itphp+mysql+apacheBuild it locallyPHP运行环境,So today I suddenly wanted to try to build it,See what troubles will come along the way.The first thing we need is the build tools:
- windows操作系统(我的电脑是win10)
- apache
- MySQL
- php
首先我安装的是apache,
1.Apache的安装:
apache的下载地址http://www.apachelounge.com/download/,Download according to your computer configuration

Download it according to your computer configuration32位的还是64位的.这里我在D盘创建了一个wamp的文件夹,将下载好的apacheUnzip in this directory.Next run as administratorcmd,Then enter step by stepd:\wamp\Apache\bin目录,在该目录下执行httpd -k install 命令,

I execute it for the first timehttpd -k install The installation command encountered the problem above,that should behttpd.confThe default path in the configuration file is wrong,You can manually rewrite it to your actual path.
I also encountered it in the processapachecannot be installed,I checked later that it was installed beforeapache已经被设置为系统服务,删除即可.
删除操作如下(Note also operate as an administrator):

操作:Type in the start launch barservices.msc,Open the list of system services:如图

Of course, I also encountered other problems during the period:
Right click on the image aboveApache2.4-》属性

The path to the executable was found to be wrong,Or the path of the previous integrated environment(Of course, here is what I have modified).
It is modifiable here,方式如下:
Start typing in the search bar to start"regedit"打开注册表在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ Find the desired service underApache2.4,将其 "ImagePath"Just change the key value to the actual path.Of course the introduction here is just for youapache启动不了的情况,如果你执行了

这条命令,You don't have to do the above.当你执行完httpd -k install,When the following appears,说明你本地的apache已经安装成功了

Errors in red boxes are, in my judgment, ignorable,
Of course, you can also solve this kind of error:
localhost.localdomain. Set the 'ServerName' directive globally to suppress this message apache Start the workaround for this error: 将 apache 的配置文件httpd.conf中的 ServerName Change it to an available domain name or configure it as follows ServerName localhost:80
你在浏览器中输入 http://localhost,如果出现以下页面,说明你的apache已经安装成功了.

Install reference link reference link
2.php的安装
下载地址:https://windows.php.net/downloads/releases/

Then extract the downloaded file to wamp目录下的php文件夹(Do not download non-thread safe versions,里面没有phpX(5,7)apache2_4.dll的拓展文件),配置apache的时候要用到.
3.下载MySQL
接下来就是下载MySQL链接地址https://dev.mysql.com/downloads/mysql/,

我是下载的MySQL5.7版本的,Download according to your operating system32bit或者64bit

将下载的文件解压到wamp目录下的mysql文件夹.
4.修改配置文件
打开D:/wamp/apache/conf文件夹下的httpd.conf文件
找到#LoadModule xml2enc_module modules/mod_xml2enc.so这一行,Add something below this line


然后再找到AddType application/x-gzip .gz .tg Add this line below
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
Uncomment this line,并且填写extThe actual path to the folder.
Then just turn it onphp的扩展文件

接下来就是配置MySQL了,Open to enterD:/wamp/mysql目录下新建my.ini配置文件,Paste the content
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=D:\wamp\mysql # 设置mysql数据库的数据的存放目录 datadir=D:\wamp\mysql\data # 允许最大连接数 max_cnotallow=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB |
以管理员的身份运行cmd,进入到D:/wamp/mysql/bin目录下安装MySQL服务,输入mysqld install(注意是mysqld不是mysqlBe sure not to dazzle)
The command line shows the line,表示安装成功
Service successfully installed
接下来输入mysqld --initialize创建data文件夹,否则后面无法启动MySQL服务;
然后输入net start mysql就可以启动MySQL服务了
输入mysql -u root -p,Then enter the password to connectMySQL服务
可能会出现以下错误

Download here nowMySQLNeither version supports passwordless authentication by default,We need to manually set the modification,打开my.ini文件,在文件末尾加上一句:
1 | skip-grant-tables |

然后重启MySQL(net stop mysql/net start mysql),You can now connect without a password,But many functions are limited.先连接MySQL,然后选择user数据库修改root用户的密码.


断开MySQL连接,file will be set upmy.inijust added to the fileskip-grant-tables删除,重启MySQL服务,Log in with the password you set.
边栏推荐
- 分布式限流 redission RRateLimiter 的使用及原理
- 面试官:Redis中的布隆过滤器与布谷鸟过滤器,你了解多少?
- LeetCode_235_Last Common Ancestor of Binary Search Tree
- 自定义查询--关于倒排索引的研究
- 数字量输入输出模块DAM-5088
- TensorFlow custom training function
- 24. 两两交换链表中的节点
- Get the original data API on 1688app
- 基于时延估计的扰动卡尔曼滤波器外力估计
- Static LED display developed by single chip microcomputer
猜你喜欢
随机推荐
ADC0808/9 signal acquisition developed by single chip microcomputer
Introduction to IoT Technologies: Chapter 6
概率论得学习和整理6:概率的分布
External Force Estimation Based on Time Delay Estimation with Perturbed Kalman Filter
基于时延估计的扰动卡尔曼滤波器外力估计
The method of judging the same variable without the if branch
基于MySQL数据库,Redis缓存,MQ消息中间件,ES搜索引擎的高可用方案解析
Flexible distribution parameters of mechanical system modeling and control of research and development
decodeURIComponent()、eval()、encodeURIComponent()
Matlab绘图(1)——二维绘图
概率论得学习整理--番外3:二项式定理和 二项式系数
面试官:Redis中的布隆过滤器与布谷鸟过滤器,你了解多少?
saltstack学习3模块
Matlab基础(1)——基础知识
UE5 GAS 学习笔记 后记0
历时两月,终拿字节跳动offer,算法面试题分享「带答案」
C language - bitwise operations
Reverse linked list - recursive inversion method
【CVA估值训练营】如何快速读懂上市公司年报——第五讲
明德扬FPGA开发板XILINX-K7核心板Kintex7 XC7K325 410T工业级








