- Whether or not display_errors is on
- The default level of error reporting
- The Unicode settings
- Support for the Improved MySQL Extension functions
- SMTP values for sending emails
What each of these means—if you don’t already know—is covered in the book’s chapters and in the PHP manual. But for starters, I would highly recommend that you make sure that display_errors is on. Changing PHP’s configuration is really simple. The short version is: edit the php.ini file and then restart the Web server. But because many different problems can arise, I’ll cover configuration in more detail. If you are looking to enable support for an extension, like the MySQL functions, the configuration is more complicated.
To configure PHP:
1. Run a phpinfo() script in your Web browser.
2. In the resulting page, look for the line that says “Configuration File(php.ini Path”.It should be about six rows down in the table.
3. Note the location of your php.ini file. This will be the value listed on the line mentioned in Step 2 (it’ll be found in the right-hand column). This is the active configuration file PHP is using. Your server may have multiple php.ini files on it, but this is the one that counts.
4. Open the php.ini file in any text editor. If you are using Mac OS X, you do not have easy access to the php.ini directory. You can either use the Terminal to access the file, open it using BBEdit’s Open Hidden option, or use something like TinkerTool to show hidden files in the Finder. If you go to the directory listed and there’s no php.ini file there, you’ll need to download this file from the PHP Web site (it’s part of the PHP source code).
5. Make any changes you want, keeping in
mind the following:
- Comments are marked using a semicolon. Anything after the semicolon is ignored.
- Instructions on what most of the settings mean are included in the file.
- The top of the file lists general information with examples. Do not change these values! Change the settings where they appear later in the file.
- For safety purposes, don’t change any original settings. Just comment them out (by preceding the line with a semicolon) and then add the new, modified line afterward.
- Add a comment (using the semicolon) to mark what changes you made and when.
; unicode.semantics = Off
; Next line added by LEU
unicode.semantics = On
6. Save the file.
7. Restart the Web server (Apache, IIS, Xitami, etc.). You do not have to restart the entire computer, just the Web serving application (Apache, IIS, etc.). How you do this depends upon the application being used, the operating system, and the installation method. Windows users can use the XAMPP Control Panel. Mac OS X users can stop and then start Personal Web Sharing (under System Preferences > Sharing). Unix users can normally just enter apachectl graceful in a Terminal window.
8. Rerun the phpinfo.php script to make sure the changes took effect.
- Any changes to PHP’s (or Apache’s) configuration file do not take effect until you restart Apache. Always make sure that you restart the Web server to enact changes!
- Editing the wrong php.ini file is a common mistake. This is why I recommend that you run a phpinfo.php script to see which php.ini file PHP is using.