Home > Backend Development > PHP7 > body text

Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)

coldplay.xixi
Release: 2023-02-17 20:10:01
forward
3064 people have browsed it

Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)

Recommended (free): PHP7

1. Preparation before installation

1. Remove the previous local environment (php, Apache, mysql). If the IIS service is enabled locally by default, the IIS service needs to be turned off (port occupation), although the Apache service port can be changed. , but it always feels awkward to use port access when accessing.
How to shut down the IIS service: Win R key, enter services.msc to confirm, open the local service list, find the IIS service, right-click and select Properties, stop the service and select manual, as shown below.
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
2. Download the required resources. You can choose the following resources according to whether your system is 32-bit or 64-bit.
①php resource download (the latest version when writing the blog is php7.1.10)
php7 for windows version resource download address: http://windows.php.net/download/
Version Choice: There are 4 versions of php7 for windows, divided into 32-bit and 64-bit, which are divided into non thread safe and thread safe. If the environment you are installing is IIS or nginx, please select non thread safe. If the environment you are installing is Apache, please select thread safe. I installed apache locally and chose thread safe. The reason why you can search the difference between non thread safe and thread safe on Baidu is related to the PHP operating mechanism.
②Apache resource download (the latest version when writing the blog is VC15 Apache2.4.28)
There are two download addresses here, just choose one of them, but you need to download Apache2.4 or above, because Apache2.2 version does not support php7. What I chose here is the VC15 Apache2.4.28 version.
Download address: https://www.apachelounge.com/download/
https://www.apachehaus.com/cgi-bin/download.plx#APACHE24VC09
③mysql download (latest at the time of blogging) Version mysql5.7.20)
When I was writing a blog, after decompressing the 64-bit compressed package of mysql5.7.20 downloaded from the official website, there was no my-default.ini file, so I had to create one myself. You can also choose other versions of mysql
The latest version download address: https://dev.mysql.com/downloads/mysql/
Mysql5.6 download address: https://dev.mysql.com/downloads /mysql/5.6.html#downloads
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
④Since php7 uses the VC14 compilation environment, we also need to download Visual C 2015. This can be tested after the above three installations are completed to see if there are any problems. Install again, because your windows system may have already installed it for you.
Download address: https://www.microsoft.com/en-US/download/details.aspx?id=48145

PS: If you are too lazy to find resources yourself, here is Addresses of resources required for environment construction (the compressed package contains php7.1.10 version compressed package (64-bit, thread safe version), Apache2.4.28 compressed package (64-bit, VC15 version), mysql5.7.20 (64-bit), Visual C 2015 (64-bit), the above resources are all windows versions):
Link: http://pan.baidu.com/s/1eR7N3zk Password: qr4b - Install the required resource package


2. Start the installation

Create a folder to store the contents of your environment that you will build next. The name of the folder I created here is benxiaohai
1. PHP installation
① Create a folder under the benxiaohai folder to store the PHP content, place the downloaded compressed package in the folder, and unzip it. As shown below:
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
② Modify the configuration file
1) Modify the php.ini-development file in the G:\benxiaohai\php7.1.1 directory and change the G:\benxiaohai\php7.1.1 directory Change the name of the php.ini-development file under to php.ini
2) Modify the extension directory

extension_dir = "G:/benxiaohai/php7.1.1/ext"
Copy after login

3) Enable related extensions
Enable related extensions as needed. I only enabled them as follows Extension:

extension=php_gd2.dllextension=php_curl.dllextension=php_mbstring.dllextension=php_openssl.dllextension=php_mysqli.dllextension=php_pdo_mysql.dll
Copy after login

Note: In php7, the php_mysql.dll extension has been removed and replaced by php_mysqli.dll.

2、安装apache
①将压缩文件httpd-2.4.28-Win64-VC15.zip解压到Apache24目录中,如下图
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
②创建apache服务
打开cmd,输入”G:\benxiaohai\Apache24\Apache24\bin\httpd.exe” -k install -n Apache2.4,路径是你自己安装apache的路径。如下图。回车运行后,当出现The ‘Apache2.4’ service is successfully installed时表示安装成功。
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
③安装成功后按win+R,输入services.msc回车,你会在服务列表中找到你的Apache2.4服务
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
④配置apache
需要配置的文件:G:\benxiaohai\Apache24\Apache24\conf\httpd.conf
1)配置apache安装的目录

ServerRoot "G:/benxiaohai/Apache24/Apache24"
Copy after login

