Home >Backend Development >PHP Tutorial >How to configure the php Apache mysql environment in win7 system, win7mysql_PHP tutorial
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
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
e05d0d9844b0556cb938c9871c14773b
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.
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.
at the end
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
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.
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:
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
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行)去掉前面的“;” 当然也可以打开881行的php_pdo_mysql.dll启用php的pdo支持我一般都用这个。 注:在第863行到第888行有很多扩展选择,你要用到什么,去掉前面的“;”就可以了。当然如果要添加其他的扩展支持如redis支持,php本身可能没有提供相应的dll文件,就需要自己去找到相应版本的dll添加到ext文件夹中,然后在配置文件中添加一个extension=… 完成之后,重启Apache 3)、启动MySQL服务 net start mysql MySQL服务正在启动 . 4)、登陆MySQL服务器 注意:MySQL的管理员用户名为root,密码默认为空。 5)、查看数据库 可以看到MySQL服务器中有三个数据库。 6)、使用数据库 7)、查看数据库中的表 8)、创建表ttt 9)、插入三条数据 10)、查询数据 11)、删除数据 删除后查询操作结果: 12)、更新数据 查看更新结果: 13)、删除表 查看数据库中剩余的表: 三、更改MySQL数据库root用户的密码 1、使用mysql数据库 2、查看mysql数据库中所有的表 3、删除mysql数据库中用户表的所有数据 4、创建一个root用户,密码为"xiaohui"。 5、查看user表中的用户 6、重启MySQL:更改了MySQL用户后,需要重启MySQL服务器才可以生效。 net stop mysql MySQL 服务正在停止.. net start mysql 7、重新登陆MySQL服务器 如果修改密码后net startmysql出现不能启动mysql的1067错误,则可以使用以下办法解决: 四、数据库的创建与删除 1、创建数据库testdb 2、使用数据库testdb 3、删除数据库testdb 4、退出登陆 五、操作数据库数据的一般步骤 1、启动MySQL服务器 2、登陆数据库服务器 3、使用某个要操作的数据库 4、操作该数据库中的表,可执行增删改查各种操作。 5、退出登陆。 以上内容讲述了win7系统配置php+Apache+mysql环境的方法,希望大家喜欢。
changed to =>
AllowOverride None
Options None
Require all granted
# 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"
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.
[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
extension=php_mysql.dll
extension=php_mysqli.dll
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)
mysql> use test
Database changed
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)
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)
mysql> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
+------+------+
3 rows in set (0.00 sec)
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)
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)
mysql> drop table ttt;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
Empty set (0.00 sec)
mysql> use mysql
Database changed
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)
mysql> delete from user;
Query OK, 3 rows affected (0.00 sec)
mysql>grant all on *.* to root@'%' identified by 'xiaohui' with grant option;
Query OK, 0 rows affected (0.02 sec)
mysql> select User from user;
+------+
| User |
+------+
| root |
+------+
1 row in set (0.00 sec)
MySQL 服务已成功停止。
MySQL 服务正在启动 .
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>
使用cmd命令:D:\Appserv\mysql\bin\mysqladmin -uroot -p shutdown,然后输入密码,再net start mysql 就没有这个错误提示了!
mysql> create database testdb;
Query OK, 1 row affected (0.02 sec)
mysql> use testdb;
Database changed
mysql> drop database testdb;
Query OK, 0 rows affected (0.00 sec)
mysql>exit
Bye
C:\Documents and Settings\Administrator>