Manually build the php environment

There are many combinations of php manual construction environment, and the version number is inconsistent, which will cause the construction to fail.

The combination I built is: the combination of php5.6+MySQL5.6+Apache2.4.

 

1. Download the PHP language pack

 

First download php5.6 from the official website  http://windows.php.net/download#php-5.6 

Select the full version to download:

 

2. Apache server download

First download Apache2.4 from the official website   http://httpd.apache.org/download.cgi

 

Enter the second interface and select the second option:

 

Depending on the computer, select the appropriate number of digits:

 

Note the sentence:

The general meaning is that after configuring Apache, if you want to run ApacheMonitor.exe, it may report that the dll file is missing. If the file is missing, you need to download this software.

 

After downloading Apache2.4, continue to download MySQL 5.6.

 

3. Download the MySQL 5.6 service.

I am using the version of mysql5.6.17 Official website download address:  https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-17.html

Maybe the official website download will be slower, you can also find it directly online.

There are two types of this file, one is the installation version (the file ending in msi), and the other is the free version (the file ending in zip)

 

Both are fine.

 Note: It is best to back up something in the database before

 I use the free version, and I think this version has fewer errors. The following describes the preparation method of the free version:

Unzip to a custom directory, the directory I unzipped is D:\LAMP\mysql-5.6.17-winx64

Rename my-default.ini in the root directory to my.ini, and replace all the contents of my.ini with the following.

[client]
port=3306
default-character-set=utf8
#Client character type, it is the same as the server, utf8 is recommended
[mysqld]
port=3306
character_set_server=utf8
#Server character type, utf8 is recommended
basedir=D:\LAMP\mysql-5.6.17-winx64
#Unzip the root directory
datadir=D:\LAMP\mysql-5.6.17-winx64\data
#Unzip the root directory\data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
D:\LAMP\mysql-5.6.17-winx64\bin\mysqld.exe
#Unzip the root directory\bin\mysqld.exe

 

Note this sentence:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

What is set here is that if you want to add empty data to a column in the table, you cannot use the '' method, you must write NULL without quotation marks.

If you want to use the '' way, change this sentence to:

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

 

Environment variable configuration

My Computer - Properties - Advanced - Environment Variables - New

Variable MYSQL_HOME value D:\LAMP\mysql-5.6.17-winx64

Find the variable path edit, add ;%MYSQL_HOME%\bin after

 

Enter cmd during operation, or find C:\Windows\System32\cmd.exe, enter the bin subdirectory of the mysql decompression directory

C:\Documents and Settings\Administrator>cd\
C:\>d:
D:\>cd LAMP
D:\LAMP>cd mysql-5.6.17-winx64
D:\LAMP\mysql-5.6.17-winx64>cd bin
D:\LAMP\mysql-5.6.17-winx64\bin>
D:\LAMP\mysql-5.6.17-winx64\bin>mysqld -install
Tip: Service successfully installed. And the installation is successful.
(CMD command: CD\ return to the root directory D: enter D drive cd LAMP enter the LAMP folder)

 

Start, stop, remove MYSQL service
  Start the MYSQL service: net start mysql
  Stop the MYSQL service: net stop mysql
  Remove the mysql service: mysqld -remove
Start the service here to facilitate the next step.

 This completes the configuration.

 

If it is a file ending with msi, the installation process is:

Enter this interface and select the second custom setting path

 

 

Select the default option all the way,

Set the password here.

 

 After MySQL is installed, you can start configuring the development environment

Apache installation configuration

1. Unzip the downloaded Apache2.4 to a custom directory. The directory I choose here is the AMP directory of the D drive.

2. Open the httpd.conf file in the conf folder of the apache decompression directory:

Find all c: Apache24 and change it to the directory you unzipped yourself. There should be several places that need to be changed. Use the replacement function of Notepad directly.

After the replacement, open the cmd command line, enter httpd -k install and check the syntax, as follows:

 

 

As shown in red text, it is successful.

3. Next, start the apache service, test whether the installation is successful, and open ApacheMonitor.exe in the apache bin directory (if the dll file is missing, you need to install the VC mentioned above, and you can open the monitor after installation) , open as follows:

 

4. Test

Enter localhost in the browser and press Enter, and see the following figure indicating that the apache installation is successful.

In fact, the it works displayed by the browser is the content of the default home page index.html under the apache default site htdocs (in fact, it is located in the htdocs folder under the apache directory). Since then, apache has been successfully installed, and then you need to configure php so that apache and php work together (using php as a module of apache).

 

 

This folder htdocs is the root directory for running php files, and all php files must be placed here before they can be run.

 

 

Configure php module to apache server

1. Do the following configuration in Apache24/conf/httpd.conf:

Add the following code at the end of the file (note to modify the path):

LoadModule php5_module D:\AMP\php-5.6.30-Win32-VC11-x64\php5apache2_4.dll
AddType application/x-httpd-php .php
LoadModule php5_module modules/libphp5.so
PHPIniDir D:\AMP\php-5.6.30-Win32-VC11-x64

  

After that, restart the apache server (restart the configuration file if you modify it).

 

2. Create a php file in the htdocs directory of apache, called index.php here, and write the following content in this file:

<?php
 echo "hello php world!";
?>

Enter localhost/index.php in your browser to see:

Apache configures php successfully, and then you need to configure some php-related configurations and configure MySQL into php.

php configuration

Configure time zone:

Open the php decompression directory, find the php.ini-development file, rename it php.ini, and open it with Notepad.

find (with semicolon) ;date.timezone =

Remove the previous points and modify it to date.timezone = Asia/Shanghai

Test: Write the following code in the index.php folder in the root directory

<?php

 echo  date("Y:m:d H:i:s");
?>

 If the browser runs and displays the current time, the time zone configuration is successful.

 

 configure mysql

1. Open the php.ini file and look for the extension_dir keyword

Remove the previous comment and change the ext file path to our own ext path, that is, modify it to:

extension_dir = "D:\AMP\php-5.6.30-Win32-VC11-x64\ext"

 2. Continue to find the php_mysql keyword in php.int

Remove the semicolon in front of the two items in the figure. If the extension is missing after running php, you can remove the semicolon before the corresponding content.

 

 

3. Set the encoding:

Find default_charset =

Change it to:

default_charset = "UTF-8"

At this point, the php environment is built, and the php file can be put into the htdocs folder to run.

 Forwarded from http://www.cnblogs.com/cyrfr/p/6483529.html#3917894

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482840&siteId=291194637