一、资料
1.windows10专业版64位,
2.apache
http://httpd.apache.org/docs/current/platform/windows.html#down
https://www.apachelounge.com/download/
https://home.apache.org/~steffenal/VC15/binaries/httpd-2.4.41-win64-VC15.zip
3.php
https://www.php.net/downloads.php
https://windows.php.net/downloads/releases/php-7.4.0-Win32-vc15-x64.zip
4.mysql
https://www.mysql.com/cn/
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-winx64.zip
5.Microsoft Visual C++ 2015-2019 Redistributable (x64)
https://www.microsoft.com/zh-cn/
https://www.microsoft.com/zh-cn/download/default.aspx
https://visualstudio.microsoft.com/zh-hans/downloads/?utm_medium=post-banner&utm_source=microsoft.com&utm_campaign=channel+banner&utm_content=launch+vs2019&rr=https%3A%2F%2Fwww.microsoft.com%2Fzh-cn%2Fdownload%2Fdeveloper-tools
https://download.visualstudio.microsoft.com/download/pr/3b070396-b7fb-4eee-aa8b-102a23c3e4f4/40EA2955391C9EAE3E35619C4C24B5AAF3D17AEAA6D09424EE9672AA9372AEED/VC_redist.x64.exe
二、安装
1.分别解压 httpd-2.4.41-win64-VC15.zip、php-7.4.0-Win32-vc15-x64.zip、mysql-8.0.18-winx64.zip
确定安装目录,并将解压后的文件夹复制到安装目录中。本文示例所有软件安装目录均为:c:/amp/
httpd-2.4.41-win64-VC15------httpd-2.4.41-win64-VC15/Apache24 =====Apache24
php-7.4.0-Win32-vc15-x64------整个文件夹全部放入=====php-7.4.0
mysql-8.0.18-winx64--------mysql-8.0.18-winx64/mysql-8.0.18-winx64=====mysql-8.0.18
2.安装VC
3.配置
php配置/
复制文件() C:/amp/php-7.4.0/php.ini-development
命名为 C:/amp/php-7.4.0/php.ini
编辑 php.ini
1.
; On windows:
;extension_dir = "ext"
=====>>>
; On windows:
;extension_dir = "ext"
extension_dir = "c:/amp/php-7.4.0/ext"
此处为php/ext的真实目录位置
2.
;extension=mysqli
====>>>
extension=mysqli
按需开启
apache配置/
编辑文件 c:/amp/Apache24/conf/httpd.conf
1.
Define SRVROOT "c:/Apache24"
修改为真实目录==>>
Define SRVROOT "c:/amp/Apache24"
2.
LoadModule 新增行
LoadModule php7_module c:/amp/php-7.4.0/php7apache2_4.dll
AddType application/x-httpd-php .php
PHPIniDir c:/amp/php-7.4.0
===========
测试
进入c:/amp/Apache24/htdocs
新建index.php
phpinfo();
进入c:/amp/Apache24/bin
运行cmd
执行
c:/amp/Apache24/bin/httpd.exe
浏览器访问
localhost
localhost/index.php
显示如图表示成功,
===========
mysql配置/
进入mysql目录bin目录
C:\amp\mysql-8.0.18\bin
打开命令行执行初始化命令
生成空密码,登陆时直接回车
.\mysqld.exe --initialize-insecure
生成随机密码命令,
.\mysqld.exe --initialize
随机密码位置:C:\amp\mysql-8.0.18\data文件夹中.err结尾的文件,data文件初始化时会产生
安装命令
.\mysqld.exe --install
输出成功信息
Service successfully installed.
启动
net start mysql
连接mysql
.\mysql.exe -u root -p
输入密码
mysql命令,修改root用户密码为111111,密码验证方式为mysql_native_password,默认mysql8.0密码验证方式为caching_sha2_password
mysql> ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '111111';
只修改密码命令
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '111111';
测试,
进入apache目录
C:\amp\Apache24\htdocs
修改index.php内容为
$con = mysqli_connect("localhost","root","111111");
var_dump($con);
刷新页面http://localhost/index.php
如图,输出mysqli对象,即为成功,
补充//
apache服务添加到系统
关闭窗口
进入目录
C:\amp\Apache24\bin
运行cmd命令
.\httpd.exe -k install
或 .\httpd.exe -k install -n xxx xxx为添加到windows的服务名称默认为Apache2.4
双击打开ApacheMonitor.exe
管理已添加的apache服务,ApacheMonitor.exe软件退出,不影响服务运行,
运行状态
//服务停止/启动命令
net stop/start xxx
xxx为服务名称,不区分大小写,apache默认为Apache2.4,mysql默认为msql
mysql 服务卸载命令
PS C:\amp\mysql-8.0.18\bin> .\mysqld.exe -remove
apache服务卸载命令
PS C:\amp\Apache24\bin> .\httpd.exe -k uninstall