How to correctly configure the PHP development environment

Source: Internet
Author: User
Tags php development environment
Before developing the PHP language, you must configure the development environment so that our program can run perfectly. So, how to correctly configure the PHP development environment? Article

Before developing the PHP language, you must configure the development environment so that our program can run perfectly. So, how to correctly configure the PHP development environment? This article describes how to download, install, and configure Apache, MySql, and PHP, and how to build the development environment in windows and Linux respectively.

1. download Apache, MySql, and PHP

1. download Apache

The Apache server can download the Apache installation program for windows through the image address provided by the official website. However, the installation programs are both in English and the download speed is too slow. I suggest you go to Huajun, skysky, or Zhongguancun to download the latest version of the installation program, which is fast.

2. download MySQL

The official website of MySQL is http://www.mysql.com. You can download the latest version of MySQL. In that case, we suggest you download it from Huajun, skysky, or Zhongguancun.

3. Download PHP

PHP official website is http://www.php.net. You can download the latest version.

2. configure the PHP development environment in windows

1. installation of Apache, MySql, and PHP is the same as installation of other windows software. we recommend that you install Apache and PHP in the D directory and install MySQL on the C disk, in this way, MySQL can run smoothly without any settings.

2. configure the development environment

To enable windows to execute PHP, perform the following steps to build the environment:

1) in the PHP installation directory, find the php5ts. dll file and copy it to the C drive system32 directory.

2) in the PHP installation directory, find the file libmysql. dll and copy it to the C drive system32 directory.

3) in the PHP installation directory, find the php. ini file and copy it to C: \ windows. This file is the basic file for configuring PHP, such as setting the server root directory configuration. open php in the editor. in the INI file, find "doc_root =" because I installed Apache under the root directory of drive d by default. Therefore, modify the value of this configuration item to doc_root = d: \ apache2 \ htdocs.

Tip: you can modify the value of this configuration item based on the path of your Apache installation.

4) in php. in ini, find "extension_dir = ". /"", this configuration item is used to load the PHP Extension Module. modify this configuration item as follows: extension_dir = d: \ php \ ext, (you need to modify the PHP loading location according to your installation directory ).

5) in php. ini, locate "; extension = php_mysql.dll" and remove the semicolon before this item to make it take effect. This configuration item is used to make PHP support MySQL. here, the semicolon serves as a comment. After modifying the PHP configuration file php. ini, save and exit the file.

6) configure Apache. Go to the conf directory under the Apache installation directory and open the Apache configuration file http. conf in the text editor. Find dynamic shared object (DOS) Support in this file, and add the following configuration item 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 own installation directory ). This item is loaded into the PHP module php5apache2. dll through Apache, that is, PHP runs with a module of Apache.

7) in order for Apache to support files with. php suffixes, find the AddType item in http. conf and add the following configuration item at the end: AddType application/x-httpd-php.php. Find the directoryIndex and add index. php at the end. To support Chinese, find AddDefaultCharset ISO-8859-1 to adddefacharcharset GB2312. Save http. conf after modification. This completes the basic configuration of Apache.

Note: it is strongly recommended that the Apache configuration file http. when modifying the conf file, you must follow the principle of modifying one point of test, that is, each time you finish modifying one item and save the http. after conf, restart Apache. If Apache is started normally, you can modify it later. Otherwise, the modification is incorrect. check carefully and modify it again.

3. configure and configure the PHP development environment in Linux

1. install MySQL

On the MySQL official website to 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, run the following command to test whether the MySQL installation is successful.

Mysql-u root

The installation is successful if a message similar to welcome to the mysql mointor. commands end with; or \ g is displayed.

2. install Apache

Download the unixxcompressed package from the official apachewebsite and use httpd-2.0.52.tar.gz as an example. assume that the resource package is placed under/usr/local/src and enter the directory to decompress the package. the command is as follows:

Cd/usr/local/src

Tar-zxvf httpd-2.0.52.tar.gz

After decompression, go to the directory httpd-2.0.52 and execute the following command:

./Configure -- prefix =/usr/local/apache2 -- enable -- module = so

-- Prefix =/usr/local/apache2 is used to specify the installation directory of Apache. Next, compile and execute the command to complete the installation.

Make

Mae install

3. configure PHP development environment installation

1. download the php5.1.4.tar.gz compressed package from the PHP official network and decompress the package. the command is as follows:

Tar-zxf php5.1.4.tar.gz

2) go to the decompressed directory and execute the following command to complete the PHP installation directory and other related configurations:

./Configure -- prefix =/usr/local/php-with-mysql =/var/lib/mysql

3) compile PHP and run the following command:

Make

Make install

4) copy the file lib in the PHP installation directory under the current directory and change it to php. ini. the command is as follows:

Cp php. ini-dist/usr/local/php/lib/php. ini

5) after installing the above PHP development environment, refer to the configuration in windows for related configuration. the configuration items are similar to the configuration method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.