Signup/Sign In

Install PHP on your Local Machine

To run PHP scripts on any machine(server, computer etc) we need PHP installed on it. In this tutorial, we will learn how to install PHP on our computer/laptop and setup the development environment.


Requirements for PHP

To run PHP scripts, we need the following services:

  1. PHP Parser: To execute PHP scripts, PHP installation is required.
  2. Web Server: Because PHP is mostly used to develop websites, hence most of its implementations comes bundled with Apache Web Server, which is required to host the application developed in PHP over HTTP.
  3. Database: Any one database management system, which is generally MySQL, as PHP comes with a native support for MySQL

Now, you can install all the 3 services separately yourself, or you can simply download and install softwares which automatically installs all the above services.

The most popular such software package is XAMPP.


What is XAMPP?

XAMPP stands for:

X: Cross Platform, as it supports all the moder operating systems like Windows, Mac OSX, Linux etc.

A: Apache Web Server

M: MySQL database management system.

P: PHP installation

P: Perl scripting language

XAMPP logo

You can easily download and install XAMPP from this link. The installation process is simple and once installed you will see a small window like this, showing the status of various services which are running.

XAMPP Window Snapshot

You can easily control, stop and restart, various services using the XAMPP Control Panel.

Upon successful installation, a folder with name xampp will be created in the C drive(by default). In the folder xampp there are many sub-folders like apache, cgi-bin, FileZillaFTP etc, but the most important sub-folders are:

  1. htdocs: This is the folder in which we will keep all our PHP files.
  2. mysql: This folder contains all the files for the MySQL database. By default the MySQL databse runs on port number 3306.
  3. php: This folder holds all the installation files for PHP. All the configurations for the current PHP installation is saved in php.ini file which is stored in this folder.

If everything seems fine and the apache server is running(check in the XAMPP control panel), open your Web browser and enter localhost in the address bar and hit enter. You will see the default page of Apache web server.

Apache Webserver It Works


Other Software Packages

XAMPP is not the only available package, although it is the most widely used one. Here are a few other Operating System specific options that you can download and install:

  • WAMP: It's for Windows (Window, Apache, MySQL and PHP)
  • MAMP: It's for Mac OSX (Macintosh, Apache, MySQL and PHP)
  • LAMP: It's for Linux (Linux, Apache, MySQL and PHP)

IDE or Editor for writing PHP code

As PHP code is not compiled, you can even use a simple editor like Notepad to create PHP code files. But it's always good to have a nice looking Editor which can highlight the code, provide you suggestions while coding, and even analyze your code for syntax errors as your write it.

Before we checkout the list of IDEs and Editors, we must know the difference between both. An Editor is a simple text editor with enhanced capabilities like syntax highlighting etc, many modern editors also allows for language specific plugin download to support more features.

Whereas, an IDE is an integrated development environment, which is a self-contained package that allow you to write, compile, execute and debug code in the same place.

So if you want a light weight software, go for any Editor, and if you want a heavy weight IDE, you can choose any one from the list below.

So here are a few good IDEs and Editors:

  1. Netbeans IDE
  2. Eclipse IDE
  3. PyStorm IDE
  4. Atom Editor
  5. Brackets Editor
  6. Notepad ++
  7. Sublime Text

Download and install anyone you want. I personally use Atom Editor, as it is lightening fast, comes with some amazing themes options and plugins.