How to configure the php environment under win7 system, php Apache mysql is essential in the configuration process There are few elements, 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)Change 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 the 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"
changed to =>
DocumentRoot "D:phpEnvwww"
(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)
DirectoryIndex index.html
changed to =>
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)(line 380)
AllowOverride None
Options None
Require all granted
changed to =>
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 (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# 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 added it under LoadModule
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, create a new index.php with the content of Save it. When accessing the php information, it means that php has been successfully installed.
Remarks:
Some common configuration modifications of Php: (D:phpEnvphpphp.ini)
Time zone setting: date.timezone = Asia/Shanghai
Error reporting level: error_reporting = E_ALL This is in development mode All can be opened below.
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) (Line 721); extension_dir = "ext", remove the previous ";" and change it to extension_dir = "D:phpEnvphpext" to open php extension support. There are many php extension support under the ext folder .dll file, interested students can take a look.
(2) Then open the mysql extension of php
(Lines 875, 876) Remove the preceding ";"
extension=php_mysql.dll
extension=php_mysqli.dll
Of course, you can also open php_pdo_mysql.dll on line 881 to enable php's pdo support. I usually use this.
Note: There are many extension options on lines 863 to 888. Whatever you want to use, just remove the ";" in front of it. Of course, if you want to add other extension support such as redis support, PHP itself may not provide the corresponding dll file. You need to find the corresponding version of the dll yourself and add it to the ext folder, and then add an extension=...
After completion, restart Apache
3), start MySQL service
net start mysql
MySQL service is starting
.
The MySQL service cannot be started.
4), log in 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 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), use 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(20));
Query OK,
0 rows affected (0.00 sec)
9), insert three pieces 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)
Query operation result 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 update 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)
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 data in the user table in the 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 changing the MySQL user, you need to restart the MySQL server for it to take effect.
net stop mysql
MySQL service is stopping..
MySQL
Service stopped successfully.
net start mysql
MySQL service is starting
.
The MySQL service has been started successfully.
7. Log in 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 you change the password, net
If startmysql encounters a 1067 error that cannot start mysql, you can use the following methods to solve it:
Use the cmd command: D:Appservmysqlbinmysqladmin
-uroot -p shutdown, then enter the password, and then net start mysql
There is no such error message anymore!
4. Creation and deletion of database
1. Create 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 database testdb
mysql> drop database testdb;
Query OK, 0 rows affected
(0.00 sec)
4. Log out
mysql>exit
Bye
C:Documents and
SettingsAdministrator>
5. General steps for operating database data
1. Start the MySQL server
2. Log in to the database server
3. Use a certain Operated database
4. Operate the tables in the database and perform various operations such as addition, deletion, modification and query.
5. Log out.