The PHP language needs to be configured properly before it can be developed so that our program runs perfectly. So how do you configure the PHP development environment correctly? The article will introduce Apache, MYSQL, php download, installation and configuration, respectively, in Windows and Linux environment development environment.
First, download Apache, MySQL and PHP
1, the Apache download
The Apache server can download Windows Apache installer via an officially provided mirrored address, but it is both in English and too slow to download. I suggest that you go to the Chinese army, the sky or Zhongguancun to download the latest version of the installation program, fast.
2, the MySQL download
The official website of MySQL is http://www.mysql.com. Can download the latest version of MySQL, or that sentence, we recommend to the Chinese army, the sky or Zhongguancun download.
3, PHP download
The official website of PHP is http://www.php.net. You can download the latest version.
Second, configure the PHP development environment under Windows
1, Apache, MySQL and PHP installation like other Windows software, here we recommend the Apache and PHP software installed in the D disk directory, the MySQL software installed in the C disk, so no need to do any setup, MySQL can start running smoothly.
2, Configuration development environment
In order for Windows to execute PHP, you need to do something further and build your environment by following these steps:
1 in the PHP installation directory, find the file Php5ts.dll, copy it to the C disk system32 directory.
2 in the PHP installation directory, find the file Libmysql.dll, copy it to the C disk system32 directory.
3 in the PHP installation directory, find the file php.ini, copy it to the c:windows. This file is configured to configure PHP basic files, such as setting the server root configuration, using a text editor to open the php.ini file, find "doc_root=", because I installed the Apache default in the D-Packing directory, so modify the value of this configuration item is: Doc_root=d: Apache2htdocs
Tip: The user modifies the value of the configuration item according to the path of the Apache installation.
4 Find "Extension_dir =" in php.ini, this configuration item is used to load the extension module of PHP, modify the configuration item as follows: Extension_dir = D:phpext, (need to modify PHP loading location according to own installation directory).
5) Find the "Extension=php_mysql.dll" in the php.ini and remove the semicolon before it, indicating that the item is in effect. This configuration entry is used to enable PHP to support MySQL, where the semicolon functions as an annotation. After modifying the PHP configuration file php.ini, save exit the file.
6) for Apache configuration. Go to the Conf directory under the Apache installation directory and open the Apache configuration file http.conf with a text editor. Dynamic shared Object (DOS) Support is found in this file, and the following configuration items are added at the end of the LoadModule line: LoadModule php5_module D:/php/php5apache2.dll, ( You need to modify the PHP loading location according to your installation directory. This item is loaded into the PHP module Php5apache2.dll via Apache, which is run by PHP as a module in Apache.
7 in order to allow Apache to support the. php suffix file, locate the AddType item in http.conf and add the following configuration entry at the end: AddType application/x-httpd-php.php. Find DirectoryIndex and add index.php at the end. In order to support Chinese, find Adddefaultcharset iso-8859-1 changed to Adddefaultcharset GB2312. Save http.conf after modification. That completes the basic configuration of Apache.
Note: It is strongly recommended that the Apache configuration file http.conf to be modified, must comply with the principle of a little test, that is, after each modification and save the http.conf, to restart Apache, if the Apache normal start, you can make subsequent changes, otherwise, explain this change is wrong, careful inspection Check and redo the new changes.
Iii. Configuring the PHP development environment under Linux
1, the installation of MySQL
On MySQL website download mysql installation file mysql-server-4.0.20-0.i386.rpm, execute the following command to complete the installation of MySQL.
RPM-IVH mysql-server-4.0.20-0.i386.rpm
If the MySQL password is not set, test the MySQL installation successfully with the following command.
Mysql-u Root
Appears like Welcome to the MySQL Mointor. The words commands end With;or g indicate a successful installation.
2, the Apache installation
Download the UNIX version of the compression pack from Apache's official website, taking httpd-2.0.52.tar.gz as an example, assuming that the resource bundle is placed under/USR/LOCAL/SRC and unzipped after entering the directory, the command is as follows:
Cd/usr/local/src
TAR-ZXVF httpd-2.0.52.tar.gz
After decompression, enter the directory httpd-2.0.52 and execute the following command:
./configure--prefix=/usr/local/apache2--enable--module=so
Where--prefix=/usr/local/apache2 is used to specify the installation directory for Apache. Next compile, execute the command to complete the installation.
Make
Mae Install
3, configure the installation of the PHP development environment
1 Download the php5.1.4.tar.gz compression package from the PHP website, extract the package, and order the following:
TAR-ZXF php5.1.4.tar.gz
2) go to the unpacked directory, execute the following command to complete the PHP installation directory and other related configuration:
./configure--prefix=/usr/local/php-with-mysql=/var/lib/mysql
3) Then compile PHP, the command is as follows:
Make
Make install
4 Copy the current directory under the file PHP large installation directory of the Lib directory, and renamed to PHP.ini, command as follows:
CP Php.ini-dist/usr/local/php/lib/php.ini
5 after the installation of the above configuration PHP development environment, see the configuration of the content under Windows for related configuration, configuration items and configuration methods similar.