2.4 Configuring PHP


After you have successfully installed PHP, you can start configuring the package. This is essential because the default setting will not always satisfy your demands. The configuration file of PHP is called php.ini. The location of this file depends on how and where you have installed PHP. If you are using Red Hat's standard packages, the file is located in /etc/php.ini.

In this section, you will take a closer look at this configuration file and all relevant settings will be discussed extensively. The various entries are described in the same order they occur in the configuration file of PHP 4.1:

  • engine To enable PHP to use it, this flag has to be set to On. The word engine refers to the Zend engine, which is the core of PHP 4.

  • short_open_tag If short tags are enabled, the Web server will accept <? and ?> in addition to <?php and <script>. To make your scripts more portable, we recommend using <?php for defining the beginning of a PHP script because otherwise you might run into trouble if you want to run your script on a server where short tags are turned off.

  • asp_tags ASP (Active Server Pages; these are the ones many people use when working with IIS) supports <% %> tags, which have the same meaning as <?. In the default configuration this kind of tag is turned off.

  • precision PHP supports variable floating-point precision.

  • y2k_compliance Enforces Y2K compliance. This can cause trouble with non-Y2K compliant browsers. The default value is Off.

  • output_buffering Output buffering allows you to send header lines after you send body content. By default this setting is set to Off in order to achieve higher performance.

  • output_handler The output of a script can be sent to a function. This way various operations such as filtering and compression can be done.

  • zlib.output_compression If this flag is set to On, transparent output compression will be used.

  • implicit_flush This flag tells the output layer to flush the buffers after every block.

  • safe_mode PHP's safe mode is an attempt to achieve a higher level of security. When working with safe mode, some PHP functions such as system for performing system calls and pg_loimport (responsible for working with binary objects stored in a PostgreSQL database) are disabled.

  • open_basedir This flag can be used to restrict all file operations outside the directory defined by this flag.

  • disable_functions Some functions that are still beta or that are a potential threat for your system can be disabled by this flag. The functions have to be defined as a comma-separated list.

  • max_execution_time To prevent problems caused by endless loops or scripts that take too long to execute, you can define the maximum time a script is allowed to run. As soon as the time limit is reached, a script will be terminated immediately.

  • memory_limit The memory consumption of PHP scripts can be limited by the size defined by the memory_limit script. The size is defined in megabytes. Every PHP script running may consume this amount of memory.

  • error_reporting Defines the way errors are displayed by PHP. Depending on how much debugging information you need, this flag can be modified to your needs.

  • display_errors Tells PHP whether to display errors. The default value of this flag is On.

  • display_startup_errors Errors can occur when PHP starts up. In the default configuration, these errors are not displayed.

  • log_errors For debugging purposes it is useful to set this flag to On because otherwise, errors won't be logged.

  • track_errors Stores the most recent error message in $php_errormsg.

  • arg_separator.input By default the arguments passed to PHP via a URL are separated using a &. This can be changed by modifying this setting.

  • variables_order Defines in which order GET, POST, cookie, environment, and built-in variables are registered. The default value is EGPCS.

  • register_argc_argv Defines whether variables passed to PHP via standard input should be registered.

  • post_max_size POST requests send data to a script. For security reasons, the maximum amount of data should be limited using the post_max_size parameter.

  • default_mimetype By default the header sent to the browser is text/html.

  • enable_dl dl is an important command. If you want to add extensions to PHP without recompiling the server, or if you want to try new versions of a component, shared objects can be included dynamically using the dl command. enable_dl tells PHP whether to support dynamic loading or not.

  • file_uploads File uploads are a potential security threat and they can easily be disabled by setting file_uploads to Off.

  • upload_max_filesize The maximum size of a file uploaded to the Web server can be defined in two ways. One way is to add a parameter to the HTML document. The second and more secure way to do the job is to tell PHP how big a file is allowed to be.

  • extension Windows extensions can easily be added to the server by adding an entry pointing to a DLL.

  • odbc.allow_persistent This flag tells PHP whether it is allowed to use persistent database connections in combination with ODBC.

  • odbc.check_persistent To find out if a persistent connection is still valid before reusing the connection handle, this flag must be set to On.

  • odbc.max_persistent Defines the maximum number of simultaneous persistent connections. -1 means unlimited.

  • odbc.max_links Defines the total number of connections allowed (total = persistent + nonpersistent).

  • pgsql.allow_persistent This flag tells PHP whether it is allowed to use persistent database connections in combination with PostgreSQL.

  • pgsql.max_persistent Defines the maximum number of simultaneous persistent connections. -1 means unlimited.

  • pgsql.max_links Defines the total number of connections allowed (total = persistent + non-persistent).

  • session.save_handler Tells PHP which handles are used for managing sessions.

  • session.save_path Defines the directory where session information is stored. The default value is /tmp.

  • session.use_cookies Defines whether to use cookies.

  • session.name Defines the name of the session.

If you make changes in the configuration file of PHP, it is necessary to know when the changes take place. Usually the configuration file is read when PHP starts up. If PHP is used as a module of the Web server, the file is read when the server is started. Therefore you have to restart your server in order to make changes that affect your system. With CGI scripts, the configuration is read every time a CGI script is started.



PHP and PostgreSQL. Advanced Web Programming2002
PHP and PostgreSQL. Advanced Web Programming2002
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 201

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net