Windows PHP5和Apache的安装与配置_PHP
Apache
一 下载安装程序Apache可以从http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/下载
PHP可以从http://www.php.net下载.
二 安装程序
1、Apache的程序安装相对来说要较为的简单一些,我们从网站下来的是一个Windows下的安装程序,我们可以直接双击运行,这样我们就便利Apache在我们的电脑上安下家来了。
2、我们在这里要注意的就是在下载PHP时一定要下载那个zip包的,而不要下载Installer的.将我们下载下来的PHP包解压到C盘下的根目录下,并将解压出来的文件夹改名为php。
三 配置
1、最好是无论使用何种接口(CGI 或者 SAPI)都确保 php5ts.dll 可用,因此必须将此文件放到 Windows 路径中。最好的位置是 Windows 的 system 目录:
c:\windows\system for Windows 9x/ME
c:\winnt\system32 for Windows NT/2000 或者 c:\winnt40\system32 for Windows NT/2000 服务器版
c:\windows\system32 for Windows XP
2、下一步是设定有效的 PHP 配置文件,php.ini。压缩包中包括两个 ini 文件,php.ini-dist 和 php.ini-recommended。建议使用 php.ini-recommended,因为此文件对默认设置作了性能和安全上的优化。
将选择的 ini 文件拷贝到 PHP 能够找到的目录下并改名为 php.ini。PHP 默认在 Windows 目录下搜索 php.ini:
3 在 Windows 9x/ME/XP 下将选择的 ini 文件拷贝到 %WINDIR%,通常为 c:\windows。
在 Windows NT/2000 下将选择的 ini 文件拷贝到 %WINDIR% 或 %SYSTEMROOT% 下,通常为 c:\winnt 或 c:\winnt40 对应于服务器版本。
4 Apache中PHP的设置
有两种方法使得 PHP 工作在 Windows 下的 Apache。一是使用 CGI 二进制文件,另一是使用 Apache 模块 DLL。无论那种方法,您首先必须停止 Apache 服务器,然后编辑 httpd.conf,以配置 Apache 和 PHP 协同工作。
如果我们要使用CGI二进制文件,那么我们要将如下指令插入到 Apache 的 httpd.conf 配置文件中,以设置 CGI 二进制文件:
PHP 以 CGI 方式安装到 Apache 2.0:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
如果我们想把 PHP 作为 Apache 2.0 的模块,那么就一定要移动 php4ts.dll 到 winnt/system32(Windows NT/2000)或 windows/system32(Windows XP),覆盖原有文件(如果有的话),对于 PHP 5,这个文件是 php5ts.dll。然后我们要插入如下两行到 httpd.conf 中,以使我们的 PHP 作为 Apache 的 PHP-Module 安装:
PHP 以模块方式安装到 Apache 2.0:
; For PHP 4 do something like this:
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
; For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
经过这样的配置以后,我们就安装好了我们的PHP和Apache服务器了。我们可以简单的测试一下:
1、测试Apache:
我们打开浏览器,在地址栏中输入localhost,如果可以出现Apache页面,则说明我们的Apache可以正常工作了。
2、测试PHP设置:
我们可以简单的编写一个PHP页面,我们可以用文本编辑器,输入下面的代码:
<html>
<head>
<title>
hello
</title>
</head>
<body>
<?php echo "hello,php"; ?>
</body>
</html>
然后将这个文件存为hello.php,将其放在Apache的htdocs目录中(我们也可以在http.conf文件中来更改这个目录的),然后在我们的浏览器中输入http://localhost/hello.php,如果能够正确的显示hello,php就说明我们的PHP配置是可以正常工作的。
这样以后我们也可以来设计我们的PHP站点了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

How to avoid the third-party interface returning 403 error in the Node environment. When calling the third-party website interface using Node.js, you sometimes encounter the problem of returning 403 error. �...

Mastering Debian system log monitoring is the key to efficient operation and maintenance. It can help you understand the system's operating conditions in a timely manner, quickly locate faults, and optimize system performance. This article will introduce several commonly used monitoring methods and tools. Monitoring system resources with the sysstat toolkit The sysstat toolkit provides a series of powerful command line tools for collecting, analyzing and reporting various system resource metrics, including CPU load, memory usage, disk I/O, network throughput, etc. The main tools include: sar: a comprehensive system resource statistics tool, covering CPU, memory, disk, network, etc. iostat: disk and CPU statistics. mpstat: Statistics of multi-core CPUs. pidsta

The problem of comparing and synchronizing BeyondCompare files: Case sensitivity failure when using Beyond...

Why can't my code get the data returned by the API? In programming, we often encounter the problem of returning null values when API calls, which is not only confusing...

"DebianStrings" is not a standard term, and its specific meaning is still unclear. This article cannot directly comment on its browser compatibility. However, if "DebianStrings" refers to a web application running on a Debian system, its browser compatibility depends on the technical architecture of the application itself. Most modern web applications are committed to cross-browser compatibility. This relies on following web standards and using well-compatible front-end technologies (such as HTML, CSS, JavaScript) and back-end technologies (such as PHP, Python, Node.js, etc.). To ensure that the application is compatible with multiple browsers, developers often need to conduct cross-browser testing and use responsiveness

Choice of Python Cross-platform desktop application development library Many Python developers want to develop desktop applications that can run on both Windows and Linux systems...

Efficient reading of Windows system logs: Reversely traverse Evtx files When using Python to process Windows system log files (.evtx), direct reading will be from the earliest...
