PHP on localhost made easy

Geschreven door Erwin A.W. Maas

Need only PHP ❓

If you have a website with PHP-files, you can install a webserver-package with PHP, Apache webserver and MySQL. For example: one like Xampp, Wampserver or whatever. This can be a hassle: often you need to change several settings to make everything work.

But what if you only need PHP? Is there an easier way to work on your website offline?

Yes there is, let me explain: you can go to the downloadpage of php.net or if you are on windows even easier: go to the Windows-PHP downloadpage.

Almost there...

Preparing for installation

Download the PHP-version you want (look for the version you´re running on your website) and extract the package to any folder you want. In the root folder where you unpacked the zipfile exists a file called "php.exe". Starting this file alone is not going to work, you need to give it some extra info.

Getting it done

Now, I have unpacked the downloaded file to my external harddrive called D and my website is also on my external harddisk D in the folder "exdomo".

I opened my text-editor and typed the following text to make a batchfile

for mobile-visitors: the second line (starting with D: and ending with exdomo) should not have line-breaks and slashes need to be backslashes in your batchfile.

@echo off
D:\path\to\php.exe -S localhost:8080 -t D:\path\to\exdomo
pause

Then I saved this file on my harddisk with the name: server.bat

To this file I added a shortcut on my desktop.
Now when I click the shortcut the start-up screen appears and when I open my webbrowser and type in the adress bar: "localhost:8080" I see the website offline.

Exit php using ctrl-c and answering the question with "Y"

Opmerkingen

  1. Markdown is toegestaan. Toegestane HTML-Tags: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.