当前位置:网站首页>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.
边栏推荐
- 周鸿祎:微软抄袭了360安全模式 所以成为美国最大的安全公司
- Based on sliding mode control of uncertain neutral system finite time stable
- Matlab绘图(1)——二维绘图
- I built another wheel: GrpcGateway
- 2022-07-29 顾宇佳 学习笔记 异常处理
- 【数据库基础】redis使用总结
- EA中的业务对象和业务实体你分得清吗?
- Redis 主从复制
- 概率论的学习整理--番外1:可重复且无次序的计数公式C(n+k-1,k) 的例题 : 同时丢3个骰子,会有多少种情况?答案不是216而是56!
- 【CVA估值训练营】如何快速读懂上市公司年报——第五讲
猜你喜欢

2022-07-29 Gu Yujia Study Notes Exception Handling

基于MySQL数据库,Redis缓存,MQ消息中间件,ES搜索引擎的高可用方案解析

嵌入式环境下并发控制与线程安全

MySQL——数据库基础

Summary of text alignment, line height, space, etc.

Verilog grammar basics HDL Bits training 08

时间序列曲线相似性

云原生应用的概念和云原生应用的 15 个特征

LeetCode_235_二叉搜索树的最近公共祖先

Concepts of cloud-native applications and 15 characteristics of cloud-native applications
随机推荐
Kubernetes 入门实战03 中级篇
HJY-F931A/YJ three-phase voltage relay
C# 时间戳与时间的互相转换
概率论的学习整理1: 集合和事件
Explain the problem of change exchange in simple terms - the shell of the backpack problem
[ASP.NET Core] Dependency Injection for Option Classes
The package of idea is not hollow
如何用Golang来手撸一个Blog - Milu.blog 开发总结
11 年膨胀 575 倍,微信为何从“小而美”变成了“大而肥”?
Based on sliding mode control of uncertain neutral system finite time stable
Manage reading notes upward
概率论的学习和整理--番外4: 关于各种平均数:算术平均数,几何平均数,调和平均数,以及加权平均数和平方平均数 (未完成)
Reverse linked list - iterative inversion method
重写并自定义依赖的原生的Bean方法
PanGu-Coder: Function-level code generation model
英 文 换 行
牛客-TOP101-BM42
Program environment and preprocessing (detailed)
域名怎么注册备案解析?
RY-D1/1 Voltage Relay