apache2.4下載和安裝php
下載apache2.4html
https://www.apachelounge.com/download/VC11/mysql
提取解壓目錄Apache24到d:/dev/Apache24sql
修改d:/dev/Apache24/conf/httpd.confapache
ServerRoot "d:/dev/Apache24"windows
DocumentRoot "d:/dev/Apache24/htdocs"
<Directory "d:/dev/Apache24/htdocs">php7
在D:\dev\Apache24\bin啓動cmd,執行app
httpd -k install curl
httpd -k startide
如提示msvcr110.dll丟失,請下載並安裝VC++ 2012運行庫:https://www.microsoft.com/zh-CN/download/details.aspx?id=30679
訪問http://localhost/檢查是否安裝成功
php5.5下載和配置
http://windows.php.net/downloads/releases/archives/ php-5.5.9-Win32-VC11-x64.zip
解壓到D:\dev\php-5.5.9-Win32-VC11-x64
拷貝php.ini-development到php.ini
修改php.ini
設置擴展支持目錄
extension_dir = "D:/dev/php-5.5.9-Win32-VC11-x64/ext"
打開常見擴展
extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
配置環境變量,設置
PHP_HOME D:\dev\php-5.5.9-Win32-VC11-x64
修改PATH,追加%PHP_HOME%
測試是否安裝成功 php -v
如提示msvcr110.dll丟失,請下載並安裝VC++ 2012運行庫:https://www.microsoft.com/zh-CN/download/details.aspx?id=30679
php7.1下載和配置
http://windows.php.net/downloads/releases/archives/ php-7.1.4-Win32-VC14-x64.zip
解壓到D:\dev\php-7.1.4-Win32-VC14-x64.zip
配置和安裝參考php5.5的配置
mysql5.7下載和配置
https://dev.mysql.com/downloads/mysql/ 下載mysql-5.7.18-winx64.zip
解壓到D:/dev/mysql-5.7.18-winx64
在mysql安裝目錄,建立my.ini
[mysqld]
basedir=D:/dev/mysql-5.7.18-winx64
datadir=D:/dev/mysql-5.7.18-winx64/data
初始化mysql
bin\mysqld --defaults-file=D:/dev/mysql-5.7.18-winx64/my.ini --initialize-insecure
如提示msvcr120.dll丟失,請下載並安裝VC++ 2013運行庫: https://www.microsoft.com/zh-cn/download/details.aspx?id=40784
安裝服務並啓動
bin\mysqld -install
net start MySQL
測試mysql是否能夠登錄
bin\mysql -uroot
設置root帳戶的密碼爲123456
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
修改環境變量
MYSQL_HOME D:/dev/mysql-5.7.18-winx64
PATH 追加 %MYSQL_HOME%/bin
php5.5(php7.1)和apache2.4的集成
php5.5和php7.1都支持apahce2.4,集成的方法都是一致的,這裏以php5.5爲例。
支持 PHP 解析
修改apache安裝目錄conf下的httpd.conf,在LoadModule內部, 追加(或更改成)以下配置:
LoadModule php5_module "D:/dev/php-5.5.9-Win32-VC11-x64/php5apache2_4.dll"
PHPIniDir "D:/dev/php-5.5.9-Win32-VC11-x64"
AddType application/x-httpd-php .php
若是是php7,配置應該是:
LoadModule php7_module "D:/dev/php-7.1.5-Win32-VC14-x64/php7apache2_4.dll"
PHPIniDir "D:/dev/php-7.1.5-Win32-VC14-x64"
AddType application/x-httpd-php .php
加入index.php做爲首頁
DirectoryIndex index.html index.php
重啓apache httpd -k restart
在D:\dev\Apache24\htdocs建立phpinfo.php
<?php
phpinfo();
?>
訪問http://localhost/phpinfo.php,測試是否配置成功。
虛擬主機
修改C:\Windows\System32\drivers\etc\hosts
加入127.0.0.1 local.test.com
修改apache安裝目錄conf下的httpd.conf,搜索到"# Virtual hosts」部分,加入(或更改成)以下配置:
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Include conf/extra/httpd-vhosts.conf
修改httpd-vhosts.conf,加入
<VirtualHost *:80>
DocumentRoot C:/dev/svn/test
ServerName local.test.com
#下面三行可選
#ServerAdmin admin@local.test.com
#ErrorLog "logs/local.test.com-error.log"
#CustomLog "logs/local.test.com-access.log" common
</VirtualHost>
建立C:/dev/svn/test目錄,建立phpinfo.php
<?php
phpinfo();
?>
重啓apache httpd -k restart
訪問http://local.test.com/phpinfo