How to configure the php-Apache-mysql environment in win7, win7apache configuration _ PHP Tutorial

Source: Internet
Author: User
How to configure the php-Apache-mysql environment and win7apache in Windows 7. How to configure the php-Apache-mysql environment in win7 and how to configure the php environment in win7apache? php + Apache + mysql are all essential elements in the configuration process, php is responsible for configuring the php-Apache-mysql environment and win7apache configuration in win7.

How to configure the php environment in win7? php + Apache + mysql is an essential element in the configuration process. php is responsible for parsing php code, apache is responsible for the server while mysql is the transit station for data interaction.

So how can we configure php + apache + mysql? next, let's take a look at the specific method. the software version will change, so we need to renew it on a regular basis.

Step 1:

Php-5.5.10-Win32-VC11-x64.zip: http://windows.php.net/download/
Httpd-2.4.7-win64-VC11.zip: http://www.apachelounge.com/download/
Mysql-5.6.16-winx64.zip: http://dev.mysql.com/downloads/mysql/

Step 2:

Install apache2.4.7(httpd-2.4.7-win64-vc11.zip)

1. unzip the downloaded installation package: the httpd-2.4.7-win64-VC11.zip will put it in its own installation directory (my Directory D: \ phpEnv \ Apache24)

2. modify the configuration file http. conf (D: \ phpEnv \ Apache24 \ conf \ http. conf)-open it with notepad.

(1)Modify the root path of ServerRoot Apache:

(37 rows) ServerRoot "c:/Apache24" changed to => ServerRoot "D:/phpEnv/Apache24"

(2)Modify ServerName your host name:

If this line is not modified, start apache and prompt Starting httpd: AH00558.

(Row 217) ServerName www.example.com: 80 removes the previous #. This attribute is required when Apache is started from the command line.

(3)Modify the Directory of the main folder accessed by DocumentRoot Apache, that is, the location of php and html code files. The default path of Apache is under htdocs (D: \ phpEnv \ Apache24 \ htdocs.pdf, which contains a simple access file index.html. You can modify the path by yourself. here, I will configure it in my new folder www (D: \ phpEnv \ www.

(Row 3) DocumentRoot "c:/Apache24/htdocs"

Change to =>

DocumentRoot "D: \ phpEnv \ www"

(4)Modify the configuration of the portal File: In general, we use index.php?index.html=index.htm as the portal for web projects. Only index.html needs to be added to the access port of apachetings. of course, the settings of this entry file can be increased or decreased according to your own needs. if the requirements are strict, you can write only one index. php, so the entry in the project can only be index. php

(274 rows)

DirectoryIndex index.html

Change to =>

DirectoryIndex index. php index.htm index.html

(5)Set the serverscript Directory:

(Row 3) ScriptAlias/cgi-bin/"c:/Apache24/cgi-bin/" changed to => ScriptAlias/cgi-bin/"D: /phpEnv/Apache24/cgi-bin"

(6)(380 rows)

AllowOverride None

Options None

Require all granted

Change to =>

AllowOverride None

Options None

Require all granted

3. start Apache.

Start --- run, enter cmd, and open the command prompt. Go to the D: \ phpEnv \ Apache24 \ bin directory and press enter ,.

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

Put index.html in the directory of Apache24 \ htdocs.html under the D: \ phpEnv \ www Directory. "It works" appears when accessed by a browser. This means that apache has been correctly installed and started. You can also open a simple index.html file.

4. Add Apache to the window service startup item and set it to start upon startup.

Close the httpd service first (close the command window)

Open a new command window and go to the D: \ phpEnv \ Apache24 \ bin directory:

The command to add the HTTP service is: httpd.exe-kinstall-n "servicename" servicename is the service name. what I add is: when the httpd.exe-k install-n "Apache24" command is successful, a prompt is displayed. you can view the Apache24 service in the window service startup item.

Click Start. if you do not want to set it to boot, you can change the start type to manual.

If you want to uninstall the service, stop the service first. Then, enter httpd.exe-k uninstall-n "Apache24" to uninstall the service.

Of course, you can also start Apache using apachemonitor.exe under D: \ phpEnv \ Apache24 \ bin.

The Apache configuration is complete.

Install php5.5.10(php-5.5.10-win32-vc11-x64.zip)

1. decompress the downloaded php-5.5.10-win32-vc11-x64.zip file to the installation directory (D: \ phpEnv \ php)

2. copy the php. ini-development file in the directory and change it to php. ini, which is the configuration file of php.

3. add php support for the Apache service

Open the Apache configuration file http. conf and add

# 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 it under LoadModule

Make sure that the php5apache2_4.dll file exists in the php5.5 earlier version, but the file is already available in the later version. you can open the php installation directory to find the file.

PHPIniDir "D:/phpEnv/php". This is your php root directory.


4. restart the Apache server.
5. test. Delete other files in www and create an index. php file. the content is Save. accessing the php information indicates that php has been successfully installed.
Note:
Some common Php configuration changes: (D: \ phpEnv \ php. ini)
Time zone settings: date. timezone = Asia/Shanghai
Error Report level: error_reporting = E_ALL, which can be enabled in development mode.

Install mysql5.6.16(mysql-5.6.16-winx64.zip)

1. install mysql

64-bit mysql does not find the msi installation package. Therefore, extract the package to the installation directory, configure the related environment variables, modify the configuration file, and add the window service, this is not detailed here. Here I will post my configuration file 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 root directory of mysql and datadir is the data storage directory of mysql. I will not explain anything else.

After installing mysql, there is no graphical user interface. you can install software such as Navicat for MySQL, which looks more convenient.

Register mysql as a service: mysqld.exe -- install mysql

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. ini)

(1) (721 rows); extension_dir = "ext", remove the previous ";" and change it to extension_dir = "D: \ phpEnv \ php \ ext "enables php extension support. There are many php extension support in the ext folder. dll file. if you are interested, you can take a look.

(2) then the mysql extension of php is enabled.

(Rows 875 and 876) remove the preceding ";"

Extension = php_mysql.dll

Extension = php_mysqli.dll

Of course, you can also enable php_pdo_mysql.dll in line 1 to enable php's pdo support.

Note: There are a lot of expansion options between lines 863rd and 888th. if you want to use them, just remove the previous. Of course, if you want to add other extension support such as redis support, php may not provide the corresponding dll file, you need to find the corresponding version of dll and add it to the ext folder, then add an extension =... in the configuration file...

Restart Apache

3) start the MySQL service
Net start mysql
MySQL service is starting.
The MySQL service cannot be started.
4) log on to the 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 MySQL administrator username is root, and the password is blank by default.

