Home >Backend Development >PHP Tutorial >How to configure the php Apache mysql environment in win7 system, win7mysql_PHP tutorial

How to configure the php Apache mysql environment in win7 system, win7mysql_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:44:18765browse

How to configure php Apache mysql environment in win7 system, win7mysql

B/S architecture is very popular now, because B/S architecture has many advantages, for example: users only need to browse It can be used as soon as the server is installed, it is more convenient to maintain and upgrade, it is cross-platform, etc. This article talks about how to configure the development environment of Windows Apache PHP Mysql.

How to configure the php environment under 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 transfer station for data interaction.

So how to configure php apache mysql? Next, let’s take a look at the specific method. The software version will change, so you need to adapt to the times and adapt to changes.

Step one:

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 2:

Install and configure Apache2.4.7(httpd-2.4.7-win64-VC11.zip)

1. Unzip the downloaded installation package: httpd-2.4.7-win64-VC11.zip and put it in your own installation directory (my directory D: phpEnvApache24)

2. Then modify the http.conf (D:phpEnvApache24confhttp.conf) configuration file - just open it with Notepad

(1) Modify the root path of ServerRoot Apache:

(Line 37) Change ServerRoot "c:/Apache24" to =>ServerRoot "D:/phpEnv/Apache24"

(2) Modify ServerName to your host name:

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

(Line 217) ServerName www.example.com:80 Remove the # in front. This attribute is needed when starting Apache from the command line.

(3) Modify the main folder directory accessed by DocumentRoot Apache, which is the location of php and html code files. The default path of Apache is under htdocs (D:phpEnvApache24htdocs), which has a simple entry file index.html. This path can be modified by yourself. I configure it here under my own newly created folder www (D: phpEnvwww).

(Line 247) DocumentRoot "c:/Apache24/htdocs"

  6d25b96ffee33535a37ab3bdaffcfc69

changed to =>

DocumentRoot "D:phpEnvwww"
            ea9c3e706f7b732b82bc314640c3aa5e

(4) Modify the entry file configuration: DirectoryIndex. Generally, we use index.php, index.html, and index.htm as the entry points for web projects. Apache's default entry is only index.html, and you need to add support for the other two. Of course, the settings of this entry file can be increased or decreased according to your own needs. If the requirements are stricter, you can only write one index.php, so that the entry in the project is It can only be index.php

(line 274)794ea01c23a0d5c1a7b2f169e4879de9

DirectoryIndex index.html
                                                                                             

changed to =>

  49f7757408106d5b5a3074712d599179

DirectoryIndex index.php index.htm index.html                                                                                                
(5) Set the serverscript directory:
(Line 358) ScriptAlias/cgi-bin/ "c:/Apache24/cgi-bin/" changed to => ScriptAlias/cgi-bin/ "D:/phpEnv/Apache24/cgi-bin"

(6)(380 lines)

            c85fffe3139ebc7dfc01ee59be1fb0fb ​​​​​AllowOverride None

Options None

Require all granted                                                                                          

changed to =>

                e05d0d9844b0556cb938c9871c14773b
​​​​​AllowOverride None
Options None
Require all granted
                                                                                         

3. Next, you can start Apache

Start---Run, enter cmd, open the command prompt. Then enter the D:phpEnvApache24bin directory and press Enter httpd and press Enter, as shown in the picture.

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

Put the index.html in the Apache24htdocs directory into the D:phpEnvwww directory. If you access it with a browser, "It works" will appear, which means apache has been correctly installed and started. You can also write a simple index.html file yourself and open it.

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

Close the httpd service first (just close the command window)

Reopen a new command window and enter the D:phpEnvApache24bin directory:

The command to add HTTP service is: httpd.exe -kinstall -n "servicename" servicename is the name of the service. What I added is: httpd.exe -k install -n "Apache24" There will be a success prompt after the command is successful. , at this time you can see the Apache24 service in the window service startup item

Then click Start. If you don’t want to set it to start at startup, you can also change the startup type to manual.

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

Of course, you can also start Apache through ApacheMonitor.exe under D:phpEnvApache24bin. I won’t go into details here

In this way, the configuration of Apache is basically completed.

2. Install and configure 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. Mine is (D:phpEnvphp)

2. Copy the php.ini-development file in the directory and rename it to php.ini. It is the configuration file of php

3. Add php support for Apache service

Open Apache’s configuration file http.conf and add

at the end

Here I added it under LoadModule
# 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"

When adding, make sure that your php5apache2_4.dll file does exist. This file is not available in the early version of php5.5, but it is already in the higher version. You can open the php installation directory to find this file

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

4. Restart the Apache server.


5. Test.

Delete other files in www and create a new index.php with the content of e2d0e752df2c971bca1fcef6e50119b4 Save it. When accessing the php information, it means that php has been successfully installed.


