Tips and tricks on developing web sites

Installing PHP

You should install the same PHP version that your Hosting Server has. In this example, the server uses PHP 7.3.27. You can download that at Downloads tab at php.net . You are using Apache, so you will need the threadsafe version of PHP. You may not be able to get the exact version, but you will get very close. In this case, 7.3.28 is what the site has available. That should be more than close enough. Download the file and uncompress it (right-click) to C:\PHP. Make sure you get the 64 bit version if your server is 64 bit..

The file we grabbed was php-7.3.28-Win32-VC15-x64.zip. VC15 means you need that Visual C runtime for PHP to work. The php.net page has a convenient download link for you to find that, or you can just google VC15 runtime and it will get you on the Microsoft download page. You have probably installed the correct runtime already when you installed the Apache web server. You can test this by executing C:\PHP\php.exe and looking for errors.

Now you should set a PHP Path environment variable for Windows. At the Windows start menu, type in environment and then click on the Edit environment variables for your account. Click on the Advanced tab and Environment variables button in the lower right. In the System Variables section, locate the Path item and add C:\PHP to the list.

PHP comes with two configuration templates php.ini-development and php.ini-production. We want a development environment, so copy php.ini-development and rename it to php.ini.

Edit your Apache httpd.conf file (C:\Apache24\conf) and add a handler at the end of the file

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php/php7apache2_4.dll"
PHPIniDir "c:/php"

To test that it worked, edit your webpage index.php file (C:\apache\htdocs\public_html) replacing as follows. Remember that you must have changed your httpd.conf DirectoryIndex to DirectoryIndex index.php index.html for this example.

<html><body><?php echo phpinfo(); ?></body></html>

You should get a purple screen detailing the configuration of PHP.

Let’s take a look at the c:\php\php.ini and note some important settings that you want in development:

error_reporting = E_ALL  will display any error or warning
display_errors = On
display_startup_errors = On