Setting up the Apache PHP Mysql environment on windows

Tool download address:

The php installation package requires the vc11 environment, so the following
Visual C++ Redistributable for Visual Studio 2012 Update 4 is required
https://www.microsoft.com/zh-cn/download/details.aspx?id=30679

One, install apache2.4

1. Decompress apache2.4
Insert picture description here
2. Install apache service
Insert picture description here
Insert picture description here
This is installed by default in the phpWeb directory of disk G. The command is as follows

D:\Apache24\bin\httpd -k install
注意:如果apache目录不在盘符根目录下,需要修改conf下的httpd.conf,修改Define SRVROOT 指定安装目录
例如
Define SRVROOT "G:/phpWeb/Apache24"
ServerRoot "${SRVROOT}"
修改网站路径
        DocumentRoot "D:\www"
        <Directory "D:\www">

3. Test whether the Apache container is installed successfully
win+r enter service.msc to check whether the service is installed successfully
Insert picture description here

Two, install PHP

Here, use PHP as the apache module to install
1, decompress php
Insert picture description here
2, simply configure PHP

#搜索extension_dir 修改为
extension_dir = "D:/php-5.6.38/ext"

#修改php时区搜索date.timezone 修改为
date.timezone =PRC

#设置session存放路径,搜索session.save_path = “/tmp”改为
session.save_path = "D:/tmp"

#打开mysql,mysqli,pdo,gd2,curl,查找去掉前面的; 即可,修改如下
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll

3. Introduce PHP module in Apache

1. Modify httpd.conf in the Apache conf directory and add the following code

LoadModule php5_module "D:/php-5.6.38/php5apache2_4.dll"
<IfModule php5_module> 
    PHPIniDir "D:/php-5.6.38/" 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</IfModule>

2. Modify the index page
Search DirectoryIndex to find the following code

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
修改为

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

3. Handling pseudo-static compatibility with old code of Apache2.2 version

搜索找到以下代码
#LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule access_compat_module modules/mod_access_compat.so
去掉#修改为
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule access_compat_module modules/mod_access_compat.so

搜索找到以下代码
<Directory />
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Require all granted
</Directory>
修改为
<Directory />
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Require all granted
</Directory>

4. Test whether the PHP module is loaded successfully
. Create a new test.php file under the www folder under the Apache installation directory, edit the file and add the following code

<?php
phpinfo();
?>

Restart the Apache server, enter 127.0.0.1/test.php in the address bar and see the relevant PHP configuration, indicating that the configuration is successful.
Insert picture description here

图示为伪静态模块特写

Fourth, install Mysql

1. Unzip the mysql
administrator and run the DOS window. Enter the bin folder of
mysql : create a my.ini file in the folder of mysql-5.6.17 and place it in the bin directory. The content is:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=D:/mysql-5.6.17
# 设置mysql数据库的数据的存放目录
datadir=D:/mysql-5.6.17/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

2. Install mysql service
1. Open the dos window under the mysql-5.6.17 folder, and enter in the dos window:

mysqld –initialize-insecure

Then enter:

mysqld -install
#如果说已经存在,可以使用 sc delete mysql 或者 mysql -remove 将其删除
#成功会显示Service successfully installed.

Start the mysql service:

net start mysql 

2. Set mysql password

mysqladmin -u root password ***

3. Enter mysql and view the table

mysql -u root -p
show databases;

4. Create a database

CREATE DATABASE shop DEFAULT CHARACTER SET utf8

5. Add users and authorize

CREATE USER 'shop'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'shop'@'%' IDENTIFIED BY '123456';
GRANT ALL ON shop.* TO 'shop'@'%';
GRANT ALL ON shop.* TO 'shop'@'localhost';
#删除用户命令:
#DROP USER 'username'@'host';

6. Import the database

mysql -ushop -p
use shop;
source /tmp/test.sql

Supplementary documentation:
The following apache + php supplement is good
https://www.cnblogs.com/52fhy/p/6059685.html

Guess you like

Origin blog.csdn.net/qq_43316775/article/details/111212713