登录后更精彩...O(∩_∩)O...
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Windows下PHP环境的搭建
一、安装Apache 官方下载地址
下载地址:http://www.apachelounge.com/download
下载httpd-2.4.52-win64-VS16.zip,解压后放在目录C:\php下
虽然官方不在提供安装文件,但是他有推荐!!我们点击“Apache Loujge”就能够下载二进制文件了。
这里我们下载64位的 httpd-2.4.29-Win64-VC15.zip 即可。
Be sure !! that you have installed the latest C++ Redistributable Visual Studio 2017 : vc_redist_x64 or vc_redist_x86.
也就是说,我们需要先安装 vc_redist_x64 即可。请自行安装!
2.配置Apache——配置安装路径 以文本文档打开conf目录下的httpd.conf配置文件 该文件是Apache配置文件 修改 ServerRoot "D:/php/Apache24"
修改完毕后,我们就可以运行bin/httpd.exe启动了!
我们通常的做法是将httpd作为win的服务随机启动!
3.配置Apache——配置服务器域名 搜索ServerName,找到下面一行的配置 #ServerName www.example.com:80 去掉开头的注释#
 4.安装Apache 以管理员运行cmd cd D:\php\Apache24\bin httpd.exe -k install
5.启动Apache服务 打开Apache的服务监视工具——“bin\ApacheMonitor.exe” 在Windows右下角状态栏会出现Apache的小图标管理工具,在图标上单击鼠标左键弹出控制菜单打开Apache 
查看win服务列表,就会出现 apache24服务了。
启动服务就能正常访问本机!
6.访问测试 查看php\Apache24\htdocs下的文件名为index.html 修改访问首页配置 C:\php\Apache24\conf\httpd.conf中
通过浏览器访问本机站点127.0.0.1\index.html 或http://localhost/index.html 
“It works!”页面是Apache默认站点下的首页 注:
二、PHP的安装 下载地址:https://windows.php.net/download
1.下载php-8.0.0-Win32-vs16-x64zip解压放在D:\php下
2.创建php.ini配置文件 在PHP安装目录下复制一份php.ini-development文件并命名为php.ini,将此文件作为PHP的配置文件
3.在Apache中引入PHP模块 如何让apache支持php呢,修改httpd.conf文件即可,新增加如下: 在http.conf文件中加入以下配置信息
[XML] 纯文本查看 复制代码 PHPIniDir "C:/php/php-8.0.0-Win32-vs16-x64"
LoadModule php_module "C:/php/php-8.0.0-Win32-vs16-x64/php8apache2_4.dll"
<FilesMatch "\.php$">
setHandler application/x-httpd-php
</FilesMatch>
注意目录路径就行了,重启apache服务,打印phpinfo如下: Apache安装目录/htdocs的目录下新建一个phpinfo.php文件,
 内容为: [PHP] 纯文本查看 复制代码 <?php phpinfo();?> 保存后,在浏览器输入127.0.0.1/phpinfo.php,回车,出现关于PHP的版本信息,如下图:

至此,就搭建好了
=================================
Install
-------
You must first install the Visual C++ Redistributable for Visual Studio 2015-2019 x64.
Download and Install, if you have not done so already, see:
https://www.apachelounge.com/download/
Unzip the Apache24 folder to c:/Apache24 (that is the ServerRoot in the config).
The default folder for your your webpages is DocumentRoot "c:/Apache24/htdocs"
When you unzip to an other location:
change Define SRVROOT "c:/Apache24" in httpd.conf, for example to "E:/Apache24"
Run and test
------------
Open a command prompt window and cd to the c:\Apache24\bin folder.
To Start Apache in the command prompt type:
>httpd.exe
Press Enter. If there are any errors it will tell you.
Warnings will not stop Apache from working, they do need to be addressed none the less.
If there are no errors the cursor will sit and blink on the next line.
You can test your installation by opening up your Browser and typing in the address:
http://localhost
You can shut down Apache by pressing Ctrl+C (It may take a few seconds)
To install as a service. Open command prompt as Administrator and type:
>httpd.exe -k install
You can start/stop the service with the command:
>services.msc
To see all Command line options:
>httpd -h
ApacheMonitor:
Double click ApacheMonitor.exe, or put it in your Startup folder.
Upgrading
---------
- Upgrading from 2.2.x see: httpd.apache.org/docs/2.4/upgrading.html
and see httpd.apache.org/docs/2.4/new_features_2_4.html .
- Updating from 2.3.x
copy all the files over, except your changed .conf files.
When you have questions or want more info, post in the forum at www.apachelounge.com or mail me.
Enjoy,
Steffen
=====================
|