Win7 System configuration Php+apache+mysql environment method _php Instance

Source: Internet
Author: User
Tags configuration php
b/S architecture is very popular now, because B/s architecture has many advantages, such as: Users only need to have a browser to use, maintenance upgrades are more convenient, cross-platform, and so on. This article is about how the Windows+apache+php+mysql development environment is configured.

How to configure the PHP environment under the Win7 system, php+apache+mysql are essential elements in the configuration process, PHP is responsible for parsing PHP code, Apache is responsible for the server side and MySQL is the data interchange.

So how to configure the Php+apache+mysql, next we look at the specific method, the software version will change so need to timely, improvise.

The first step: Download Address: Download Address: Download Address:

Step Two:

Installation configuration Apache2.4.7 (

1. Unzip the downloaded installation package: put it in its own installation directory (my directory D:\phpEnv\Apache24)

2. Then make modifications to the http.conf (D:\phpEnv\Apache24\conf\http.conf) configuration file-use Notepad to open the line

(1) Modify the root path of the ServerRoot Apache:

(37 lines) ServerRoot "C:/apache24" changed to =>serverroot "D:/phpenv/apache24"

(2) modify servername your host name:

Launch Apache hint starting httpd:ah00558 If this line is not modified

(217 lines) ServerName removes the previous #, which is required when launching Apache from the command line.

(3) Modify DocumentRoot Apache access to the home folder directory, is the location of PHP, HTML code files. Apache default path is under Htdocs (D:\phpEnv\Apache24\htdocs), there will be a simple entry file index.html. This path can be modified on its own, and I will configure it in my own new folder, www (D:\phpEnv\www).

(247 lines) DocumentRoot "C:/apache24/htdocs"

Change to =

DocumentRoot "D:\phpEnv\www"

(4) Modify the Portal file configuration: DirectoryIndex generally we are index.php, index.html, index.htm as the portal for Web projects. Apache Default portal only index.html need to add the other two support, of course, the settings of this portal file can be increased or decreased according to their own needs, if the requirements are more stringent can only write a index.php, so that the entry in the project can only be index.php

(274 lines)

DirectoryIndex index.html

Change to =

DirectoryIndex index.php index.htm index.html

(5) Set the Serverscript directory:

(358 lines) scriptalias/cgi-bin/"c:/apache24/cgi-bin/" to = = scriptalias/cgi-bin/"D:/phpenv/apache24/cgi-bin"

(6) (380 lines)

AllowOverride None
Options None
Require all granted

Change to =

AllowOverride None
Options None
Require all granted

3. You can start Apache next.

Start---Run, enter cmd, and open a command prompt. Then enter the D:\phpEnv\Apache24\bin directory to enter httpd enter.

You can test without an error (Keep the command window open).

Put the index.html in the Apache24\htdocs directory in the D:\phpEnv\www directory, access to the browser will appear "It works" that the Apache has been properly installed and started. You can also write a simple index.html file or open it yourself.

4. Add Apache to the window service startup and set it to boot

Close the HTTPD service first (Close the command window)

Reopen a new command window into the D:\phpEnv\Apache24\bin directory:

The command to add the HTTP service is: Httpd.exe-kinstall-n "ServiceName" ServiceName is the name of the service, I added: Httpd.exe-k install-n "Apache24" After the command succeeds, you will be prompted to see the Apache24 Service in the Window service startup item.

Then click on to start, if you do not want to set up the boot, you can also modify the startup type to Manual.

If you want to uninstall this service, first stop the service and then enter Httpd.exe-k uninstall-n "Apache24" to uninstall the service.

Of course, you can also start Apache by D:\phpEnv\Apache24\bin the ApacheMonitor.exe below, and there's not much to say.

So the Apache configuration is basically done.

Second, installation configuration php5.5.10 (

1, unzip the downloaded to the installation directory my Yes (D:\phpEnv\php)

2. Copy the Php.ini-development file in the directory and rename it to php.ini he is a PHP configuration file

3. Add PHP support for Apache service

Open Apache configuration file http.conf at the end of the add

# php5 supportloadmodule php5_module "D:/phpenv/php/php5apache2_4.dll" AddHandler application/x-httpd-php. PhpAddType application/x-httpd-php. html. htm# Configure Thepath to Php.iniphpinidir "d:/phpenv/php"

Here I add below the LoadModule

Add the time to ensure that your Php5apache2_4.dll file does exist php5.5 earlier version of the file does not have this, but the high-point version is already available, you can open the PHP installation directory to find this file

Phpinidir "d:/phpenv/php" This is your PHP root directory.

4. Restart the Apache server.

5. Test.

Delete other files in www, create a new index.php, the content is <?php phpinfo ();?> Save, access the information that appears in PHP indicates that PHP has been successfully installed.


Some common configuration changes in PHP: (D:\phpEnv\php\php.ini)

Settings for time zone: Date.timezone = Asia/shanghai

Error Reporting level: Error_reporting = E_all This can all be opened in development mode.

Three, installation configuration mysql5.6.16 (

1. Install MySQL

64-bit MySQL temporarily did not find the MSI installation package, so directly extracted to the installation directory, and then configure the relevant environment variables, modify the configuration file, Add window service on the line, here is not detailed. Here put my configuration file for everyone to refer to the following:

[Mysqld]  Loose-default-character-set = UTF8   basedir = d:/program/mysql-5.6  datadir = D:/program/mysql-5.6/data  Port = 3306  sql_mode=no_engine_substitution,strict_trans_tables   character_set_server = UTF8  [client]    Loose-default-character-set = UTF8

Note: Basedir is the root directory of MySQL and DataDir is the data storage directory for MySQL. I'm not going to explain anything else.

After installing MySQL, there is no graphical user interface, you can install a navicat for MySQL and other software, this will look more convenient.

Registering MySQL as a service: Mysqld.exe--install MySQL

Delete the MySQL service: Mysqld.exe--remove MySQL

2, after the installation of MySQL, add MySQL support for PHP

Open PHP configuration file php.ini (D:\phpEnv\php\php.ini)

(1) (721 lines); Extension_dir = "ext", remove the front ";" and change to Extension_dir = "D:\phpEnv\php\ext" to open PHP extension support, Ext folder has a lot of PHP extension support. dll files, interested students can look.

(2) then the MySQL extension that opens PHP

(875, 876 lines) remove the front ";"

    Extension=php_mysql.dll    Extension=php_mysqli.dll

Of course you can also open 881 rows of Php_pdo_mysql.dll enable PHP PDO support I usually use this.

Note: There are many expansion options in lines No. 863 through No. 888, what you need to use, and remove the previous ";" You can do it. Of course if you want to add additional extension support such as Redis support, PHP itself may not provide the corresponding DLL files, you need to find the appropriate version of the DLL to add to the Ext folder, and then add a extension= in the configuration file ...

When you are finished, restart Apache

3), start the MySQL service

net start MySQL

The MySQL service is starting.
The MySQL service could not be started.

4), log in to MySQL server

Mysql-uroot-penter Password:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.1.32-community mysql community Edition (GPL) Type ' help; ' or ' \h ' for Help. Type ' \c ' to clear the buffer.mysql>

Note: The administrator user name for MySQL is root and the password is empty by default.

5), view the database

