-2

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

Cass
  • 1
  • 1

2 Answers2

1

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

micah
  • 974
  • 6
  • 11
1

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.

Lukas
  • 267
  • 1
  • 4
  • 16