Tutorial on building a php apache mysql environment in windows and Linux

Source: Internet
Author: User
Tags mysql tutorial php development environment

In windows and linux environments, php Tutorial: apache mysql tutorial environment setup tutorial
 
How to correctly configure the 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? 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. For example, you can set the server root directory configuration and open php in a text 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: apache2htdocs.

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: phpext (you need to modify the php loading location according to your own 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 the 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.