Table of Contents
1. Apache installation:
http://localhost
3.下载MySQL
4.修改配置文件
Home Backend Development PHP Problem How to set up a php environment under win

How to set up a php environment under win

Dec 13, 2021 am 09:46 AM
php win10

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.

How to set up a php environment under win

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,

The first time I executed the

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

Operation: Enter

services.msc in the start bar , open the system service list: as shown

Of course, I also encountered other problems during this period:

Right-click

Apache2.4 in the above picture -》Properties

#It was found that the path of the executable file was wrong, or the path of the previous integrated environment (of course, this has been modified by me).

This can be modified as follows:

Enter

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

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

According to my judgment, the errors in the red box can be ignored Of course, you can also solve this error:

localhost.localdomain. Set the 'ServerName' directive globally to suppress this message. The solution to this error when starting apache: Change the ServerName in the apache configuration file httpd.conf to an available domain name or configure ServerName as follows: localhost:80

You enter

http://localhost

in the browser, if the following page appears, It means your apache has been installed successfully.

Installation reference link reference link

2.php installation

Download address: https://windows.php.net/ downloads/releases/

然后将下载的文件解压到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"
Copy after login

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

AddType application/x-httpd-php .php
Copy after login

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

以管理员的身份运行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
Copy after login

然后重启MySQL(net stop mysql/net start mysql),此时可以不用密码进行连接,但许多功能受到了限制。先连接MySQL,然后选择user数据库修改root用户的密码。

update user set authentication_string=password("你设置的密码") where user = "root";
Copy after login

断开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!

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,

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

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

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