PHP Standalone Environment Configuration

php download address: http://windows.php.net/download/

Apache download address: http://www.apachelounge.com/download/

mysql download address: http://dev.mysql.com/downloads/mysql/

1. 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:\phpEnv\Apache24) win7 (64-bit) php5.5-Apache2.4 -mysql5.6 environment installation

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

(1) Modify the root path of ServerRoot Apache: (Line 37) ServerRoot "c:/Apache24" is changed to =>ServerRoot "D:/phpEnv/Apache24"

(2) Modify ServerName to your host name: (Line 217) ServerNamewww.example.com:80 Remove the preceding #, 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:\phpEnv\Apache24\htdocs), and there will be a simple entry file index.html.

This path can be modified by myself, and I configure it here under my own newly created folder www (D:\phpEnv\www).

  (247行) DocumentRoot "c:/Apache24/htdocs" <Directory"c:/Apache24/htdocs"> 改为=> DocumentRoot "D:\phpEnv\www" <Directory "D:\phpEnv\www">

(4) Modify the entry file configuration: DirectoryIndex In general, we use index.php, index.html, and index.htm as the entry of the web project. Apache's default entry is only index.html and needs to add support for the other two,

Of course, the setting 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 can only be index.php

  (274行)<IfModuledir_module> DirectoryIndexindex.html 改为=> <IfModuledir_module> DirectoryIndex index.php index.htm index.html

(5) Set the directory of serverscript:

  (358行)ScriptAlias/cgi-bin/ "c:/Apache24/cgi-bin/"改为=> ScriptAlias/cgi-bin/ "D:/phpEnv/Apache24/cgi-bin"

(6)(380行) <Directory"c:/Apache24/cgi-bin"> AllowOverride None Options None Require all granted 改为=>

<Directory"D:/phpEnv/Apache24/cgi-bin">

  AllowOverride None

  Options None

  Require all granted

3. Next, you can start Apache Start---Run, enter cmd, and open the command prompt.

Then enter the D:\phpEnv\Apache24\bin directory and press Enter httpd and press Enter,

As shown in the figure. If there is no error, you can test it (keep the command window open).

Put the index.html in the Apache24\htdocs directory into the D:\phpEnv\www directory, and if you access it with a browser, "It works" will appear, which means that apache has been installed and started correctly.

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 the httpd service first (close the command window)

Re-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 name of the service,

What I added is: httpd.exe -k install -n "Apache24" command will have a successful prompt after the command is successful,

At this point, you can see the Apache24 service in the window service startup item and click Start.

If you don't want to set it to start at boot, you can also change the startup type to manual.

If you want to uninstall this service, 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:\phpEnv\Apache24\bin. I won't say much here. The configuration of Apache is basically completed.

 

Second, install and configure php

1. Unzip the downloaded php.zip to the installation directory, mine is (D:\phpEnv\php)

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

3. Add php support for the Apache service Open the Apache configuration file http.conf and add it at the end

# php5

support LoadModulephp5_module D:/phpEnv/php/php5apache2_4.dll

AddTypeapplication/x-httpd-php .php .html .htm

# configure thepath to php.ini

PHPIniDir "D:/phpEnv/php"

Here, when I add it under LoadModule, make sure that your php5apache2_4.dll file does exist in the earlier version of php5.5. There is no such file in it.

But the high-end version already has it.

You can open the php installation directory and find this 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 a new index.php with the content <?php phpinfo(); ?>

Save and access the information that appears in php, it means that php has been successfully installed.

Remarks: Some common configuration modifications of Php: (D:\phpEnv\php\php.ini)

Time zone setting: date.timezone = Asia/Shanghai

Error reporting level: error_reporting = E_ALL

This can all be turned on in development mode.

 

3. Install and configure mysql

1. Download the MySQL compressed package, extract it directly 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 is my configuration file posted 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 anything else.

After installing mysql, there is no graphical user interface. You can install software such as Navicat for MySQL, which seems to be more convenient.

2. After installing mysql, add mysql support for php

Open the php configuration file php.ini (D:\phpEnv\php\php.ini)

(1) (Line 721); extension_dir = "ext", remove the preceding ";",

And change it to extension_dir = "D:\phpEnv\php\ext" to open php extension support. There are many php extension support .dll files in the ext folder. Interested students can take a look.

(2) Then it is to open the mysql extension of php

(Lines 875 and 876) remove the preceding ";" extension=php_mysql.dll extension=php_mysqli.dll

Of course, you can also open php_pdo_mysql.dll in line 881 to enable php's pdo support. I usually use this.

Note: There are many expansion options in lines 863 to 888, just remove the preceding ";" for whatever you want to use.

Of course, if you want to add other extended support such as redis support, php itself may not provide the corresponding dll file,

You need to find the corresponding version of the dll and add it to the ext folder, and then add an extension=… to the configuration file. After completion,

Restart Apache and you can see it when you visit phpinfo

 

4. Summary:

There is already a lot of information on the installation of the Php environment on the Internet.

When I came into contact with php, I also searched earth-shakingly.

I have installed it on my computer several times.

At the beginning, the integrated software package, WAMP, AppServ, etc., was used. Later, after the php version was upgraded,

I found that it is very troublesome to upgrade the php of the integrated package.

Therefore, it is strongly recommended to configure the environment by yourself to better understand the connection between Apache, php, and mysql.

Guess you like

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