Build PHP Environment on Windows 7

Source: Internet
Author: User
Tags php website vc9
Windows 7 under PHP environment setup

??? There is not a time to write things, these days to get a little php things, now to share a PHP operating environment to build,

Although there are many lmap and wmap a kind of one-button installation tools, but I think, or do their own hands, to understand the language of the operating environment, in the future development more ease.

Because the development in Linux is relatively small, I am under the Windows 7 system installed under the PHP operating environment for everyone to do an introduction, share my results.

First of all, we have to prepare the relevant running environment installation package, I use PHP5.3 + apache2.2+ MySQL5.5

The download addresses are:

?

? Php:http://windows.php.net/downloads/releases/php-5.4.7-win32-vc9-x86.zip

Apache:http://mirror.bjtu.edu.cn/apache//httpd/binaries/win32/httpd-2.2.22-win32-x86-no_ssl.msi

Mysql:http://cdn.mysql.com/downloads/mysql-5.5/mysql-5.5.28-win32.msi

?

Here I only take my pc to configure, the path is my own local path, you can follow your actual installation path to configure.

?

?

First, we have to configure Apache (the installation procedure is omitted, this is not difficult)

?

1. Find the Conf folder under the Apache installation directory, I am here C:\Program files (x86) \apache software foundation\apache2.2\conf, find the httpd.conf file. This is Apache's core configuration file, we need to add the following lines:

?

#加载PHP处理模块
LoadModule php5_module "C:/php/php5apache2_2.dll"?
#添加PHP后缀的处理
AddType application/x-httpd-php. php???
Phpinidir "c:/php"

?

Look at the note that I wrote. Everyone should also understand that first to load the PHP processing module, so that when accessing Apache, it will call PHP to request processing.

If Php5apache2_2.dll is not found in the PHP installation package, then you do not have the correct PHP version

We see on the PHP website, php Two version, one is VC9 x86 Non thread safe, one is VC9 x86 thread safe, that is, a with Apache module, one without Apache module, Be sure to select the ZIP package with Apache here.

?

Then the second sentence is to add the PHP suffix processing, indicating that when Apache receives a file with a content header of application/x-httpd-php or suffix. php, it will be handed over to phpinidir for processing, This will allow our PHP files to be compiled via Apache and then PHP.

?

2, the DocumentRoot and directory directory are changed to the path of the Web directory, in fact, is to customize a workspace, the future development of PHP will put the project into this workspace, browser access to the local IP can browse all the PHP project, very convenient.

I'll change it here.

?? DocumentRoot "D:/phpworkspace"?

??

??

?

? Everyone changes according to their actual situation.

?

Ok,apache aspect configuration is complete.

?

Second, then to configure PHP:

?

1, PHP.ini

?

Unzip the downloaded PHP source package into the C-drive PHP (this can be placed on their own location, but it is not recommended to put too deep in the directory and directory names can not contain Chinese and spaces, which may make you depressed to crazy).

?

And then found in the PHP directory php.ini-development file, there are two similar files, one is Php.ini-development, one is php.ini-production, from the file name we can also see that one is suitable for development, a suitable for project release , so, we modify php.ini-development this file, directly the filename php.ini after the deletion (preferably first back), so it becomes php.ini, hey, is not very familiar with it, right, we want this configuration file. And then open it, and the one we're going to modify is

?

; extension_dir= "ext"

?

Find this sentence and change it to

; extension_dir = "C:/php/ext"

?

and use the front for annotation?;?? The number is removed, it becomes this

? extension_dir = "C:/php/ext"

?

That is, ext's local absolute path, this according to their own actual situation change.

Then there is another is to let PHP support MySQL, very simple, find??

; Extension=php_mysql.dll?

This sentence, put;? The number is OK if you remove it. Let's not explain this.

?

?

? third, MYSQL (installation procedure omitted)

?

In front of the php.ini we have configured to allow PHP to use MySQL, there is no need for any configuration

?, just make sure that MySQL is working properly, OK.

?

Four, commissioning

?

We created a new PHP file under the previously defined workspace, with the following:

?

$link =mysql_connect (' localhost ', ' root ', ' admin ');
if (! $link) echo "Failed!";
else echo "Success!";
Mysql_close ();
?>

People who understand PHP can understand this sentence, a database of successive code, and then we save, browser input 127.0.0.1 access to a bit,

You can see the new PHP file we just created, click the link in the output if successful, then our environment is configured successfully.

?

Five, frequently asked questions:

?

1, if you run a php file without seeing the page instead of the Download prompt box, then it means that your PHP file is not recognized by Apache and handed over to PHP for processing, the problem is in the Apache httpd.conf file of the three lines of code.

2, if the PHP file can see the content of the Web page but display

????? Fatal Error: Call to undefined function mysql_connect () in D:\PHPWorkspace\test.php on line 2

????

???? Then it means that your PHP files can be compiled, Apache is normal, the problem is php.ini, not allowed to use the MySQL database or the Ext directory is not located, that is, Extension_dir = "C:/php/ext" problem.

3, remember to modify the general modification of the configuration file when you have to restart Apache for the changes to take effect.

?

?

?

Because I am also in the process of learning, write the article technical content is not high, but can record my study on the journey of little bit, these things only suitable for novice, Master laughed at.??????????????????????????????????????????????

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????? by Xiaomin

?

  • Related Article

    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.