Mysql> Show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Test |+--------------------+3 rows in Set (0.02 sec)

You can see that there are three databases in the MySQL server.

6), using the database

mysql> Use testdatabase changed

7), view the tables in the database

Mysql> Show tables; Empty Set (0.00 sec)


Mysql> CREATE TABLE TTT (a int,b varchar (20)); Query OK, 0 rows Affected (0.00 sec)

9), insert three data

mysql> INSERT into TTT values (1, ' AAA '); Query OK, 1 row affected (0.02 sec) mysql> insert into TTT values (2, ' BBB '); Query OK, 1 row Affected (0.00 sec) mysql> INSERT into TTT values (3, ' CCC '); Query OK, 1 row Affected (0.00 sec)

10), query data

Mysql> SELECT * FROM ttt;+------+------+| A | b |+------+------+| 1 | AAA | | 2 | BBB | | 3 | CCC |+------+------+3 rows in Set (0.00 sec)

11), delete data

Mysql> Delete from TTT where a=3; Query OK, 1 row affected (0.01 sec)

Query operation results after deletion:

Mysql> select * from TTT; +------+------+| A | b |+------+------+| 1 | AAA | | 2 | BBB |+------+------+2 rows in Set (0.00 sec)

12), Update data

mysql> update TTT Set b = ' xxx ' where a = 2; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0

To view the results of the update:

Mysql> select * from TTT; +------+------+| A | b |+------+------+| 1 | AAA | | 2 | XXX |+------+------+2 rows in Set (0.00 sec)

13), Delete table

mysql> drop table TTT; Query OK, 0 rows Affected (0.00 sec)

To view the remaining tables in the database:

Mysql> Show tables; Empty Set (0.00 sec)

Third, change the password of the MySQL database root user

1. Using MySQL Database

mysql> Use mysqldatabase changed

2. View all the tables in the MySQL database

Mysql>show tables; +---------------------------+| Tables_in_mysql |+---------------------------+| Columns_priv | | db | | Func | | Help_category | | Help_keyword | | help_relation | | Help_topic | | Host | | Proc | | Procs_priv | | Tables_priv | | Time_zone | | Time_zone_leap_second | | Time_zone_name | | time_zone_transition | | Time_zone_transition_type | | User |+---------------------------+17 rows in Set (0.00 sec)

3. Delete all data from user tables in MySQL database

mysql> Delete from user; Query OK, 3 Rows Affected (0.00 sec)

4, create a root user, the password is "Xiaohui".

Mysql>grant all on * * to root@ '% ' identified by ' Xiaohui ' with GRANT option; Query OK, 0 rows affected (0.02 sec)

5. View users in the user table

Mysql> Select User from user; +------+| User |+------+| Root |+------+1 row in Set (0.00 sec)

6. Restart MySQL: After you change the MySQL user, you need to restart the MySQL server to take effect.

net stop MySQL

The MySQL service is stopping:
The MySQL service has stopped successfully.

net start MySQL
The MySQL service is starting.
The MySQL service has started successfully.

7. Re-login to MySQL server

Mysql-uroot-pxiaohui Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.1.32-community mysql community Edition (GPL) Type ' help; ' or ' \h ' for Help. Type ' \c ' to clear the buffer.mysql>

If you change the password after the net Startmysql 1067 error that does not start MySQL, you can use the following methods to solve the problem:
Use the cmd command: D:\Appserv\mysql\bin\mysqladmin-uroot-p shutdown, then enter the password, and then net start MySQL will not have this error prompt!

Iv. creation and deletion of databases

1. Create DATABASE TestDB

mysql> CREATE DATABASE TestDB; Query OK, 1 row affected (0.02 sec)

2. Using Database TestDB

mysql> Use testdb;database changed

3. Delete database TestDB

mysql> drop database TestDB; Query OK, 0 rows Affected (0.00 sec)

4. Exit Login

Mysql>exit Byec:\documents and Settings\administrator>

V. General steps for manipulating database data

1. Start the MySQL server

2. Log in to the database server

3. Use a database to manipulate

4, the operation of the database table, executable additions and deletions to check various operations.

5. Exit the landing.

The above describes the win7 system configuration Php+apache+mysql environment method, I hope you like.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.