Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed Apache and PHP by:

sudo apt-get install apache2
sudo apt-get install php5

Then I created a .htaccess file in /var/www with:

AddHandler application/x-httpd-php5 .html

It parses PHP in .php files just fine, but any PHP in .html files it doesn't.


share|improve this question

closed as not a real question by MDMarra, mdpc, Ward, growse, Scott Pack May 19 '13 at 19:13

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Are you sure you're set up to allow directives in .htaccess files?

Look for the AllowOverride directive in your apache config file. Something like this:

<Directory /var/www/>
      AllowOverride None

You will need to update the AllowOverride line, replacing "None" with "FileInfo". Another option (better IMHO) would be to just update the existing AddHandler line for php to include the .html extension:

AddHandler application/x-httpd-php5 .php .html

Link to Apache documentation:

share|improve this answer
Thanks, but tried both of that and it still doesn't work. – Cass Mar 28 '11 at 17:49

You could install mod-php.

# for Ubuntu
apt-get install mod-php
#for Debian
apt-get install libapache2-mod-php5

The package-name can vary from distro to distro. Use apt-cache search or aptitude search to find the appropriate package.

Next step would be to enable the module in apache:

a2nmod php5

This should create a configfile in /etc/apache2/mods-enabled/ called php5.conf. It should already contain all the configuration you need for a standard installation, so you can remove the AddHandler line from your .htaccess file.

Lastly you should restart your Apache2:

apache2ctl configtest && /etc/init.d/apache2 restart

This will first check the config for errors and only restart Apache2 if everything is all right. Otherwise apache2 could get stopped but be unable to start again.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.