Apache PHP MySQL phpMyAdmin

建议安装XAMPP


安装

下面两个先别装,一般开发者装机后会已为依赖项安装到系统了,如果跑不起来再来安装。


配置 Apache

编辑C:\Apache24\conf\httpd.conf文件

添加:
  • PHP 7
LoadModule php7_module "c:\php7\php7apache2_4.dll"

<IfModule php7_module>
    AddHandler application/x-httpd-php .php
    AddType application/x-httpd-php .php .html
    PHPIniDir "c:\php7"
</IfModule>
  • PHP 5
LoadModule php5_module C:/php5/php5apache2_4.dll

<IfModule php5_module>
    DirectoryIndex index.html index.php
    AddHandler application/x-httpd-php .php
    PHPIniDir "C:/php5"
</IfModule>
  • 修改
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName localhost
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8080
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    # AllowOverride None
    AllowOverride All
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# DocumentRoot "c:/Apache24/htdocs"
# <Directory "c:/Apache24/htdocs">
DocumentRoot "c:/www"
<Directory "c:/www">
  • 测试Apache

c:/Apache24/htdocs 中的文件拷贝到 c:/www

$ httpd.exe -k install - $ httpd.exe -k start - 浏览器访问http://localhost:8080/

  • 保证以下路径的正确性:
    • ServerRoot "c:/Apache24"
    • DocumentRoot "c:/Apache24/htdocs"
    • <Directory "c:/Apache24/htdocs">
    • ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"
    • <Directory "c:/Apache24/cgi-bin">

配置 PHP

编辑C:\php5\php.ini文件

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "C:\php5\ext"
doc_root = "C:/www"
;extension=php_mysql.dll
;extension=php_mysqli.dll
extension=php_mysql.dll
extension=php_mysqli.dll

C:\php5 执行 $ php -m 检查是否配置正确


配置 MySQL

C:\mysql5\创建my.ini文件

[client]
port=3306
default-character-set=utf8

[mysqld]
port=3306
character_set_server=utf8
basedir="C:\mysql5"
datadir="C:\mysql5\data"
skip-grant-tables

C:\mysql5\bin 执行 $ mysqld --initialize-insecure --user=root - $ mysqld --install - net start mysql - mysql -u root -p

C:\Apache24\bin\ 执行 $ httpd.exe -k restart


配置 phpMyAdmin

C:\www\phpmyadmin\创建config.inc.php文件

<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'hanya';
$cfg['Servers'][$i]['nopassword'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['ssl'] = false;

/* End of servers configuration */

$cfg['blowfish_secret'] = 'kjLGJ8g;Hj3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V';
$cfg['DefaultLang'] = 'ru';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$cfg['ExecTimeLimit'] = 6000;

?>

配置环境变量

;C:\php5;C:\Apache24;C:\Apache24\bin;C:\mysql5\bin

测试

C:\www\创建info.php文件

<?php
phpinfo();
?>

浏览器访问http://localhost:8080/info.php


备份配置文件

  • C:\Apache24\conf\httpd.conf
  • C:\mysql5\my.ini
  • C:\php5\php.ini
  • C:\www\phpmyadmin\config.inc.php

How to install web server on Windows 10 (Apache 2.4, PHP 7, MySQL 5.7 and phpMyAdmin)

发布了110 篇原创文章 · 获赞 53 · 访问量 37万+

猜你喜欢

转载自blog.csdn.net/xianghongai/article/details/79657498
今日推荐