PHP+APACHE开发环境搭建

1.环境

        入门级安装教程,环境搭建

        window32位+httpd-2.4.10-win32-VC11+php-5.6.31-Win32-VC11-x86

2.操作:

        下载对应的安装包,可自行百度。解压到非中文目录,最好不要带符号

php安装

        解压压缩文件后复制php.ini-production,改名为php.ini,用记事本打开(notepad++),

搜索extension_dir = "ext",去掉前面的;改为安装目录的路径,如下所示

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
 extension_dir = "D:/php/ext"

; Directory where the temporary files should be placed.
; Defaults to the system default (see sys_get_temp_dir)
; sys_temp_dir = "/tmp"

接下路搜索如下去前面没有引号的地方,找到后,去掉引号

;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_12c.dll  ; Use with Oracle Database 12c Instant Client

搜索找到data.timezone,改为date.timezone =PRC

这里主要是修改时间。否则php默认的时间与中国时间有时间差

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =PRC

apache安装

直接解压后,进入Apache24\conf\httpd.conf,找到ServerRoot,这里为apache的默认目录,如下

#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "c:/Apache24"

找到后替换,将路径替换为本地apache目录。c:/Apache24全部替换为D:/Apache24

在httpd.conf中添加如下内容支持php

LoadModule php5_module "D:/php/php5apache2_4.dll"
PHPIniDir "D:/php"
AddType application/x-httpd-php .php .html .htm

然后在Apache24\htdocs目录下新建index.php文件,内容如下

<?php
phpinfo();
?>

保存后,退出。

注意:

运行Apache24\bin\httpd.exe,这里我电脑提示msvcp100.dll缺失,需要下载window插件,网址https://www.microsoft.com/en-us/download/details.aspx?id=30679

进行下载

3.启动Apache

 上述完成后打开Apache24\bin\httpd.exe文件,会停留在一个窗口下,别关。访问http://localhost/index.php

访问到php版本信息,配置成功

猜你喜欢

转载自my.oschina.net/u/3429289/blog/1556014