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 (Windows and MacOS) 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 directives for both XAMPP 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 On
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?

  • In XAMPP (Windows), the php.ini file is in the C:\xampp\php folder.
  • In XAMPP (MacOS), the php.ini file is in the /Applications/XAMPP/xamppfiles/etc folder
  • In MAMP 2.1.1 (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 7.1.7 (Win).

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 top navigation bar 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 7.1.7

In this version of the php.ini file, there are only two 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 # (Win) Line # (Mac)
short_open_tag Off 197 228
error_reporting E_ALL | E_STRICT 460 516
display_errors On 477 533
log_errors On 498 554
file_uploads On 815 877
upload_tmp_dir C:\xampp\tmp
/Applications/XAMPP/xamppfiles/temp
820 883
allow_url_fopen On 835 894
allow_url_include Off 839 898
date.timezone America/Chicago 1957 1040

 

  1. Open your php.ini file in Notepad++ (or other text editor with line numbering) and make the necessary changes.
  2. (MacOS only) Line 228 (short_open_tag) should be as follows:
    short_open_tag = Off
  3. Line 460 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 1957 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 PHP configuration settings, click Admin button next to Apache (or type http://localhost in address bar of a browser) to open the XAMPP dashboard in your default browser.
  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 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.