On a recent project we needed to provide a client our contribution to the site code base as static .html files. To make the development process easier though a number of the developers wanted to include some of the global page assets such as the header and footer using PHP includes in their development environments. This of course normally does not work as the server never passes the page content to the PHP engine to process as it doesn’t have a .php or .phtml extension.
Archive for the ‘apache’ tag
Executing PHP Code Server Side In .html Files
Logging PHP Errors For Production Environments
Good security practices dictate PHP should be configured to never display error messages and notices to screen in a production environment due to its potential to reveal information about your server and application setup. One solution is to enable error logging on the server by setting the log_errors attribute to 1 in your php.ini and reloading Apache. When active by default all errors will be sent to the Apache error log and will appear similar to the line below, unless a different path has been set in the php.ini configuration file using the error_log directive.
Debugging Apache Mod Rewrite
Sometimes trying to figure out why the hell scripts arent working after trying to get search engine friendly URL’s working with Apache’s rewrite module can be a huge pain in the arse.
One way you can get a bit more insight into what may be broken is by adding the Apache Rewritelog & Rewriteloglevel directives to your apache configuration file.
In my development server the lines are added near the end of the VirtualHost directive, which looks something like:
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
RewriteLog /var/log/apache2/rewrite.log
RewriteLogLevel 3
</VirtualHost>
The rewriteloglevel can be any number between 1 & 9, one being the least verbose looging level and nine the most.
**This will not work on servers if you don’t have access to the main apache configution files i.e shared hosting environments.
XAMPP – Make your Computer a Webserver: Apache, PHP, MySQL
A painfree tutorial on installing the XAMPP bundle to ease the development and testing of your web applications.