PHP 5 Tutorial

advertisement
Apache, MySQL and PHP Installation
and Configuration
Chapter 3
PHP Installation and Configuration
PHP Installation
Installing with Windows :
•
•
•
•
Go to the source Web site, php.net, and click “downloads” on
the navigation bar, choose click link to download Windows
Binary.
Choose latest stable version and click the installer file to initiate
download.
There are several different versions of the zip package - chose
the version that is suitable for the web server being used:
• If PHP is used with IIS then choose PHP 5.3 VC9 Non Thread
Safe or PHP 5.2 VC6 Non Thread Safe;
• If PHP is used with IIS7 or greater and PHP 5.3+, then the
VC9 binaries of PHP should be used.
• If PHP is used with Apache 1 or Apache 2 then choose PHP
5.3 VC6 or PHP 5.2 VC6.
Unzip the file to a temporary directory of your choice.
PHP Installation
Installing with Windows using IIS:
•
•
•
•
Click setup.exe to run the installation program. You
will see the first of the Installation Wizard screens.
Choose installation type, if you want to install in
the specific directory, choose advanced.
Click Next, which brings you to the Choose
Destination Location screen.
Settings SMTP :
• Type SMTP server address : localhost
• Type address for the mail function :
admin@localhost.com
PHP Installation
Installing with Windows using IIS:
•
•
•
•
•
Choose Error Settings :
• Display all errors warnings and notices for development
process.
Select Web Server, choose Apache 2.x.
Select .php for file extension.
For Web Server Configuration choose WWW Service Master
Properties and Default Web Site.
For testing, create file something.php which contain this script :
<?php
phpinfo();
?>
•
Open that file using web browser, if you can see a page that
contain information about your php installation, you’re in the
right way
PHP Installation
Installing Manually with Windows :
•
•
•
•
•
Download PHP 5.3 VC6 or PHP 5.2 VC6 for Apache HTTP Web
Server.
Unzip the file to a installation directory. (ex. c:\php)
Rename php.ini-dist to php.ini. Make sure to save your new
php.ini file to your c:\windows directory so Apache can find it.
By default, the PHP installation provides two copies of your
common configuration file: php.ini-dist and php.inirecommended. The php.ini-dist file is meant to be used for
development purposes, whereas php.ini-recommended should be
used when your site goes live, because it has additional security
measures.
Copy php5ts.dll into the c:\windows\system32 directory so that
Apache can find it.
You now need to configure your PHP to run with Apache and
MySQL, refer to Chapter 1 and 2.
Testing Installation
Installing Manually with Windows :
•
For testing, create file something.php which contain this
script :
<?php
phpinfo();
?>
•
Open that file using web browser, if you can see a page
that contain information about your php installation,
you’re in the right way.
Configuring
Configuring PHP5 to Use MySQL :
•
If you are using Windows, you will need to make two changes to your
php.ini file. Open the file using your text editor (such as Notepad++).
Locate the following lines:
; Directory in which the loadable extensions (modules) reside.
extension_dir = “./”
•
Change the last line to
extension_dir = “c:\php\ext”
•
The next change involves locating the following line :
;extension=php_mysql.dll
•
Simply remove the semicolon at the beginning of the line to
uncomment it.
You will also need to copy the file libmysql.dll from your c:\php
directory into your c:\windows\system32
References
References :
1.
2.
3.
4.
Anonymous.(n.d.). Apache HTTP Server Documentation Version
2.2. Retrieved from http://httpd.apache.org/docs/2.2/.
Achour, M., Betz, F. (n.d.), PHP Manual. Retrieved from
http://www.php.net/download-docs.php.
Anonymous. (n.d.). MySQL Reference Manual. Retrieved from
http://downloads.mysql.com/docs/.
Naramore, E., Gerner, J., Le Scouarnec, Y., Stolz, J., Glass, M. K.
(2005). Beginning PHP5, Apache, and MySQL® Web Development.
Indianapolis, IN: Wiley Publishing, Inc.
Download