Home > Tutorials and Resources > Getting Started Guide for Local Test Server Setup > Configuring PHP

Configuring PHP

By B Lingafelter          testserver, workflow

This guide is intended to help you configure PHP for your local test server, and includes details for configuring PHP in XAMPP for both Windows and Mac OSX. Before you configure your php.ini file, you should first check your current settings and note the settings you need to change.

Recommended PHP Core and date directives for test server

This table contains the recommended test server settings for PHP Core and Date directives for XAMPP (both Win and Mac).

Recommended Test Server Settings for PHP
Directive Local Value
allow_url_fopen On
allow_url_include Off
display_errors On
error_reporting 32767
file_uploads On
log_errors On
short_open_tag Off
upload_tmp_dir (Win) C:\xampp\tmp
(OS X) /Applications/XAMPP/xamppfiles/temp
date section
Default timezone
America/Chicago

 

Check Your PHP Settings with XAMPP:

  1. Open your XAMPP Control Panel (Manager-OSX) and Start  the Apache server.
  2. In a browser, type http://localhost in the address bar to open the XAMPP dashboard page.
  3. Click PHPInfo in top navigation bar to display your current settings. The PHP Core and Date directives sections are the ones to focus on.
    XAMPP Start Page
  4. Compare your Core and date values to those in the recommended test server settings for PHP Core table and note the ones that need to be changed. Your PHP directives should look similar to the old screenshot below.
    PHP Info
  5. Open XAMPP Control Panel and Stop Apache server before editing PHP directives.

Where Is My php.ini File?

  • In XAMPP (Windows), the php.ini file is in the C:\xampp\php folder.
  • In XAMPP (Mac OSX), the php.ini file is in the /Applications/XAMPP/xamppfiles/etc folder.

Tips Before Editing php.ini File

Important points BEFORE editing your php.ini file:

  1. IMPORTANT! Open your XAMPP control panel and Stop Apache server before editing the php.ini file.
  2. Make a backup copy of the php.ini file before editing in case anything goes wrong (Name the backup copy php.ini.bak or something similar).
  3. The php.ini file is huge--use a text editor with line numbering, like Brackets (or Notepad++ for Win).
  4. Lines that begin with a semicolon (;) are comments and are ignored by PHP.

Modify php.ini for XAMPP 7.4.8

In this version of the php.ini file, there are only two directives that must be modified. (Three directives in Mac OS X) However, you should still verify all the following directives are correct in your php.ini file. Directives in the following table are organized by line number.

Recommended Apache Server Settings for PHP by line number
Directive Local Value Line # (Win) Line # (Mac)
short_open_tag Off 187 228
error_reporting E_ALL | E_STRICT 463 516
display_errors On 480 533
log_errors On 501 554
file_uploads On 833 877
upload_tmp_dir (Win) C:\xampp\tmp
(OS X) /Applications/XAMPP/xamppfiles/temp
838 883
allow_url_fopen On 853 894
allow_url_include Off 857 898
date.timezone America/Chicago 1969 1040
  1. Open your php.ini file in Brackets (or other text editor with line numbering) and make the necessary changes.
  2. (Mac OS X only) Line 228 (short_open_tag) should be as follows:
    short_open_tag = Off
  3. Line 463 or 516 (error_reporting) should be as follows: (Note: the value is case sensitive so be sure to type in all caps. Use the pipe character SHIFT + \ for separator.)
    error_reporting = E_ALL | E_STRICT
  4. Line 1969 or 1040 (date.timezone) should be as follows:
    date.timezone = America/Chicago
  5. Save and close the php.ini file.
  6. In XAMPP Control Panel, restart your Apache server.
  7. To check the changes to your PHP configuration settings, type http://localhost in address bar of a browser to open the XAMPP dashboard.
  8. In the XAMPP dashboard, click PHPinfo link to display your current settings. Compare your values to the Recommended PHP Core directives table.
  9. When your php.ini file is configured correctly, you're ready to work on projects in your htdocs directory.
    • c:\xampp\htdocs (Win)
    • /Applications/xampp/htdocs (Mac OSX)
  10. (Optional) If you want to use PHP includes and site root relative links in your projects, review Setup Virtual Hosts with XAMPP.