2)配置你php项目的安放目录

DocumentRoot "G:/benxiaohai/www"<Directory "G:/benxiaohai/www">
Copy after login
Copy after login

3)加载php模块
在文件最后边添加如下配置

#php7 support
LoadModule php7_module "G:/benxiaohai/php7.1.1/php7apache2_4.dll"AddHandler application/x-httpd-php .php#configure the path to php.ini
PHPIniDir "G:/benxiaohai/php7.1.1"
Copy after login

4)修改域名配置

ServerName localhost:80
Copy after login

或者

ServerName 1270.0.1:80
Copy after login

5)配置欢迎页(首页)

<IfModule dir_module>
    DirectoryIndex index.html index.php index.htm
</IfModule>
Copy after login

⑥启动apache
在apache安装目录下点击ApacheMonitor.exe,启动apache,如下图
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
⑦在上面配置php项目的安放目录下建一个test.php文件并在里边写入如下代码

<?phpphpinfo();
Copy after login

⑧打开浏览器,输入localhost/test.php,看到如下界面,就说明你安装成功了!
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
3、mysql5.7.20数据库安装
在官网下载的mysql5.7.20的64位压缩包中,解压后里边缺少my-default.ini文件,需自己创建
①将下载好的压缩包解压到mysql5.7目录下,如下图
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
②修改my-default.ini文件
复制一份my-default.ini文件 ,并将其改名为my.ini,并添加如下配置

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES basedir = G:/benxiaohai/mysql5.7/mysql-5.7.20-winx64
datadir = G:/benxiaohai/mysql5.7/mysql-5.7.20-winx64/data
character_set_server=utf8 
port = 3306
Copy after login

注:这里的data文件夹本来是不存在的,mysql会自动生成。
③添加环境变量,如下图,将mysql的解压目录添加到环境变量path中,我的是G:\benxiaohai\mysql5.7\mysql-5.7.20-winx64\bin,注意分号问题
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
④安装
1)打开cmd,将路径转换到你安装mysql的路径下,然后服务安装命令,其中mysql是服务名称,my.ini是你上面复制的my-default.ini文件,当出现Service successfully installed.时表示服务安装成功,如下图

mysqld --install mysql --defaults-file=G:\benxiaohai\mysql5.7\mysql-5.7.20-winx64\my.ini
Copy after login

Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
2)执行生成data文件指令(mysql初始化数据表数据,以及你以后创建表的数据目录)

mysqld --initialize
Copy after login

3)执行启动服务指令

net start mysql
Copy after login

Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
4)用编辑器打开G:\benxiaohai\mysql5.7\mysql-5.7.20-winx64\data目录下后缀为.err文件,第一次安装用户名一般为root,密码为空或者随机。
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
5)登陆,输入如下指令,然后会要你输入密码,如果密码为空直接回车键,如果密码不为空,则输入密码后回车键。出现下图这表示登陆成功,mysql5.7在这里也就安装完成了。

mysql -u root -p
Copy after login

Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)


三、在安装过程中遇到的问题

1、启动apache 提示Starting httpd: AH00558
Starting httpd: AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName’ directive globally to suppress this message
apache 启动出现这种错误的解决方法:
将 apache 的配置文件httpd.conf中 ServerName 改成可用域名或如下配置
ServerName localhost:80
2、安装完apache后,在浏览器中访问localhost时,一直出现的是IIS页面,这里需要把你本地的IIS服务关掉(本文开头有关闭该服务说明),并清理浏览器缓存后再访问。
3、在安装完apache和php后访问test.php时,出现403。可以从几个方面考虑,大多还是apache的httpd.conf配置问题
①首先要确保线面这个配置目录是对的

DocumentRoot "G:/benxiaohai/www"<Directory "G:/benxiaohai/www">
Copy after login
Copy after login

②其次是配置中对该目录权限配置,下三个配置与其有关,与之前apache版本的权限配置稍有不同,可以注意下

Options Indexes FollowSymLinks
AllowOverride NoneRequire all granted
Copy after login

4、在安装完mysql之后,启动出现如下弹框。这个可以参考这个地址:http://blog.csdn.net/qq_26525215/article/details/53424152解决该问题。
Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7)
5、另外,在安装apache时要注意80端口是否被占用
6、如果出现提示VCRUNTIME140.dll丢失,可以安装Visual C++ 2015,文中开头有说明。

The above is the detailed content of Introducing the establishment of php7 environment on windows (Apache2.4+MySQL5.7+PHP7). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template