Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

GATEWAY_INTERFACE CGI/1.1

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.

2 Answers 2

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: http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler

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.