下面文章内容将讲述 Windows2000/XP/2003(不建议在 windows 98 下建立 PHP 环境) 下 PHP 环境的配置,服务器选择 Apache 2.0.54,数据库选择 MySQL 4.1.14 版本。
需要下载几个软件包:
1. PHP 5.1.0RC1
2. Apache 2.0.54
3. MySQL 4.1.14
下载软件包:
1. PHP 5.1.0RC1
PHP 的下载地址为: http://www.php.net/downloads.php ,找到如下图位置,下载方框中的两个软件包。其中 PHP 5.1.0RC1 zip package 就是 PHP5 软件包,而 Collection of PECL modules for PHP 5.1.0RC1 则是 PHP5 的 PECL 扩展模块集合包。
下载完成后放于 C 盘备用。
2. Apache 2.0.54
Apache 官方下载地址为: http://httpd.apache.org/download.cgi ,找到如下图位置,下载 For Windows 的 MSI 安装包,保存于 C 盘备用。
3. MySQL 4.1.14
MySQL 官方下载地址为: http://dev.mysql.com/downloads/mysql/4.1.html ,找到 Windows downloads 部分,下载 Without installer 包并保存于 C 盘,如下图所示:
安装 PHP5:
假设你的系统安装于 C 盘,否则下列目录均须改成相应的盘的目录。
将下载来的 PHP 5.1.0RC1 解压缩到 C:\PHP5\ 目录下。将 PECL 扩展模块集合包里的所有文件解压缩到 C:\PHP5\ext\ 目录下。
复制 C:\PHP5\ 目录下的 php5ts.dll 文件到 C:\windows\(如果是 windows 2000 操作系统,则为 C:\WINNT\ 目录,下同,不再重复说明) 目录下。
复制 C:\PHP5\ 目录下的下列 dll 文件于 C:\windows\system32\ 目录下:
fdftk.dll
fribidi.dll
gds32.dll
libeay32.dll
libintl-1.dll
libmhash.dll
libmysql.dll
libmysqli.dll
ntwdblib.dll
ntwdblib.dll
yaz.dll
其中 libmysql.dll 为 MySQL 4.1 之前版本的扩展支持,libmysqli.dll 为 MySQL 4.1 之后版本的扩展支持。
复制 C:\PHP5\ 目录下的 php.ini-dist 文件到 C:\windows\ 目录下,并改名为 php.ini ,并用记事本打开编辑:
定位到下面两行:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
修改下面一行使它指向 C:\PHP5\ext\ 目录,修改后如下:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP5\ext\"
定位到下面两行:
可以看到下面列出了所有可支持扩展,我们可以去掉前面的分号来使 PHP 支持相应的扩展。我测试了下,支持下列扩展,也可以根据选择是否配置。
extension=php_bz2.dll
extension=php_cpdf.dll
extension=php_curl.dll
extension=php_dba.dll
;extension=php_dbase.dll
extension=php_dbx.dll
;extension=php_exif.dll
extension=php_fdf.dll
extension=php_filepro.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
extension=php_iisfunc.dll
extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_mcrypt.dll
extension=php_mhash.dll
extension=php_mime_magic.dll
extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
;extension=php_oci8.dll
extension=php_openssl.dll
;extension=php_oracle.dll
extension=php_pdf.dll
;extension=php_pgsql.dll
extension=php_shmop.dll
extension=php_snmp.dll
extension=php_sockets.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
;extension=php_w32api.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
;extension=php_yaz.dll
extension=php_zip.dll
保存文件退出并退出。
安装 Apache 2.0.54
准备好下载下来的 apache_2.x.x-win32-x86-no_ssl.msi 。双击后开始安装。一步 Next 下来,同意许可协议后会有填写服务器信息的页面,本地调试,前面两个输入 localhost 即可。如下:
一路 Next 下来,均按照默认路径安装――当然你也可以选择你自己需要的路径。Apache 会自动安装并启动相关服务。并在任务栏右下角运行着一个 Apache 监控器:
如果安装完成后在Apache里没有找到service,还需要在cmd中输入apache -k install;
我们可以从这个监控器来重起、停止、启动 Apache 服务。双击小图标打开控制界面:
接下来对 Apache 的配置文件进行配置,用记事本打开 C:\Program Files\Apache Group\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,定位到下面这行:
DirectoryIndex index.html index.html.var
在其后面添加一个 PHP 默认页,通常是 index.php ,如下:
DirectoryIndex index.html index.html.var index.php
为了使 Apache 识别 PHP 的相关扩展名,搜索并定位到下面这个部分:
AllowOverride None
Options None
Order allow,deny
Allow from all
在后面添加如下两行:
AddType application/x-httpd-php .php .phtml .php3 .php4
AddType application/x-httpd-php-source .phps
指定 php 模块,找到并定位到如下这行:
#LoadModule ssl_module modules/mod_ssl.so
在下面添加一行:
LoadModule php5_module c:\php5\php5apache2.dll
使它指向 PHP5 目录下的 php5apache2.dll 文件,路径一定要准确。
另外,如果要禁止目录浏览,查找并定位到下面这几行:
#……
#一些注释
#……
Options Indexes FollowSymLinks
去掉几行注释下面紧跟着的一行的 Indexes 即可,修改后:
#……
#一些注释
#……
Options FollowSymLinks
找到 DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs" 将其改为你的WEB目录(可不改)如我的为 DocumentRoot "D:/website"
OK,保存 httpd.conf 文件后重起 Apache 服务器。
MySQL 4.1.14 的安装
运行setup.exe文件进行安装,完成后会弹出窗口提示你进行实例安装
进入之后的详细配置说明大家可以参考http://dev.mysql.com/tech-resources/articles/4.1/installer.html,这里就不一一说明了。
我们一路点击Next进行安装,如果安装顺利的话,打开“控制面板”,进入后打开“管理工具”,再打开“服务”,可以看到mysql的启动服务信息。
到这里 MySQL 的安装告一段落,非常简单。
如果连接时出现Client does not support authentication protocol错误,请参考本站别一篇文章http://www.smallrain.net/study_show.asp?id=579。
测试 PHP 是否配置成功
打开记事本,输入如下这行代码:
保存为 phpinfo.php 文件,存放于 D:/website(Apache中定义的web目录) 目录下,记得保存的时候选择保存类型为“所有文件”。
好了,打开浏览器,在地址栏中输入: http://localhost/phpinfo.php 并回车,如果一切顺利的话你将看到下面这个页面,到此 PHP5 的配置大功告成:

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。


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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
