Home  >  Article  >  Backend Development  >  Installation and configuration methods of Windows Apache2211 and Php529-1

Installation and configuration methods of Windows Apache2211 and Php529-1

WBOY
WBOYOriginal
2016-07-29 08:40:04848browse

Because pharmar uses Mcafee’s anti-virus software, all programs are required to be installed in Program Files, so these files are placed under D:Program Files for easy management. Mcafee is easy to use when writing protection rules.
Installation and configuration of Apache
Open the official apache website http://archive.apache.org/dist/httpd/binaries/win32/ or the mirror website http://apache.mirror.phpchina.com/httpd/binaries/win32/ , download the apache_2.2.11-win32-x86-no_ssl.msi installation file inside. Among them, there are two types of the same version: no_ssl and openssl. Openssl has an additional SSL security authentication mode. Its protocol is HTTPS instead of HTTP. This is the difference between a server with SSL and a general web server. Under normal circumstances, it will be ok if we download the no_ssl version.
After downloading the apache installation file, click Install. After three consecutive times of next, you will enter the server information configuration interface, which requires you to enter the network domain, server domain and website administrator’s email address. Ordinary users can just fill in the format according to the format. . After pressing Next again, an interface for selecting the installation path appears. The default path is relatively long. Pharmar changes the installation path to: "D:Program FilesApache" and continues the installation until it is completed.
After the installation is completed, apache will start automatically. You can test whether apache starts successfully. Enter: http://localhost/ or http://127.0.0.1/ in the browser address bar. If "It works." appears, congratulations, apache has been successfully installed; at the same time, click on the taskbar in the lower right corner of the computer. There is a green apache server running icon.
Apache also has a configuration file: httpd:conf that needs to be configured in order for php to run. The location is: D:Program FilesApacheconf directory. Open httpd:conf:
1), search for "DocumentRoot", this is the directory where the specified homepage is placed. The default is: "D:Program FilesApachehtdocs". You can use the default directory or define one yourself, such as: "D:/PHP". Note: Do not add "/" at the end of the directory.
2)、查找“DirectoryIndex”,这里是默认首页文件名,可以在index.html 的后面加入index.php等。每种类型之间都要留一个空格。
3)、查找

Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all

修改为:

Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all

如果不改这里的话,可能会出现 You don't have permission to access / on this server. 这样的错误提示,尤其在改变了默认主页的路径后。
注意:每次修改httpd:conf文件后,都要重启apache服务器。另外,如果你的win32系统上同时也运行iis服务器,那么就要先停止iis服务器的运行,然后再启动apache,否则apache服务器无法启动。
Php的安装与配置方法
首先从php的官方网站http://www.php.net/downloads.php 下载windows版本的,有两种版本:PHP 5.2.9 zip package和PHP 5.2.9 installer,目前最新版本就是5.3.0,pharmar使用的是5.2.9版本。PHP 5.2.9 installer为自动安装方式,虽然比较自动化,但在很多方面受到限制,因此pharmar不推荐使用这种方式,下面介绍PHP 5.2.9 zip package压缩包方式下的手动安装。
1)、将PHP的压缩包zip解压到一个目录下,推荐:“C:/PHP”,pharmar的是D:\Program Files\Php。
2)、将PHP目录(D:\Program Files\Php)下的 php.ini-dist 文件重命名为 php.ini,PHP的配置文件就是它,修改以下几个地方,修改好后把 php.ini 文件复制到 C:\WINDOWS\ 目录里:
extensi ,指向php文件夹下放置“php_*.dll”文件的路径。PHP4和PHP5的路径在这里有所区别。
doc_root="D:\PHP" ,指向前面apache设置的首页位置;
default_charset="gb2312" ,修改默认字符集,这里,如果前面有分号“;”,去掉这个分号;
register_globals=Off 改为 register_globals=On ,使传递全局变量有效;
extension=php_dba.dll 如果前面有分号,取消分号,以下同;
extension=php_dbase.dll
extension=php_gd2.dll GD库做图,一般用于图形验证码;
extension=php_mysql.dll 用于连接MYSQL数据库;
3)、将PHP目录下的 php5ts.dll 文件拷贝到 C:\WINDOWS\system32 目录。
4)、最后修改 Apache 的 httpd.conf 文件。在该文件的末尾添加如下2行,表示以模块方式安装PHP进入Apache:
LoadModule php5_module D:/Program Files/Php/php5apache2_2.dll
AddType application/x-httpd-php .php
注意:第一行的目录路径要更新为当前版本的apache动态链接库,比如这里我使用的是apache2.2.11版本和php5.2.9,那这个文件必须是php5apache2_2.dll,而不能是php5apache.dll、php5apache2.dll等。第二行为php脚步的后缀。
php4版中,需要添加一行 AddType mod_php4.c,而在php5中,就不需要这样的一行 AddType mod_php5.c了,php5已经集成,否则 apache 启动不了。
以上就完成了apache和php的配置过程了,重启apache。在服务器的默认目录“D:\Program Files\Apache\htdocs”里新建文件index.php,写上如下代码:
phpinfo();
?>
在浏览器地址栏里输入 http://127.0.0.1/ 或 http://localhost/ ,你就会看到php版本信息了。到此为止,php和apache就已经成功的安装了。
这里有个细节:apache的配置文件 httpd.conf 中的目录分割符号是“/”,而 PHP 的配置文件 php.ini 里的目录则要求是反斜线 “ \”,不要搞混了哦。
MYSQL的安装就简单了。到官方网站 http://dev.mysql.com/downloads/mysql/5.0.html,下载windows平台下的 mysql ,选择 Windows ZIP/Setup.EXE (x86) 最新版本是 5.0.77 ,下载即可。直接安装,安装完成后,可以进入配置向导,设置mysql数据库密码。一切OK。
关于mysql的安装与配置见:phpMyAdmin安装配置方法和问题解决
pharmar安装过程中遇到的错误:
在 Windows 下安装 PHP 后 Apache 出现 LoadModule takes two arguments 的错误,这个主要原因就是httpd.conf中的这句:
LoadModule php5_module D:\Program Files\PHP\php5apache2_2.dll
解释程序把Program Files中的空格当成了两个参数的分隔符号,因此语句中不能出现空格。在网上找了半天也没找到解决方法,最后用一级目录符号才解决问题,改成如下:
LoadModule php5_module ../php/php5apache2_2.dll
因为apache安装在D:\Program Files\Apache\目录下,PHP安装在D:\Program Files\php\,因此../就表示D:\Program Files\目录,这个终于搞定了,希望大家在安装与配置过程中多动动脑筋总会有办法的。

The above introduces the installation and configuration methods of Windows Apache2211 and Php529-1, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn