一 :准备阶段
1:php
php-5.5.13下载连接:http://windows.php.net/downloads/releases/php-5.5.13-Win32-VC11-x64.zip
推荐 Thread Safe(线程安全) V11 x64,也就是64bit的。
如今PHP官网上下载PHP安装包都有VC11或VC9的字样,这是什么含义,咱们应该下载哪一种安装包更好呢?
其实PHP官网给出了答案:
VC9 and VC11
More recent versions of PHP are built with VC9 or VC11 (Visual Studio 2008 and 2012 compiler respectively) and include improvements in performance and stability.
The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed.
The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed.
VC9意思就是该版本PHP是用VisualStudio2008编译的,而VC11则是用VisualStudio2012编译的。这意味着
若是你下载的是VC9版本的,就须要先安装VisualC++RedistributableforVisualStudio2008SP1,
若是你下载的是VC11版本的,就须要先安装VisualC++RedistributableforVisualStudio2012.
V11是微软的一个组件,若是不安装的话会提示 msvcr110.dll丢失。
下载连接:http://www.microsoft.com/zh-CN/download/details.aspx?id=30679
请下载64bit的,安装完成后,请重启计算机
2:apache2.4.9,下载连接:http://www.apachelounge.com/download/
一样是推荐 V11,64位的。
3:mysql 5.6,下载连接:php
http://dlsw.baidu.com/sw-search-sp/soft/ea/12585/mysql_installer_community_V5.6.21.1_setup.1418020972.msihtml
二:方法/步骤
1:安装配置Apache2.4.9(httpd-2.4.9-win64-VC11.zip )
解压下载的安装包:httpd-2.4.9-win64-VC11.zip 将其放到本身的安装目录(个人目录D:/program/Apache24)
而后对http.conf(D:/program/Apache24/conf/http.conf)配置文件进行修改-使用记事本打开就行
(1)修改ServerRoot Apache的根路径:
(37行)ServerRoot"c:/Apache24"改为=>ServerRoot "D:/program/Apache24"
(2)修改ServerName你的主机名称:
ServerName www.example.com:80将前面的#去掉,该属性在从命令行启动Apache时须要用到。
ServerName localhost:80
(3)修改DocumentRoot Apache访问的主文件夹目录,就是php、html代码文件的位置。
Apache默认的路径是在htdocs(D:/program/Apache24/htdocs)下面,里面会有个简单的入口文件index.html。
这个路径能够本身进行修改,我这里将其配置在我本身新建的文件夹www(E:/php/www)下。
DocumentRoot "c:/Apache24/htdocs"
<Directory"c:/Apache24/htdocs">
改成=>
DocumentRoot "D:/workspace/phpworkspace"
<Directory "D:/workspace/phpworkspace">
(4)修改入口文件配置:DirectoryIndex通常状况下咱们都是以index.php、index.html、index.htm做为web项目的入口。
Apache默认的入口只有index.html须要添加其余两个的支持,固然这个入口文件的设置能够根据本身的须要增减,
若是要求比较严格的话能够只写一个index.php,这样在项目里面的入口就只能是index.php
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改成=>
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
(5)设定serverscript的目录:
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"改成=> ScriptAlias /cgi-bin/ "D:/program/Apache24/cgi-bin"
(6)<Directory "c:/Apache24/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
改成=>
<Directory "D:/program/Apache24/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
接下来就能够启动Apache了
开始---运行,输入cmd,打开命令提示符。接着进入D:/program/Apache24/bin目录下回车httpd回车,
没有报错的话就能够测试了(保持该命令窗口为打开的状态)。
把Apache24/htdocs目录下的index.html放到D:/workspace/phpworkspace目录下,用浏览器访问会出现“It works”那么就说明apache已经正确安装并启动了。
也能够本身写一个简单的index.html文件也能够打开。
说明:Apache 默认使用80端口,若是80端口被占用,Apache将没法启动,此时能够更改Apache端口,解决此问题。
更改端口:找到Apache安装目录下conf目录下的httpd.conf文件(即e:/Apache24/conf/httpd.conf)。打开它。找到“Listen80”,紧接着Listen的数字就是端口号,咱们改成“Listen 8080”。
修改成其它未使用的端口号也行。. 从新启动Apache,使新的配置生效。能够使用右下角状态栏的“Apache Serive Monitor”启动apache。
也能够点击“开始”>"运行>输入cmd>回车>定位到apache安装目录下到bin目录,而后输入“httpd–k start”。
将Apache加入到window服务启动项里面并设置成开机启动
先关闭httpd的服务(将命令窗口关闭便可)
从新打开一个新的命令窗口进入到D:/program/Apache24/bin目录下:
添加HTTP服务的命令是:httpd.exe -kinstall -n "servicename"
servicename是服务的名称,我添加的是:httpd.exe -k install -n "Apache24"命令成功后会有成功的提示,
此时你能够在window服务启动项中看到Apache24这个服务
此时若是你出现:Installing the Apache2.4 service(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager, perhaps you forgot to log in as Adminstrator?
这个错误时,是由于在安装Apache的时候,下载的是zip格式,不是msi安装版,须要本身注册服务,才能在桌面任务栏里有httpd的图标。
结果在cmd命令行里输入安装服务命令的时候出错,出错上述错误,错误信息提示我没有用管理员身份登陆!
解决方案:将cmd以管理员身份运行,而后再从新输入命令便可,执行成功后,可在系统服务中找到Apache24这个服务。
而后点击启动就能够了,若是不想设置成开机启动的话也能够将启动类型修改成手动。
若是要卸载这个服务的话,先要中止这个服务,而后输入httpd.exe -k uninstall -n "Apache24"卸载这个服务。
固然也能够经过D:/program/Apache24/bin下面的ApacheMonitor.exe来启动Apache这里就很少说了
如此Apache的配置就基本完成了。
2:安装配置php5.5.13(php-5.5.13-Win32-VC11-x64.zip)
(1)、将下载的php-5.5.10-Win32-VC11-x64.zip 解压到安装目录下个人是(D:/program/php-5.5)
(2)、将目录下的php.ini-development文件复制一份并更名为php.ini他是php的配置文件
(3)、为Apache服务添加php支持
打开Apache的配置文件http.conf在最后加上
# php5 support
LoadModule php5_module D:/program/php-5.5/php5apache2_4.dll
AddType application/x-httpd-php .php .html .htm
# configure thepath to php.ini
PHPIniDir "D:/program/php-5.5"
这里我添加在LoadModule下面
添加的时候要保证你的php5apache2_4.dll文件确实存在php5.5的早期版本里面是没有这个文件的,不太高点版本里面已经有了,能够打开php安装目录找下这个文件
PHPIniDir "D:/program/php-5.5"这个就是你的php根目录
(4).重启Apache服务器。
(5).测试。在D:/workspace/phpworkspace 中,新建一个index.php,内容为<?php phpinfo(); ?>保存,访问出现php的信息就说明php已经成功安装。
备注:
Php的一些经常使用配置修改:(D:/program/php-5.5/php.ini)
时区的设置:date.timezone = Asia/Shanghai
错误报告等级:error_reporting = E_ALL这个在开发模式下能够所有打开。mysql
错误处理:不支持mysqlweb
配置PHP5支持MySQLsql
修改PHP配置文件“D:\program\php-5.5\php.ini”apache
1.打开“extension=php_mysql.dll”,windows
2.打开“extension_dir = "D:/program/php-5.5/ext"”(路径为绝对路径)浏览器
从新启动服务,问题解决;安全