1.下载地址
https://windows.php.net/download
2.安装配置php
安装目录下,复制一份php.ini-development改名为php.ini放到安装路径下
在.ini文件里添加
extension_dir = "c:\php\ext"
c:\php为php安装路径
3.Apache中加载PHP
打开apache安装目录下conf下的httpd.conf
添加
LoadModule php7_module C:/php/php7apache2_4.dll
AddType application/x-httpd-php .php .html
PHPIniDir "c:\php"
在 Apache安装路径\htdocs下新建文件:test.php 里面编辑:
<?php phpinfo(); ?>
apache服务开启 浏览器键入http://localhost/test.php 页面 可以显示apache信息
4.配置mysql
php.ini extension板块中增加一行
extension=php_mysqli.dll
在test.php中编辑:
<?php $mysqli = mysqli_connect("localhost","root","pwd") or die("cannt connet"); ?>
apache服务开启 mysql服务开启 浏览器键入http://localhost/test.php
密码正确应该无任何信息显示。填写错误密码
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\httpd-2.4.34-win64-VC15\Apache24\htdocs\test.php on line 1
can not connet