PHP without WAMP or XAMPP


I am big fan of WAMP. The reason – I tell every newbie that you can learn PHP in very short span. This is all possible because of a ONE click installation of WAMP and providing you the all the necessary packages to run your PHP and the back end code.

Well – here was the latest requirement from our client – Develop a web application using PHP and SQL Server. Naturally I need to play away with WAMP, as I don’t want to make the client box heavier using two database servers – the existing SQL server and the new MySQL because of WAMP.

Okay – so it’s a high time to install & configure the PHP & the Web Server (Apache or IIS). It was bit of headache, but no other option.

Let’s go. Here is the complete guideline on working with PHP 5.6.x with Apache server without WAMP or without XAMPP.

To be noted these versions are well compatible with each other and hence don’t go with any other major versions unless you are confident in conjuring it by yourself. I will assume that your system has SQL server already installed to it.

 

Here are the major steps:

A.      Download the packages:

  1. Apache 2.4.x httpd web server
  2. PHP 5.6.x – The PHP engine
  3. Eclipse Helios Editor (Optional)

B.      Running Apache(localhost) for the test page

C.      Configure PHP

D.      Configure Apache for PHP

E.       Running the first PHP code

A) Download the packages:

1. Apache httpd-2.4.25 http://www.apachelounge.com/download/VC14/binaries/httpd-2.4.25-win32-VC14.zip

2. PHP-5.6.30http://windows.php.net/downloads/releases/php-5.6.30-Win32-VC11-x86.zip

3. Eclipse Helioss R2 http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliossr2 This is a PHP compatible Eclipse IDE; I would insist you to go ahead with your known editor. This is not at all mandatory.

B) Running Apache(localhost) for the test page

You need to extract the downloaded package above #1. Copy to your drive (say C: or D). Rename the big named folder name to a shorted one – say its Apache24.

Go to C:\Apache24\bin

Do a double click on httpd.exe or from command prompt – C:\Apache24\bin>start httpd.exe

This should pop up a small prompt.

Open a browser and launch the URL  – http://localhost or http://localhost:80 – This should bring you a tiny output stating that – “It works!”. Means it is configured correctly.

Possible Issue #1: By somehow if your port 80 has been taken by other application like IIS or Skype, please change this into the file C:\Apache24\conf\httpd.conf from Listen 80 to Listen <YOUR_PORT>

Possible Issue #2: You may get a prompt like VCRUNTIME140.dll is missing while trying to run the httpd service. Just download this file from internet. This may come as a zip file. Extract it and copy the VCRUNTIME140.dll file to C:\Apache24\bin folder.

C) Configure PHP

Extract the #2 download and rename the big named folder to php5 or php56 or just php.

Copy the c:\php\php.ini-development to the same folder with  a rename as php.ini. After copy you should see it as c:\php\php.ini

Make sure that you should be able to locate the dll file – php5apache2_4.dll to C:/php folder. This dll is the one who help the Apache to communicate with PHP interpreter.

D) Configure Apache for PHP

i) Add these file to your httpd.conf file. You can add them anywhere but I would prefer to add where all these #LoadModule types of lines end with.

LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"

Caution : php5apache2_4.dll is the same into your PHP directory.

ii) Modify the value of the DocumentRoot to your folder htdocs or similar folder. Whatever you specify here, that should contain your project folders/subfolders and PHP files.

DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">

iii)Optionally add/modify the DirectoryIndex. Just add the main PHP file or welcome page of your project. Ideally if somebody just types http://localhost – without anything else – the mentioned page will act as a default page view at the browser.

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

E) Running the first PHP code

After adding those above lines to http.conf file, you must create index.php file. Let us add these PHP codes to your  c:/Apache24/htdocs/index.php file

<?php
   echo “PHP is one of the sweet language!”;
   echo phpinfo();
?>

Now launch the browser like http://localhost/index.php – The output should make you happy.

I will be writing another article very soon on major parameters those need to be changed in http.conf file.

Advertisements

One comment on “PHP without WAMP or XAMPP

  1. Great post. I used to be checking continuously this weblog and I’m inspired! Extremely useful info specifically the last part 🙂 I maintain such info a lot. I used to be seeking this certain information for a very lengthy time. Thanks and best of luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s