_php instance of method for win7 system configuration Php+apache+mysql Environment

Source: Internet
Author: User
Tags configuration php file copy win32 create database

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

How to configure the PHP environment in 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.

Then how to configure the Php+apache+mysql, next we look at the specific method, the software version will change so need their own timely, adaptable.

First step:

Php-5.5.10-win32-vc11-x64.zip Download Address: http://windows.php.net/download/

Httpd-2.4.7-win64-vc11.zip Download Address: http://www.apachelounge.com/download/

Mysql-5.6.16-winx64.zip Download Address: http://dev.mysql.com/downloads/mysql/

Step Two:

Installation configuration Apache2.4.7 (Httpd-2.4.7-win64-vc11.zip)

1, Decompression download installation package: Httpd-2.4.7-win64-vc11.zip put it to their own installation directory (my directory D:\phpEnv\Apache24)

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

(1) Modify the root path of ServerRoot Apache:

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

(2) modify servername your host name:

Start Apache prompt starting httpd:ah00558 If this row is not modified

(217 lines) ServerName www.example.com:80 removes the previous #, which is needed when you start Apache from the command line.

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

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

<directory "C:/apache24/htdocs" >

Change to =>

DocumentRoot "D:\phpEnv\www"
<directory "D:\phpEnv\www" >

(4) Modify the Portal file configuration: DirectoryIndex In general, we are index.php, index.html, index.htm as the portal for Web projects. Apache default entrance only index.html need to add two other support, of course, this entry file can be set up according to their own needs, if more stringent requirements can only write a index.php, so the entry inside the project is only index.php

(274 lines) <ifmodule dir_module>

DirectoryIndex index.html
</IfModule>

Change to =>

<IfModuledir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>

(5) Set the Serverscript directory:

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

(6) (380 lines)

<directory "C:/apache24/cgi-bin" >
AllowOverride None
Options None
Require all granted
</Directory>

Change to =>

<directory "D:/phpenv/apache24/cgi-bin" >
AllowOverride None
Options None
Require all granted
</Directory>

3, then you can start Apache

Start---Run, enter cmd, and open the command prompt. Then enter the D:\phpEnv\Apache24\bin directory under the Enter HTTPD carriage return, as shown in the figure.

If there is no error, you can test it (keep the command window open).

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

4. Add Apache to Window service startup and set to boot

Turn off 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" The command succeeds with a successful prompt, and you can see Apache24 This service in the window service startup

Then click to start on it, if you do not want to set up to boot, you can change 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" Uninstall the service.

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

So the Apache configuration is basically done.

Second, installation configuration php5.5.10 (Php-5.5.10-win32-vc11-x64.zip)

1. Unzip the downloaded Php-5.5.10-win32-vc11-x64.zip to the installation directory my is (D:\phpEnv\php)

2, the directory of the Php.ini-development file copy and renamed to PHP.ini he is a PHP configuration file

3. Add PHP support for Apache service

Open the Apache configuration file http.conf at the end Plus

# PHP5 support
LoadModule php5_module "D:/phpenv/php/php5apache2_4.dll" AddHandler application/x-httpd-php
. PHP
addtype application/x-httpd-php. html. htm
# Configure Thepath to php.ini
phpinidir ' d:/phpenv/php '

Here I add under LoadModule

When you add, make sure that your Php5apache2_4.dll file exists in the earlier version of php5.5 there is no such file, 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 to the presence of PHP information to explain that PHP has been successfully installed.

Note:

Some common configuration modifications for PHP: (D:\phpEnv\php\php.ini)

Time zone settings: Date.timezone = Asia/shanghai

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

Third, installation configuration mysql5.6.16 (Mysql-5.6.16-winx64.zip)

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 services on the line, here is not detailed. Here is my profile posted to you for your reference:

 [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 MySQL root directory, DataDir is the MySQL data storage directory. I'm not going to explain anything else.

MySQL is installed without a graphical user interface, you can install a navicat for MySQL, such as software, so it will look more convenient.

To register MySQL as a service: Mysqld.exe--install MySQL

To delete the MySQL service: Mysqld.exe--remove MySQL

2. After installing MySQL, add MySQL support for PHP

Open the 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 the extended support of PHP, The Ext folder has a lot of PHP extensions supported. dll files, which interested students can look at.

(2) then opens the MySQL extension of PHP

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

    Extension=php_mysql.dll
    Extension=php_mysqli.dll

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

Note: There are many extended selections in lines No. 863 through No. 888, what you need to use to remove the front ";" It's OK. Of course, if you want to add additional extension support such as Redis support, PHP itself may not provide the corresponding DLL file, you need to find the appropriate version of the DLL added to the Ext folder, and then add a extension= in the configuration file ...

When you are done, restart Apache

3), start the MySQL service

net start MySQL

The MySQL service is starting.
The MySQL service failed to start.

4), login MySQL server

Mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL connection ID is 1
Server 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 username for MySQL is root and the password defaults to null.

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 test
Database changed

7), view the tables in the database

Mysql> show tables;
Empty Set (0.00 sec)

8), CREATE TABLE TTT

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

9), insert three piece of 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)

After delete query operation result:

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

12), update the 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 updated results:

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 MySQL database root user password

1. Use MySQL Database

mysql> use MySQL
Database changed

2. View all tables in 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 |
+---------------------------+
rows in Set (0.00 sec)

3, delete all the data of the user table in the 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 in *.* 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: Changes to the MySQL user, the need to restart the MySQL server before it can 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 MySQL server

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

If you modify the password after net Startmysql a 1067 error that does not start MySQL, you can resolve it by using the following methods:
Use cmd command: D:\Appserv\mysql\bin\mysqladmin-uroot-p shutdown, then enter the password, and then net start MySQL without this error hint!

Iv. creation and deletion of database

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 the landing

Mysql>exit 
Bye

C:\Documents and settings\administrator>

V. General steps to manipulate database data

1, start the MySQL server

2, log on to the database server

3, the use of a database to operate

4, the operation of the table in the database, can be deleted and modified to check various operations.

5, exit the landing.

The above content 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: info-contact@alibabacloud.com 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.