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 on both XAMPP (Windows) and MAMP (Mac). 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 directives for test server

This table contains the recommended test server settings for PHP Core and Date sections for both XAMPP (Win) and MAMP (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 Off
short_open_tag Off
upload_tmp_dir C:\xampp\tmp
/Applications/MAMP/tmp/php
date section
Default timezone
America/Chicago

 

Where Is My php.ini File?

  • If you installed XAMPP on Windows, the php.ini file is in the C:\xampp\php folder.
  • If you installed MAMP 2.1.1 on Mac, the php.ini file is in the /Applications/MAMP/bin/php/php5.4.4/conf folder.

Tips Before Editing php.ini File

Important points BEFORE editing your php.ini file:

  1. IMPORTANT! Open your XAMPP or MAMP 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 Notepad++ (Win), or TextWrangler (Mac). NOTE: To turn on line numbering in TextWrangler, choose View > Text Dislay > Show Line Numbers
  4. Lines that begin with a semicolon (;) are comments and are ignored by PHP.
  5. If it's helpful, download the php.ini.txt instruction file for XAMPP version 5.6.28-0.

Check Your PHP Settings with XAMPP (Windows):

  1. Open XAMPP Control Panel and Start Apache server. If you don't have a Desktop or Quick Launch icon, go to Start > All Programs > XAMPP > XAMPP Control Panel.
    XAMPP Control Panel
  2. Click the Admin button next to Apache (or type http://localhost in address bar of a browser) to open the XAMPP for Windows page in your default browser.
    XAMPP Control Panel with Apache running
  3. Click PHPInfo in navigation bar (top left) to display your current settings.
    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.
    PHP Info
  5. Open XAMPP Control Panel and Stop Apache server.

Modify php.ini for XAMPP 5.6.28-0 (Windows)

In this version of the php.ini file, there are only three directives that must be modified. Woohoo! 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 Test Server Settings for PHP by line number
Directive Local Value Line #
short_open_tag Off 202
error_reporting E_ALL | E_STRICT 449
display_errors On 466
log_errors Off 487
file_uploads On 811
upload_tmp_dir C:\xampp\tmp 816
allow_url_fopen On 831
allow_url_include Off 835
safe_mode Off 933
register_globals Off 938
register_long_arrays Off 939
magic_quotes_gpc Off 940
date.timezone America/Chicago 2025

 

  1. Open your php.ini file in Notepad++ (or other text editor with line numbering) and make the necessary changes.
  2. Line 449 (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
  3. Line 487 (log_errors) should be as follows:
    log_errors = Off
  4. Line 2025 (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 PHP configuration settings, click Admin button next to Apache (or type http://localhost in address bar of a browser) to open the XAMPP for Windows page in your default browser.
  8. In the XAMPP for Windows page, click phpinfo() link (PHP category in left column) 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 Setup Virtual Hosts with XAMPP.

Check Your PHP Settings with MAMP (Mac):

  1. Open MAMP Control Panel and click Start Servers to start your Apache and MySQL servers.
    MAMP Control Panel
  2. In the Control Panel, click Open WebStart Page (opens in your default browser).
  3. In the Start page, click phpinfo link (or phpinfo tab) to display your current settings. Compare your Core and date values to those in the Recommended PHP Core directives for test server table.
  4. Open MAMP Control Panel and click Stop Servers.

Modify php.ini for MAMP 2.1.1 (Mac)

In MAMP, there are six directives that must be modified. Directives in the following table are organized by line number.

Recommended Test Server Settings for PHP by line number
Directive Local Value Line #
short_open_tag Off 76
safe_mode Off 158
error_reporting E_ALL | E_STRICT 270
display_errors On 277
log_errors Off 287
register_globals Off 365
magic_quotes_gpc Off 379
file_uploads On 473
upload_tmp_dir /Applications/MAMP/tmp/php 478
allow_url_fopen On 489
date.timezone America/Chicago 549

 

  1. Open your php.ini file in TextWrangler (or other text editor with line numbering) and make the necessary changes.
  2. Line 76 (short_open_tag) should be as follows:
    short_open_tag = Off
  3. Line 270 (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 277 (display_errors) should be as follows:
    display_errors = On
  5. Line 287 (log_errors) should be as follows:
    log_errors = Off
  6. Line 379 (magic_quotes_gpc) should be added as follows:
    magic_quotes_gpc = Off
  7. Line 549 (date.timezone) should be as follows:
    date.timezone = America/Chicago
  8. Save and close the php.ini file.
  9. Open MAMP Control Panel and click Start Servers to restart Apache and MySQL servers.
  10. To check the PHP configuration settings, click Open Start Page.
  11. In the Start page, click phpinfo link to display your current settings. Compare your values again to the Recommended PHP Core directives table.
  12. When your php.ini file is configured correctly, you're ready to Setup Virtual Hosts on MAMP. See instructions in Using MAMP to Setup a Local Testing Server.