5) view the database
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
+ -------------------- +
3 rows in set (0.02 sec)

The MySQL server has three databases.

6) use the database
Mysql> use test
Database changed

7) view tables in the database
Mysql> show tables;
Empty set (0.00 sec)

8) create a table ttt
Mysql> create table ttt (a int, B varchar (20 ));
Query OK, 0 rows affected (0.00 sec)

9) insert three data items
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

View the update result:
Mysql> select * from ttt;
+ ------ +
| A | B |
+ ------ +
| 1 | aaa |
| 2 | xxx |
+ ------ +
2 rows in set (0.00 sec)

13) delete a table
Mysql> drop table ttt;
Query OK, 0 rows affected (0.00 sec)

View the remaining tables in the database:
Mysql> show tables;
Empty set (0.00 sec)

3. change the password of the root user of the MySQL database

1. use the mysql database
Mysql> use mysql
Database changed

2. View all 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 user table data in mysql database
Mysql> delete from user;
Query OK, 3 rows affected (0.00 sec)

4. create a root user with the password "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 the MySQL User is changed, the MySQL server needs to be restarted to take effect.
Net stop mysql
MySQL service is stopping ..
The MySQL service has been stopped successfully.

Net start mysql
MySQL service is starting.
The MySQL service has been started successfully.

7. log on to the MySQL server again.
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 the "net startmysql" 1067 error cannot be started after the password is changed, you can use the following solution:
Run the cmd command: D: \ Appserv \ mysql \ bin \ mysqladmin-uroot-p shutdown, enter the password, and then run the net start mysql command!

IV. create and delete databases

1. create a database testdb
Mysql> create database testdb;
Query OK, 1 row affected (0.02 sec)

2. use the database testdb
Mysql> use testdb;
Database changed

3. delete the database testdb
Mysql> drop database testdb;
Query OK, 0 rows affected (0.00 sec)

4. log out
Mysql> exit
Bye

C: \ Documents Ents and Settings \ Administrator>

5. general steps for operating database data


1. start the MySQL server
2. log on to the database server
3. use a database to be operated
4. operate the tables in the database and perform addition, deletion, modification, and query operations.
5. log out.

How to configure the php environment in win7? php + Apache + mysql are all essential elements in the configuration process. php is responsible...

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.