Build a Php development environment on Windows

Source: Internet
Author: User
In Windows, the Php development environment is set up to start learning PHP. 1. download apache, php, and mysql, and start from the very beginning to help you query information and ask questions. 1.1 install apache by specifying the installation path. after installation, you can directly access 127.0.0.1 and view Itworks. 1.2 install the Php development environment in m Windows
Start learning PHP.
1. download apache, php, and mysql, and start from the very beginning to help you query information and ask questions.
1.1 install apache by specifying the installation path. after installation, you can directly access 127.0.0.1 and see It works.
1.2 install mysql and configure it all the way to the end:
Configure or disable Windows Firewall before configuration.
Detailed Configuration --> Developer Machine --> Multifunctional Database --> Installation Path --> demo-support --> Enable TCP/IP Networking (check "Add firewall) --> Manual Selected Default Character Set (select utf8) --> Install As Windows Service (check Include Bin Directory in Windows Path) --> Set root password --> Execute
1.3 install php
For Web Server, select Apache 2.2.x module --> select the directory where the Apache conf file is located (Program files \ Apache Software Foundation \ Apache2.2 \ conf) --> select the content that can be installed, select all options. remember to select the manual to facilitate subsequent information query.

1.4 adjust apache configuration:
After php is installed, the module and PhpIni path are automatically configured in the Apache configuration file. However, you must restart the Apache server to make the configuration take effect and restart Apache through the Apache control icon.

Try to write a test. php file to the htdoc directory of apache:
 

Enter 127.0.0.1/test. php in the browser and you can see that the php code has been executed.

Try adding a php code in index.html:
It works!
 

Enter 127.0.0.1 in the browser and find that the php code is not executed. this is because the html file is not processed by php, so modify the apache configuration and add:
AddHandler application/x-httpd-php. html
In this example, the file with the. HTML extension will be processed by php. restart apache and run the php code.
You can also modify:
DirectoryIndex index.html index. php
In this example, if index.html does not exist, search index. php for the homepage.

1.5 connect to the mysql server:
$ Db = mysql_connect ("127.0.0.1", "root", "root Password ");
If (! $ Db) echo "Can't connect database.
";
Else echo "Connected database.
";

We can see that the database is successfully connected and the basic environment can be used.

PS:
If the php module is not loaded successfully, it may be because the php path in the apache configuration file is incorrect. the backslash \ must be written.

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.