Saturday, July 31, 2010

[PHP] quick start

PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document - but it doesn't mean you can't view .php sites offline.

In order to test PHP on your own PC you need to install:
  1. Apache HTTP Server [for Windows: here]
  2. PHP [for Windows: here]

During installation you will be able to choose your custom server directory, like:

When apache installation is over, extract PHP .zip file into C:\server\PHP.

Copy php5ts.dll and ntwdblib.dll to C:\Windows\system32\.

Change file name php.ini-recommended to php.ini.

Now, let's stop for a moment to configure php.ini
> display_errors = Off
you might need to know when and what something is wrong so turn it on

> ;error_log = filename
same as above, delete ; and replace filename with the path to a file, where you want PHP to write errors
eg: C:/server/errors.php.log

> extension_dir = “./”
if your PHP directory is C:/server/PHP replace “./” with C:/server/PHP/ext/

> ;extension=php_mbstring.dll…
These entries define which extensions are turned on. Default, all are off. There is no need to turn them all on, because they are loaded during the start of the system. Delete ; to turn on just a few of them you'll need:
php_mbstring, php_bz2, php_gd2, php_imap, php_mysql

Save changes and copy php5apache2_2.dll from PHP folder to apache\bin.

Last step - configure Apache

Open apache/conf/httpd.conf in notepad and add at the end of the file:
LoadModule php5_module "bin/php5apache2_2.dll"
AddType application/x-httpd-php .php

also you might want to change the line
DocumentRoot “C:/server/apache/htdocs”
it's a place where you put your .php sites you want to view.

DirectoryIndex index.html
add here also index.htm default.html default.htm index.php

Save changes, put your site in an appropriate folder and view them in your browser by hitting
http://localhost/ or

I believe that installing PHP isn't too easy for beginners. I've been through many useless tutorials until I have found a one written by EriZ, which I've translated and shortened to make it all even more quick and clear.



  1. Test się udał! ;P

  2. Masz jakiś bug - na górze strony mam wyświetlone jakieś symbole - 9 linijek.
    Czyżby koniec bloga? ;P

  3. o czymkolwiek piszesz, lepiej byłoby gdybyś ogarnął wreszcie mojego windowsa!