Install and configure PhP5
Www.shellex.cn
The summer vacation is still a long time. I don't want to keep buried in data structures and algorithms. I decided to study PHP in my spare time.
The system is win2k3 SP1 (I have not planned to go to Linux first, but now I usually work in win, learn, and test). Apache 2.0.5.5 was installed in the past, download a PhP5 file today to install the configuration.
: Www.php.net
I downloaded a zip package, not a win installer, because I learned more about manual configuration.
The installation is based on the Apache module, Because CGI cannot be used, and the configuration is poor and there is a security problem.
Add in the HTTP. conf file
# Load the PHP module:
Loadmodule php5_module "D:/PhP5/php5apache2. dll"
# Resolution extension name
Addtype application/X-httpd-PHP. php
# Configure the php. ini path
Phpinidir "D:/PhP5"
The above is my PHP path, which should be changed as needed.
Then add the PHP path to the PATH variable of the system environment variable. My path is D:/php5.
Set a valid configuration file for PHP: PHP. ini. there are two such files in the zip package: PHP. ini-Dist and PHP. ini-recommended. follow official suggestions to use PHP. ini-recommended, because the performance and security are optimized in this file. I have a look at the content in it. It mainly involves some option changes. For the convenience of learning, I open display_errors:
Display_errors = on
Next, write the code in my web root directory... according to the habit, the first program should be hello World, PHP version <HTML>
<Head>
<Title> Hello PHP! </Title>
</Head>
<Body>
<? PHP
Class test {
VaR $ X;
Function _ construct ($ X ){
$ This-> X = $ X;
}
Function display (){
Print ("<p> Hello PhP5! </P> ");
}
Function _ destruct (){
Print ("<p> bye-bye! </P> ");
}
}
$ Tclass = new test (4 );
$ Tclass-> display ();
?>
<Body>
<HTML>
Save as index. php
Open my Firefox and enter 127.0.0.1: 8088
Page output:
Hello PhP5!
Bye-bye!
Well, it's good. www.shellex.cn