Custom php.ini Ignored


I had finally got around to writing some php scripts again but them came across a big stumbling block: apache2/php5 on opensuse 10.2 refused to read my custom php.ini file. I tried placing it in public_html, virtualhost folders and other locations however php5 still refused to read it. Finally, I edited the directory section of the virtual host I’d created and added the required php options there. For anyone with a similar problem, here is an example of a vhost with php options:
Listen 8090
<VirtualHost _default_:8090>
DocumentRoot "/path/to/files"
<Directory "/path/to/files">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
<IfModule mod_php5.c>
php_value include_path ".:/patch/to/includes:/usr/share/php5"
php_value session.cache_expire "240"
</IfModule>
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
</VirtualHost>
Alternatively, if you are simply wanting to specify options for a specific directory, the following can be used:
<Directory /path/to/files>
<IfModule mod_php5.c>
php_value include_path ".:/patch/to/includes:/usr/share/php5"
php_value session.cache_expire "240"
</IfModule>
</Directory>
If you’re uncertain of where to place these custom configuration files then I recommend you contact your host as the location can vary depending upon the operating system and customisation of the webserver. Although, if like me you’re using opensuse, place the virtual host file in /etc/apache2/vhosts.d/ or the directory file in /etc/apache2/conf.d/ and then restart apache2 (rcapache2 restart as root at a console/terminal).

Share and Enjoy:
  • Digg
  • del.icio.us
  • BlinkList
  • Furl
  • Netscape
  • Reddit
  • StumbleUpon
  • YahooMyWeb




Write a comment:

(Required, but won't be displayed)