Share » Learn » eZ Publish » The eZ publish Web Server Environment

The eZ publish Web Server Environment

Friday 04 August 2006 1:41:00 pm

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Apache and PHP are now installed in the system. Before you start using them you must make some configuration changes in the Apache and PHP configuration files.

PHP configuration

During the PHP installation we told PHP to look in the /usr/local/apache/conf directory for the php.ini configuration file. However, this file does not yet exist. Run the following command to create a new empty configuration file for PHP:

Recommended PHP configuration (php.ini) for eZ Publish

This section shows the recommended contents of the php.ini file located in the /usr/local/apache/conf directory.

; Safe Mode

safe_mode = Off

 
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off

register_globals = Off

allow_call_time_pass_reference = Off

; Maximum amount of memory a script may consume (xMB)
memory_limit = 64M

; Maximum execution time of each script, in seconds
max_execution_time = 90

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

; Whether to allow HTTP file uploads.
file_uploads = On

; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
;open_basedir =

The contents of this snippet are interpreted as follows:

; Magic quotes for incoming GET/POST/Cookie data.

magic_quotes_gpc = Off

"Magic quotes" is a process that automatically escapes incoming data to the PHP script. It is preferred to code with magic quotes off and to instead escape the data as needed at runtime. eZ publish will work with this option enabled. However, it will slightly reduce performance because all input variables must be converted back to normal. Therefore we recommend that the option is turned off.

; Maximum amount of memory a script may consume (xMB)

memory_limit = 64M

The default maximum amount of memory a script may consume is 8 MB. This is too low for eZ publish to run. eZ publish needs at least 64 MB to run the Setup Wizard. Normal operation requires about 16 MB. However, we recommend that you keep the setting at 64 MB, as certain features (such as PDF export and search reindex) use more than 16 MB. Multilingual sites that store the content in Unicode (UTF-8) also require at least 64 MB.

; Maximum execution time of each script, in seconds

max_execution_time = 90

Depending on your hardware configuration, the execution time of some operations (like template compilation or parsing translation files) might take more than the default 30 seconds. We recommend that you increase the maximum execution time to at least 90 seconds. If you get output similar to the following , your max_execution_time setting is too low:

Fatal error: Maximum execution time of 30 seconds exceeded in ...

Fatal error: eZ publish did not finish its request

The execution of eZ publish was abruptly ended, the debug output is presented below.

Apache configuration

Once the PHP settings are configured, you must configure the Apache web server. Edit the httpd.conf file to load the PHP module. The Apache configuration file is located by default in the conf/ directory of the Apache installation (/ usr/local/apache/conf).

The LoadModule statement must point to the path of the PHP module on your system, usually libexec/libphp4.so under the Apache installation directory. The make install routine may have already added LoadModule for you in the httpd.conf, but check just in case.

LoadModule php4_module libexec/libphp4.so

Next we need to tell Apache to parse specific extensions as PHP scripts. The most common configuration is to tell Apache to parse the .php extension as PHP. You can assign any extension to PHP by simply adding more extensions to the list, with each extension separated by a space.

AddType application/x-httpd-php .php

It is also common to configure the .phps extension to show highlighted PHP source. This can be done as follows:

AddType application/x-httpd-php-source .phps

Virtual host configuration

By making use of virtual hosts, it is possible to have several sites running on the same server. The sites are usually differentiated by the domain name by which they are accessed. Apache will look for a specified set of domains and use different configuration settings based on the domain that is requested.

Virtual hosts are usually defined at the end of the httpd.conf configuration file, which is the main configuration file for Apache. To add a virtual host for eZ publish, copy the following lines and replace the text encapsulated by the square brackets with actual values. The next section has a real-life example of using virtual hosts.

Virtual hosts configuration example for eZ publish:

NameVirtualHost [IP_ADDRESS]

<VirtualHost [IP_ADDRESS]:[PORT]>
   <Directory [PATH_TO_EZPUBLISH]>
       Options FollowSymLinks
       AllowOverride None
   </Directory>

   <IfModule mod_php4.c>
       php_admin_flag safe_mode Off
       php_admin_value register_globals 0
       php_value magic_quotes_gpc 0
       php_value magic_quotes_runtime 0
       php_value allow_call_time_pass_reference 0
   </IfModule>

   DirectoryIndex index.php

   <IfModule mod_rewrite.c>
       RewriteEngine On
       Rewriterule ^/var/storage/.* - [L]
       Rewriterule ^/var/[^/]+/storage/.* - [L]
       RewriteRule ^/var/cache/texttoimage/.* - [L]
       RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L]
       Rewriterule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
       Rewriterule ^/share/icons/.* - [L]
       Rewriterule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
       Rewriterule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
       RewriteRule ^/packages/styles/.+/thumbnail/.* - [L]
       RewriteRule ^/favicon\.ico - [L]
       RewriteRule ^/robots\.txt - [L]
       # Uncomment the following lines when using popup style debug.
       # RewriteRule ^/var/cache/debug\.html.* - [L]
       # RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L]
       RewriteRule .* /index.php
   </IfModule>

   DocumentRoot [PATH_TO_EZPUBLISH]
   ServerName [SERVER_NAME]
   ServerAlias [SERVER_ALIAS]

</VirtualHost>

The pertinent settings are interpreted as follows:

[IP_ADDRESS] The IP address of the virtual host, for example "128.39.140.28". Apache allows the use of wildcards here ("*").
[PORT] The port on which the web server listens for incoming requests. This is an optional setting; the default port is 80. The combination of an IP address and a port is often referred to as a "socket". Apache allows the use of wildcards here ("*").
[PATH_TO_EZPUBLISH] The path to the directory that contains eZ publish. This must be the absolute path, for example " /var/www/ezpublish".
[SERVER_NAME] The host or IP address that Apache should look for. If a match is found, the virtual host settings will be used.
[SERVER_ALIAS] Additional hosts / IP addresses that Apache should look for. If a match is found, the virtual host settings will be used.

Note that the mod_rewrite module must be enabled in httpd.conf in order to use the Rewrite Rules.

36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)