windows下手动搭建Apache+PHP+MySQL

一、下载
http://pan.baidu.com/share/link?shareid=95859&uk=2349308099

二、安装、解压
1. Apache

  主要配置Network Domain、Server Name、Email地址(我依次填的是localhost、localhost、邮箱随意)以及Apache服务的占用端口,默认为80端口,你可以根据需要配置在其他端口,Apache的安装目录你可以使用默认目录或根据需要自行选择安装目录(我安装到 D:\Apache)。

  在完成apache服务的安装后,在游览器中输入http://localhost/,出现It’s work!字样,说明Apache服务安装成功了。

2. PHP

  只要解压php-5.3.4-Win32-VC6-x86.zip并重名为文件夹为php到某个盘即可完成PHP安装(我是将其解压复制到D盘目录下 D:\web_server\php5.3)

3. MySQL

  点击Mysql安装程序自动安装,在此期间你可以根据需要选择Mysql数据库的安装目录(我安装到 D:\web_server\MySQL),MySQL 安装完后会启动向导,你可以先取消,下一部的配置里有说。

三、配置

1. Apache(Apache配置文件httpd.conf在Apache安装目录下的conf文件夹里面)

(1)默认Apache服务器执行WEB主程序的目录为Apache2.2/htdocs,所以当你的WEB主程序目录变更时,我们需要修改相应的Apache配置(我改到D:\web_server\apache2.2\htdocs),即用文本编辑软件打开 httpd.conf 将

找到

<Directory />
	Options FollowSymLinks
	AllowOverride None
	Order deny,allow
	Deny from all
</Directory>

将其注释掉

#<Directory />
#	Options FollowSymLinks
#	AllowOverride None
#	Order deny,allow
#	Deny from all
#</Directory>

找到

<Directory "D:/web_server/apache2.2/htdocs">
	#
	# Possible values for the Options directive are "None", "All",
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
	#
	# Note that "MultiViews" must be named *explicitly* --- "Options All"
	# doesn't give it to you.
	#
	# The Options directive is both complicated and important.  Please see
	# http://httpd.apache.org/docs/2.2/mod/core.html#options
	# for more information.
	#
	Options Indexes FollowSymLinks

	#
	# AllowOverride controls what directives may be placed in .htaccess files.
	# It can be "All", "None", or any combination of the keywords:
	#   Options FileInfo AuthConfig Limit
	#
	AllowOverride None

	#
	# Controls who can get stuff from this server.
	#
	Order allow,deny
	Allow from all

</Directory>

将其注释

#<Directory "D:/web_server/apache2.2/htdocs">
	#
	# Possible values for the Options directive are "None", "All",
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
	#
	# Note that "MultiViews" must be named *explicitly* --- "Options All"
	# doesn't give it to you.
	#
	# The Options directive is both complicated and important.  Please see
	# http://httpd.apache.org/docs/2.2/mod/core.html#options
	# for more information.
	#
#	Options Indexes FollowSymLinks

	#
	# AllowOverride controls what directives may be placed in .htaccess files.
	# It can be "All", "None", or any combination of the keywords:
	#   Options FileInfo AuthConfig Limit
	#
#	AllowOverride None

	#
	# Controls who can get stuff from this server.
	#
#	Order allow,deny
#	Allow from all

#</Directory>

找到

#Include conf/extra/httpd-vhosts.conf

将注释去掉

Include conf/extra/httpd-vhosts.conf

找到

#LoadModule rewrite_module modules/mod_rewrite.so

将注释去掉

#LoadModule rewrite_module modules/mod_rewrite.so

找到

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

回车下一行增加以下内容

LoadModule php5_module "D:/web_server/php5.3/php5apache2_2.dll"
PHPIniDir "D:/web_server/php5.3/"

说明:在PHP目录下可以看到多个php5apache的DLL文件,由于我使用的是Apache2.2.17,所以我们当然需要使用php5apache2_2.dll,接着指定PHP的安装目录以及执行的程序扩展名。

2. PHP(配置文件php.ini在PHP安装目录下)

(1)把php.ini-development改名为php.ini,然后用文本编辑器修改php.ini,接下来的步骤都是在php.ini进行的。

找到

; On windows:

; extension_dir = "ext"

修改为

; On windows:

extension_dir = "D:/php/ext"

表示指定PHP扩展包的具体目录,以便调用相应的DLL文件,这样就不用讲PHP的一些dll和php.ini复制到windows下了。

由于默认PHP并不支持自动连接Mysql,需开启相应的扩展库功能,比如php_mysql.dll等,即将

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll 
; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll

; The MIBS data available in the PHP distribution must be installed. 
; See http://www.php.net/manual/en/snmp.installation.php 
;extension=php_snmp.dll

;extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dll
;extension=php_zip.dll

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

找到

;session.save_path = "/tmp"

修改为

session.save_path = "D:/web_server/php5.3/session"

找到

;upload_tmp_dir =

修改为

upload_tmp_dir = "D:/web_server/php5.3/temp"

找到

;date.timezone =

修改为

date.timezone = "Asia/Shanghai"

3. MySQL
点击开始菜单下Mysql Server5.5菜单中的Mysql Server Instance Config Wizard,完成Mysql的配置向导。

点击 Next》 后出现3个选项:选择Mysql服务器的类型

Developer Machine

Server Machine

Dedicated MySQL Machine

我选第2个“Server Machine”

然后又是3个选项:Mysql数据库用途

Multifunctional Database

Transactional Database Only

Non-Transactional Database Only

我选第1个“Multifunctional Database”

选择Mysql数据库的并发连接数

Decision Support (DSS)/OLAP:最大20个连接并发数

Online Transaction Processing(OLTP):最大500个并发连接数

Manual Setting:自定义

我选自定义,设置为50

选择Mysql服务的端口号,一般默认即可

选择Mysql数据库的字符集(推荐使用UTF8,比较通用,否则容易造成乱码。)

Standard Character Set

Best Support For Multilingualism

Manual Selected Default Character Set / Collation

我选“Manual Selected Default Character Set / Collation”,然后在 Character Set 选择 utf8

设置Mysql为Windows服务

在这里考虑开机速度的问题,我将自动登录Mysql服务取消了,一般你可以选择此选项,如果没有选,你可以使用net start mysql启动Mysql服务(停止就是net stop mysql)。

我的选择是“Install AS Windows Service”和“Include Bin Directory in Windows PATH”勾选,“Launch the MySQL Server automatically”去掉勾选

设置Mysql数据库root用户的密码

执行Mysql服务配置选项

Mysql数据库的配置文件保存在D:\MySQL\my.ini,如果今后有什么变动,你可以修改此文件。

到此,所有配置完成。