Programming library  » Articles Articles
Installing PHP on your PC

» Installing PHP on your PC

Page: 1 of 1
By: Daniel
Last updated: 17 April

Testing your scripts on a production server can be dangerous. A wrong loop or query will make your admin very unhappy. It can bring your website down and if you are in a shared environment then the server performance will affect the other webmasters. Learning PHP using your hosting account is a bad idea.

Your PHP host has an Apache webserver, a MySQL server, a PHP module and other software installed . Only the first three are required for your main PHP needs. You can have these programs on your PC and learn, test or crash everything you want.

Installing MySQL:
Download a stable version of MySQL for windows from http://www.mysql.com/ . Unzip it and install it. Go to the MySQL folder. There is a subfolder called bin inside it. In that folder you will find a program called winmysqladmin.exe. Create a shortcut for this program. (This is the one you will use it for mysql). Run winmysqladmin.exe. You are prompted for a name and a password. The vaules you input will be used in your php scripts. The MySQL server is running after this step. To stop it: click on the tray icon -> WinNT -> Stop Service. Remove the winmysqladmin shortcut from Start->Programs->Startup if you don't want MySQL to start every time.

Installing Apache:
Download a stable version from http://httpd.apache.org/. Install it. When prompted for the Server Information:

Network Domain: localhost
Server Name: localhost
Administrator e-mail: <your_email>
Select "Run when started, manually".

You will finish the installation as for any normal windows program. If you are running something else on port 80 (like IIS or other web server) then you need to change the port for Apache. To do that go to: Start->Programs->Apache HTTP Server->Configure Apache Server->Edit the Apache httpd.conf Configuration File. If prompted for a program to open it, choose WordPad. You will find a line like:

Port 80

Just change it to match your port. Examples: 81,8000,8001,8080,8081 . If you want to change the root folder for apache change the fallowing line:

DocumentRoot "D:/Program Files/Apache Group/Apache/htdocs"
Note the " and / .

To start Apache go to Start->Programs->Apache HTTP Server->Start Apache in console.

Installing PHP:
Make sure Apache is not running. Download php from http://www.php.net/. Download the windows binaries from Apache. Pick the file containing the API version for Apache. If you are still on that site , go to Documentation->Documentation Downloads . Download the Windows HTML help. It is a great tool for php programmers. Unzip the php package to a folder of your convenience. Example: d:\Program Files\PHP Find the LoadModule section and add at the end:

LoadModule php4_module "D:/Program Files/PHP/sapi/php4apache.dll"

Find the AddModule section and add the next two lines:

AddModule mod_php4.c
AddType application/x-httpd-php .php


Find the Directory index section and change it to:

<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>
Copy php.ini-dist from the PHP folder to your windows folder (Windows,WinNT, etc.) Rename it php.ini and open it. Find the fallowing values and modify them accordingly:

extension_dir = "D:\Program Files\PHP\extensions"

Find the "Windows Extensions" folder and enable what you need by removing the ; mark. Just enable the modules you know your script will use. Example: gd .
Find the section [mail function].

SMTP = your.outgoing.mail.server (you can take it from the settings of Outlook)
Sendmail_from= your_email

Find the fallowing entry and point it to a folder used for temporary files:

session.save_path = d:\Tmp

If you didn't change the document root folder from Apache then your site root is located in the htdocs folder.

Start MySQL, start Apache, add your website and pray everything works!
Pages: 1
Programming help
Do you have problems
with your code?
Please send your question to: askphp@stdlib.com
Somebody will try to help you.

Articles
ProgrammingProgramming
    » Two Programmers
    » Make and Makefiles

AlgorithmsAlgorithms
    » Roulette Wheel

DataData
    » Shortcut File Format (.lnk)

WebWeb
    » Installing PHP on your PC

MediaMedia

Stdlib WebsiteStdlib Website
    » How to add an article
    » Stdlib.com Rules


Small?
Small but growing!


Do you know where to get programming help? ... Stdlib.com !