The first executable PHP Program-from configuration to hello World

Source: Internet
Author: User

A long time ago I wanted to see something about PhP. To tell the truth, it took so long to figure out how to run php. When I first wanted to use PHP, I wanted to know more about things, but I didn't know how to build the environment. Although I had a general understanding of some basic things, I was still in the lowest level.

 

Here we are talking about the first thing that can be run, of course, for the most basic thing, that is, from environment configuration to a PHP page that can run.

 

Go to the topic. First, download. Apache_2.0.63-win32-x86-no_ssl.msi (http://httpd.apache.org/download.cgi ). Php-5.2.10-Win32.zip (http://cn.php.net/get/php-5.2.10-Win32.zip/from/a/mirror ). These are the latest apache2.0 so far. And php5.2. (Let's talk about why we don't need apache2.2. Because there are a lot of problems when we use 2.2, such as compatibility or patching on the Internet. In short, it is a problem of connection ...) Therefore, 2.0 is used. (Php5.3 is not used here. It is also because the installation has encountered quite a problem. Therefore, we recommend that you download the decompressed version at the beginning, which causes fewer problems .)

 

With these two, it is enough (for the first PHP program ),

  

1. Configure PHP and decompress PHP to a directory. Here I am D:/PHP. (again, I have a bad problem, that is, I like to attribute many things to the program directory, because there are spaces, as a result, many problems are raised .) Decompress the package. Find "php. ini-Dist file, renamed as "php. ini ", this is actually (initialization parameters) configuration file, (Here we suggest you go to a look at the http://www.phpchina.com/html/81/n-13681.html) directly have some content. Haha, but let's talk about it, because at least I tried it manually. Of course, MySQL is not configured. It has been well configured for a long time, haha. Here we point out two points: 1, register_globals = value. It is related to form transfer references. 2. extension is the add-on. Then configure the environment variables (important ). Directly add D:/PHP and D:/PHP/EXT to the environment variables.

 

2. Configure Apache and install it. When entering the domain name, you can enter 127.0.0.1. Here we will test it on the local machine. Enough. Configure it. Here we need two places: 1. Find The apache2/conf directory and open httpd. conf, and then add loadmodule php5_module D:/PHP/php5apache2 after loadmodule. DLL, and add phpinidir "D:/PHP" to the interface. Note that the directory here is your directory, which means that the previous one loads php as a module, there is also the PHP configuration file under D:/PHP, which is obvious. 2. Locate addtype and add "addtype application/X-httpd-PHP. PHP and addtype application/X-httpd-PHP. html ", and then start Apache. If there is a problem, there is no problem. Congratulations, it's almost done.

 

The next step is the experiment program.

<HTML>

<Head>

<Title>

First PHP

</Title>

</Head>

<Body>

<? PHP

Echo 'Hello world'

Phpinfo ();

?>

</Body>

</Html>

 

Open the browser and enter http: // 127.0.0.1/firstphp. php to see what is going on?

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.