Remarks:


Some common configuration modifications for Php: (D:phpEnvphpphp.ini)


Time zone setting: date.timezone = Asia/Shanghai


Error reporting level: error_reporting = E_ALL can be turned on in development mode.

3. Install and configure mysql5.6.16 (mysql-5.6.16-winx64.zip)

1. Install mysql

The 64-bit mysql has not found the msi installation package yet, so it can be directly extracted to the installation directory, then configure the relevant environment variables, modify the configuration file, and add the window service. I will not write it in detail here. Here I 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 won’t explain the rest

After installing mysql, there is no graphical user interface. You can install software such as Navicat for MySQL, which will look 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 to php

Open the php configuration file php.ini (D:phpEnvphpphp.ini)

(1)(721行); extension_dir = "ext",去掉前面的“;”,并改为extension_dir ="D:\phpEnv\php\ext"打开php的扩展支持,ext文件夹下有很多php的扩展支持.dll文件,感兴趣的同学可以看一下。

(2)然后就是打开php的mysql扩展了

    (875、876行)去掉前面的“;”

    extension=php_mysql.dll
    extension=php_mysqli.dll

当然也可以打开881行的php_pdo_mysql.dll启用php的pdo支持我一般都用这个。

注:在第863行到第888行有很多扩展选择,你要用到什么,去掉前面的“;”就可以了。当然如果要添加其他的扩展支持如redis支持,php本身可能没有提供相应的dll文件,就需要自己去找到相应版本的dll添加到ext文件夹中,然后在配置文件中添加一个extension=…

完成之后,重启Apache

3)、启动MySQL服务

net start mysql

MySQL服务正在启动 .
MySQL服务无法启动。

4)、登陆MySQL服务器

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>

注意:MySQL的管理员用户名为root,密码默认为空。

5)、查看数据库

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)

可以看到MySQL服务器中有三个数据库。

6)、使用数据库

mysql> use test
Database changed

7)、查看数据库中的表

mysql> show tables;
Empty set (0.00 sec)

8)、创建表ttt

mysql> create table ttt(a int,b varchar(20)); 
Query OK, 0 rows affected (0.00 sec)

9)、插入三条数据

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)、查询数据

mysql> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
+------+------+
3 rows in set (0.00 sec)

11)、删除数据

mysql> delete from ttt where a=3;
Query OK, 1 row affected (0.01 sec)

删除后查询操作结果:

mysql> select * from ttt; 
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
+------+------+
2 rows in set (0.00 sec)

12)、更新数据

mysql> update ttt set b = 'xxx' where a =2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

查看更新结果:

mysql> select * from ttt; 
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | xxx |
+------+------+
2 rows in set (0.00 sec)

13)、删除表

mysql> drop table ttt; 
Query OK, 0 rows affected (0.00 sec)

查看数据库中剩余的表:

mysql> show tables;
Empty set (0.00 sec)

三、更改MySQL数据库root用户的密码

1、使用mysql数据库

mysql> use mysql
Database changed

2、查看mysql数据库中所有的表

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、删除mysql数据库中用户表的所有数据

mysql> delete from user; 
Query OK, 3 rows affected (0.00 sec)

4、创建一个root用户,密码为"xiaohui"。

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

5、查看user表中的用户

mysql> select User from user; 
+------+
| User |
+------+
| root |
+------+
1 row in set (0.00 sec)

6、重启MySQL:更改了MySQL用户后,需要重启MySQL服务器才可以生效。

net stop mysql

MySQL 服务正在停止..
MySQL 服务已成功停止。

net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

7、重新登陆MySQL服务器

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>

如果修改密码后net startmysql出现不能启动mysql的1067错误,则可以使用以下办法解决:
使用cmd命令:D:\Appserv\mysql\bin\mysqladmin -uroot -p shutdown,然后输入密码,再net start mysql 就没有这个错误提示了!

四、数据库的创建与删除

1、创建数据库testdb

mysql> create database testdb;
Query OK, 1 row affected (0.02 sec)

2、使用数据库testdb

mysql> use testdb;
Database changed

3、删除数据库testdb

mysql> drop database testdb; 
Query OK, 0 rows affected (0.00 sec)

4、退出登陆

mysql>exit 
Bye

C:\Documents and Settings\Administrator>

五、操作数据库数据的一般步骤

1、启动MySQL服务器

2、登陆数据库服务器

3、使用某个要操作的数据库

4、操作该数据库中的表,可执行增删改查各种操作。

5、退出登陆。

以上内容讲述了win7系统配置php+Apache+mysql环境的方法,希望大家喜欢。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1049139.htmlTechArticlewin7系统配置php+Apache+mysql环境的方法,win7mysql B/S架构当下很流行,因为B/S架构有众多优点,例如:用户只需有浏览器就可使用,维护升级都...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn