Apache
软件下载
进入 官网 ,点击 Download – a number of third party vendors – ApacheHaus ,我选择下载的版本:
Apache 2.4.29 x64 ,文件名为:httpd-2.4.29-o102m-x64-vc14.zip
软件安装
在 conf 目录下找到 httpd.conf ,修改:
Define SRVROOT "C:/Users/SY/Desktop/GIT/Software/Apache/httpd-2.4.29-o102m-x64-vc14/Apache24"
解压到任意目录后,以管理员身份打开 cmd ,进入目录
C:\WINDOWS\system32>cd C:\Users\SY\Desktop\GIT\Software\Apache\httpd-2.4.29-o102m-x64-vc14\Apache24\bin
C:\Users\SY\Desktop\GIT\Software\Apache\httpd-2.4.29-o102m-x64-vc14\Apache24\bin>httpd -k install
安装成功后,关闭命令行。
在当前目录下找到 ApacheMonitor.exe ,双击打开。
点击 Start ,然后在浏览器输入 http://localhost ,正常情况下可以看到 It Works!
配置
此步骤在安装 PHP 后执行,打开 httpd.conf ,对比源文件,修改为以下内容:
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so
LoadModule php7_module "C:/Users/SY/Desktop/GIT/Software/PHP/php-7.1.12-Win32-VC14-x64/php7apache2_4.dll"
PHPIniDir "C:/Users/SY/Desktop/GIT/Software/PHP/php-7.1.12-Win32-VC14-x64/"
AddType application/x-httpd-php .php .html .htm
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/Users/SY/Desktop/GIT/Software/PHP/Apache_Workspace/PHP/HOME"
<Directory "C:/Users/SY/Desktop/GIT/Software/PHP/Apache_Workspace/PHP/HOME">
PHP
软件下载
进入 官网 ,点击 Downloads ,找到标题:VC14 x64 Thread Safe (2017-Nov-23 18:29:12) 下载的文件名:
php-7.1.12-Win32-VC14-x64.zip
软件安装
解压压缩文件,修改 php.ini-development 为 php.ini ,修改 php.ini 为以下内容:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "C:/Users/SY/Desktop/GIT/Software/PHP/php-7.1.12-Win32-VC14-x64/ext"
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_xmlrpc.dll
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Shanghai
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
; http://php.net/session.save-path
;session.save_path = "/tmp"
session.save_path = "C:/Users/SY/Desktop/GIT/Software/PHP/Apache_Workspace/PHP/PHPSessionTmp"
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
upload_tmp_dir ="C:/Users/SY/Desktop/GIT/Software/PHP/Apache_Workspace/PHP/PHPFileUploadTmp"
重启 Apache ,进入 http://localhost ,在目录C:\Users\SY\Desktop\GIT\Software\PHP\Apache_Workspace\PHP\HOME 放置一个文件 index.php ,输入内容:
<?php
phpinfo();
?>
刷新网页,如果能够看到以下画面,说明 Apache 已经关联了 PHP 。
修改内容:
<?php
$connect=mysqli_connect("127.0.0.1","root","10929131");
if (!$connect)
echo "Mysql Connect Error!";
else
echo "MySQL OK!";
mysqli_close($connect);
?>
看到打印:MySQL OK! ,说明连接数据库成功!注意 PHP7 以后使用 mysqli 代替 mysql 。
MySQL
软件下载
进入 官网 ,点击 下载 – Community – MySQL on Windows – MySQL Installer ,选择 Windows (x86, 32-bit), MSI Installer ,下载的文件名:mysql-installer-community-5.7.20.0.msi
软件安装
直接一路 Next...
PHPMyAdmin
软件下载
进入官网 ,点击 download ,下载的文件名为:phpMyAdmin-4.7.5-all-languages.zip
软件安装
将解压后的文件夹重命名为 phpMyAdmin ,放到目录:C:\Users\SY\Desktop\GIT\Software\PHP\Apache_Workspace\PHP\HOME ,在浏览器输入:链接 即可访问。
参考教程
PHP7连接MySql错误”Fatal error: Uncaught Error: Call to undefined function mysql_connect()”

本文详细介绍了如何在Windows环境下搭建Apache Web服务器、安装PHP并配置其与Apache的关联,以及安装MySQL和PHPMyAdmin进行数据库管理。通过本教程,读者可以学会创建一个完整的本地PHP开发环境。
227

被折叠的 条评论
为什么被折叠?



