Chapter 2. Installation

Developers working with PHP and MySQL often find it convenient to work on a local computer rather than a web server. In general, it is also safer to create and test your applications on a local—preferably private—computer and then deploy them to a public server where others can enjoy your work. Typically, you need to install Apache, PHP, and MySQL on the local computer, while your ISP handles installation on the public server.

Developing Locally

Developing your construct on your local computer is the recommended way to learn, since you can interact with all of the components on your own machine and not risk causing problems on a production server. That way, if there are problems in the local environment, you can fix them immediately without exposing them to your site’s visitors. Working with your files locally means that you don’t have to FTP them to a server, you don’t have to be connected to the Internet, and you know exactly what’s installed since you did it yourself.

There are three components to install:

  • Apache

  • PHP

  • MySQL

You will install the programs in that order. All our examples will be from the installation perspective of a PC with Windows installed, with notes for the Macintosh.

Installing Apache

First, Apache needs to be installed and operational before PHP and MySQL can be installed, or else they won’t work correctly. Plus, there wouldn’t be any use for the coding application and database without the Apache web server. A web server delivers web pages, ...

Get Learning PHP and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.