主流Apache 2 PHP5安装使用介绍_PHP教程

WBOY
Freigeben: 2016-07-15 13:27:42
Original
747 Leute haben es durchsucht

我们大家都知道Apache 2和PHP是创建交互式网站的流行方案,而且成本很低。我们这里就Apache 2 PHP5安装和大家详细的介绍一下小技巧,在PHP 4.3手册的Windows安装小节,没有解释如何让Apache 2 PHP5配合使用,而有关Apache 2 PHP5安装的小节缺失了你需要的大量信息。在网上公布的其他安装指南中,也包含了不少错误,使一些安装人员只好不断试验和犯错。例如,有些人甚至将PHP的 DLL替换成其他PHP版本的DLL。OK,为了节省你的宝贵时间,我们准备了这篇最权威的指南文章,帮你扫除一切烦恼。

使用正确版本的Windows

首先要说一说兼容性:Apache 2不能在Windows 95上运行;在Windows 98上勉强能够运行,但不能作为服务使用。从4.3版本开始,PHP也不再支持Windows 95。所以,你的Windows操作系统必须是Windows NT、2000或者XP。

Apache 2:源码还是二进制?

如果你有Visual C++ 5.0或更高的版本,或者安装了Microsoft Visual Studio,那么虽然可以根据源码来生成Apache,但请绝对不要这样做。在Visual Studio IDE中,Windows下的生成过程非常复杂。即使从命令行编译,也绝对不是一件易事。所以,除非你喜欢创建makefile,否则最好获得一份 Windows Installer二进制发行包,也就是一个.msi文件。等你对Apache有了足够多的认识,知道自己要进行哪些定制操作时,才可考虑亲手生成(编译)Apache。

如果已经安装好并正在运行老版本的Apache,首先要停止它,卸载它,然后才能开始安装新服务器。多个版本的Apache 2不能共存。

双击Apache 2 .msi文件。同意许可协议后,正确设置Network Domain和Server Name(如果不打算将Apache安装到远程计算机,那么设置localhost就可以了),在Administrator‘s Email Address区域输入你的电子邮件地址,保持端口80/服务选项单选钮的选中状态。在下一个对话框中如果选择Typical安装,可以快速地获得一个能实际工作的服务器环境。

Apache 2 PHP5安装提示

建议将默认安装目录从C:Program FilesApache Group变成C:Apache或者符合8.3文件名格式的其他名称。这样一来,以后每次输入Apache安装路径时,都不必为其添加引号。

稍候片刻,安装向导会告诉你Apache 2安装成功。接下来惟一要做的事情就是进行测试,请打开浏览器并访问localhost,这样应该看到默认的Apache 2主页。

然后可以删除主Web服务器目录中的所有示例文件,它们默认位于C:InstallDirectoryApacheApache2htdocs 中。如果有一个现成的主页Index.html,请把它拷贝到这里;另外,也可以马上创建一个空白主页。对于未初始化的HTML,以下代码就可以了:

<ol class="dp-xml">
<li class="alt"><span><strong><font color="#006699"><span class="tag"><span class="tag-name">html</span><span class="tag">></span></span></font></strong><span> </span></span></li>
<li class=""><span> </span></li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">head</span><span class="tag">></span></span></font></strong><span class="attribute"><font color="#ff0000">title</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">default</font></span><span> server page</span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">head</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class=""><span> </span></li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">body</span><span class="tag">></span></span></font></strong><span>Default server page</span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">body</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class=""><span> </span></li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">html</span><span class="tag">></span></font></strong><span> </span>
</li>
</ol>
Nach dem Login kopieren

让Apache 2为PHP做好准备

从现在开始,你需要较多地以人工方式进行安装,不能简单地点击和选择几个选项了事。尽快习惯它吧,这才是Apache的方式。你需要编辑文件来设置不同的配置选项;如果操作不当,你所做的修改就会妨碍Apache的正确加载。如果设置引发错误,那么错误可能被记录到Apache 2错误日志中(默认为C:InstallDirApache2LogsError.log)。但能够像这样进行记录的毕竟是少数,大多数错误只会记录到Windows事件日志中(开始| 设置| 控制面板| 管理工具| 事件查看器)。

令人遗憾的是,在你对安装设置进行调试时,Windows事件日志并不是一个方便的工具。更好的做法是在命令行窗口中测试Apache服务器的加载,这样能立即看到错误报告。所以,在完成了我即将讨论的配置修改后,请打开一个命令行窗口,切换到Apache的binary目录(C:InstallDirApache2bin),在那里启动Apache。Apache配置文件是C:ApacheApache2ConfHttpd.conf,可用任何文本编辑器来编辑。查找 DirectoryIndex,定位到下面这一行:
<ol class="dp-xml"><li class="alt"><span><span>DirectoryIndex index.html index.html.var # index.php </span></span></li></ol>
Nach dem Login kopieren

为了允许Apache处理PHP页,要删除注释字符(#),变成:

<ol class="dp-xml"><li class="alt"><span><span>DirectoryIndex index.html index.html.var index.php </span></span></li></ol>
Nach dem Login kopieren

还要允许在任何目录中使用.htaccess文件,所以请在配置文件中查找AllowOverride,把这个设置从None改成All。保存了所做的改动后,可继续在文本编辑器中打开该文件,因为等会儿安装PHP时,要再次编辑这个文件。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446505.htmlTechArticle我们大家都知道Apache 2和PHP是创建交互式网站的流行方案,而且成本很低。我们这里就Apache 2 PHP5安装和大家详细的介绍一下小技巧,在PHP...
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!