5.5. Configuring Your Development Environment

Apache, MySQL, and PHP can be configured. Their configuration settings are stored in text files, which you can edit. When XAMPP installs the software, it creates configuration files with default settings so that the software runs with common settings. However, you might need to change the configuration for various reasons. Configuration settings are described throughout the book when the particular feature being configured is discussed.

NOTE

XAMPP installs all the software in the directory you designated during installation, such as c:xampp, which is the default directory. XAMPP configures the software to look for the configuration files in this directory. If you need to change any configuration settings, you must edit the configuration files in this directory, not in the directories that are mentioned in help files or other documentation for the individual software.

5.5.1. Configuring PHP

PHP uses settings in a file named php.ini to control some of its behavior. PHP looks for php.ini when it begins and uses the settings that it finds. If PHP can't find the file, it uses a set of default settings.

XAMPP stores the php.ini file in the apachein directory in the main XAMPP folder. For example, if XAMPP is located in the default directory, you edit the file c:xamppapacheinphp.ini to change PHP configuration settings.

To configure PHP, follow these steps:

  1. Open the php.ini file for editing in a text editor.

  2. Edit the settings you want to change.

    Steps 3 and 4 mention some specific settings that you should always change if you're using the specified environment.

  3. Only if you're using PHP 5 or earlier, turn off magic quotes.

    Look for the following line:

    magic_quotes-gpc On

    Change On to Off.

  4. Only if you're using PHP 5 or later, set your local time zone.

    Find the line:

    ;date.timezone =

    Remove the semicolon from the beginning of the line. Add the code for your local time zone after the equal sign. For instance, the line might be

    date.timezone = America/Los_Angeles

    You can find a list of time zone codes at www.php.net/manual/en/timezones.php.

  5. Save the php.ini file

  6. Restart Apache so that the new settings go into effect.

In general, the remaining default settings allow PHP to run okay, but you might need to edit some of these settings for specific reasons. We discuss settings in the php.ini file throughout this book when we discuss a topic that might require you to change settings.

5.5.2. Configuring Apache

The Apache configuration settings are stored in a file named httpd.conf. This file needs some directives in order for PHP to work. XAMPP adds these directives when it installs the software so you don't need to configure Apache to make PHP work.

You can change some of Apache's behavior with directives in the httpd.conf file. For instance, you can change where Apache looks for Web page files and what port number Apache listens on. Some of the directives you can change are described in Chapter 4 of this minibook. All the Apache directives are described in the Apache Web site at httpd.apache.org.

To change the configuration for Apache that was installed using XAMPP, you need to find the httpd.conf file in the apacheconf folder in the main folder where XAMPP was installed. For instance, if XAMPP is installed in the default directory, the Apache configuration file is c:xamppapacheconfhttpd.conf.

5.5.3. Configuring MySQL

MySQL creates a configuration file when it's installed. Most people don't need to change the MySQL configuration. However, you might want to change it in order to store your MySQL databases somewhere other than the default location. In fact, the XAMPP installation configures MySQL to look for the data directory in the XAMPP directory, which isn't the default location for MySQL, so XAMPP configures its data directory setting for you. If you want to store your data in a different location, you can change the setting yourself. Instructions for changing the configuration for MySQL are provided in Chapter 3 of this minibook.

To change the configuration for MySQL that was installed using XAMPP, you need to find the my.cnf file in the mysqlin folder in the main folder where XAMPP was installed. For instance, if XAMPP is installed in the default directory, the MySQL configuration file is c:xamppmysqlinmy.cnf.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.210.12