WAMP配置详解 - Windows上的PHP网站。

来源:互联网 发布:云计算需要什么技术 编辑:程序博客网 时间:2024/06/05 16:21

WAMP配置详解(Windows+Apache+MySql+PHP

备注:Windows系列(XP2003)、Apache2.2.17)、MySqlmysql-5.5.8-win32)、PHP5.2.175.3.5

相关资源下载站点:

Apache:http://www.apache.org

MySql:http://www.mysql.com

PHP:http://www.php.net

 

一、        Apache部分

2.2.17 x86默认安装讲解)

安装完了Apache之后,打开../Apache Software Foundation/Apache2.2/conf 目录下的httpd.conf文件,编辑该文件的以下几个字段:

 

1、  Listen 80监听端口 默认80 建议其它值

 

2、  ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"

 

3、  ServerAdmin rayviso@163.com 服务器管理员信箱

 

4、  ServerName www.hmrs.com:80 可以不配置

 

5、  DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" 站点根目录 <注意这里使用的斜杠,不是反斜杠,下同>

 

6、 目录设置

<Directory “C:/”>

Options Indexes FollowSymLinks

AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

 

7、 默认文件名称

保证LoadModule dir_module modules/mod_dir.so开启<保证该模块先加载上>

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>

 

8、  Apache cgi 配置

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">

    AllowOverride None

    Options None

    Order allow,deny

    Allow from all

</Directory>

 

9、  别名 alias name

保证LoadModule alias_module modules/mod_alias.so开启<保证该模块先加载上>

 

10、              错误log

ErrorLog "logs/error.log"

LogLevel warn

 

11、              MIME 模块

LoadModule mime_module modules/mod_mime.so

<IfModule mime_module>

    #

    # TypesConfig points to the file containing the list of mappings from

    # filename extension to MIME-type.

    #

    TypesConfig conf/mime.types

 

    #

    # AddType allows you to add to or override the MIME configuration

    # file specified in TypesConfig for specific file types.

    #

    #AddType application/x-gzip .tgz

    #

    # AddEncoding allows you to have certain browsers uncompress

    # information on the fly. Note: Not all browsers support this.

    #

    #AddEncoding x-compress .Z

    #AddEncoding x-gzip .gz .tgz

    #

    # If the AddEncoding directives above are commented-out, then you

    # probably should define those extensions to indicate media types:

    #

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

 

    #

    # AddHandler allows you to map certain file extensions to "handlers":

    # actions unrelated to filetype. These can be either built into the server

    # or added with the Action directive (see below)

    #

    # To use CGI scripts outside of ScriptAliased directories:

    # (You will also need to add "ExecCGI" to the "Options" directive.)

    #

    #AddHandler cgi-script .cgi

 

    # For type maps (negotiated resources):

    #AddHandler type-map var

 

    #

    # Filters allow you to process content before it is sent to the client.

    #

    # To parse .shtml files for server-side includes (SSI):

    # (You will also need to add "Includes" to the "Options" directive.)

    #

    #AddType text/html .shtml

    #AddOutputFilter INCLUDES .shtml

</IfModule>

 

12、              Apache SSL 加密模块

LoadModule ssl_module modules/mod_ssl.so

<IfModule ssl_module>

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

</IfModule>

 

13、              语言配置

# Language settings

Include conf/extra/httpd-languages.conf

# 这里要区分早期的版本。

# DefaultLanguage nl 配置在httpd-languages.conf

# 并采用如下配置完成语言配置

AddLanguage zh-CN .zh-cn

AddLanguage zh-TW .zh-tw

# 老版本的Apache中使用下列语句

DefaultLanguage zh-cn

 

14、              Apache支持PHP文件解析步骤

Module的形式将PHP5添加到Apache

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

PHPIniDir "C:/Program Files/PHP"

 

添加Apache.PHP文件扩展

老版本中没有<IfModule></IfModule> 模块

<IfModule mime_module>

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php .html

AddType application/x-httpd-php .txt

</IfModule>

 

或者这样写也可以

AddType application/x-httpd-php .php .html .htm .txt

 

二、        MySql部分

1、  MySql安装比较简单,主要是注意一下选择编码格式即可,一路Next即可。

 

2、  MySql的管理工具推荐使用phpAdmin,或者自行寻找。

 

3、  推荐多学习MySql命令行操作。

三、        PHP部分

PHP 5.2.17基本类似)

PHP 5.3.5默认安装讲解)

1、  安装PHP使用Windows MSI安装包,或者使用Zip包解压开也可以,推荐使用线程安全的Zip包解压,手工配置。

 

2、  ZipMSIPHP在原理上是一样的,其配置文件在../ PHP/ 目录下

新版本中配置文件直接叫做php.ini,老版本中叫做php.ini-dist,老版本中需要将php.ini-dist改名为php.ini

 

3、  extension_dir 该文件夹是放置PHP扩展文件的目录,应该在该目录下,目录名称中使用/代替/,例如extension_dir = “c:/web/php/ext”

 

4、  扩展dll文件夹在PHP根目录下,ext,在php.ini中需要对该文件夹中php扩展进行配置,一般来说配置如下,老版本可能会有所不同:

[PHP_MYSQL]

extension=php_mysql.dll

5.2.x版本的dll较多;5.3.x版本的dll较少。

 

5、  register_globals = Off

这个值是用来打开全局变量的,比如表单送过来的值,如果这个值设为“Off”,就只能用“$_POST['变量名']$_GET['变量名 ']”等来取得送过来的值,如果设为“On”,就可以直接使用“$变量名”来获取送过来的值。

简单说Off较为安全、On较为方便。

 

6、  register_long_arrays 该值用来是否可以使用冗长风格的变量

变量声明如下:

简短风格:$tireqty                                         使用register_globals

中等风格:$_POST['tireqty']

冗长风格:$HTTP_POST_VARS['tireqty']

 

7、  track_errors 标记用来标记,用来在全局变量$php_errormsg

 

8、  session.save_path 用来保存session文件在服务器上的保存目录,要求该文件夹有读写权限。

 

9、  uploadtemp 用来保存服务器临时上传的文件,该文件夹也要保证有读写权限,例如uploadtemp=”c:/uploadtemp”

 

10、              date.timezone 用来设置php运行环境的时区,在中国设置为 date.timezone = Asia/Shanghai

 

11、              php文件夹中的php5ts.dlllibmysql.dll拷贝到c:/windows/system32下,否则连接mysql数据库时会报找不到“mysql connect () in”的错误。(5.2.x版本按照上述操作,5.3.x版本中没有libmysql.dll

 

 

 

原创粉丝点击