PHP remains the most widespread and popular server-side programming language on the web. It is installed by most web hosts, has a simple learning curve, close ties with the MySQL database, and an excellent collection of libraries to cut your development time. PHP may not be perfect, but it should certainly be considered for your next web application. Both Yahoo and Facebook use it with great success.
Installing PHP on your development PC allows you to safely create and test a web application without affecting the data or systems on your live website. This article describes PHP installation as a module within the Windows version of Apache 2.2. Mac and Linux users will probably have it installed already.
There are some excellent all-in-one Windows distributions that contain Apache, PHP, MySQL and other applications in a single installation file, e.g. XAMPP (including a Mac version), WampServer and Web.Developer. There is nothing wrong with using these packages, although manually installing Apache and PHP will help you learn more about the system and its configuration options.
Although an installer is available from php.net, I would recommend the manual installation if you already have a web server configured and running.
Download the latest PHP 5 ZIP package from www.php.net/downloads.php
As always, virus scan the file and check its MD5 checksum using a tool such as fsum.
We will install the PHP files to C:php, so create that folder and extract the contents of the ZIP file into it.
PHP can be installed anywhere on your system, but you will need to change the paths referenced in the following steps.
Copy C:phpphp.ini-recommended to C:phpphp.ini. There are several lines you will need to change in a text editor (use search to find the current setting).
Define the extension directory:
extension_dir = "C:phpext"
Enable extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for the majority of applications (remove the semi-colon comment):
extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll
If you want to send emails using the PHP
mail() function, enter the details of an SMTP server (your ISP’s server should be suitable):
[mail function] ; For Win32 only. SMTP = mail.myisp.com smtp_port = 25 ; For Win32 only. sendmail_from = firstname.lastname@example.org
To ensure Windows can find PHP, you need to change the path environment variable. From the Control Panel, choose System, (then “Advanced system settings” in Vista), select the “Advanced” tab, and click the “Environment Variables” button.
Scroll down the System variables list and click on “Path” followed by the “Edit” button. Enter “;C:php” to the end of the Variable value line (remember the semi-colon).
Now OK your way out. You might need to reboot at this stage.
Ensure Apache is not running (use “net stop Apache2.2” from the command line) and open its confhttpd.conf configuration file in an editor. The following lines should be changed:
Line 239, add index.php as a default file name:
DirectoryIndex index.php index.html
At the bottom of the file, add the following lines (change the PHP file locations if necessary):
# PHP5 module LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php"
Save the configuration file and test it from the command line (Start > Run > cmd):
cd Apache2bin httpd -t
Create a file named index.php in Apache’s web page root (either htdocs or D:WebPages) and add this code:
<?php phpinfo(); ?>
Ensure Apache has started successfully, open a web browser and enter the address http://localhost/. If all goes well, a “PHP version” page should appear showing all the configuration settings.
Getting a website for your small or large business is an essential way of making it grow globally.
Copyrights © 2018 Dreamsmolder.com. All rights reserved.