0

I've configured my Apache with an alias to another directory in the httpd.conf like this:

Alias <a_dir> "<full path>"

This works fine for regular HTML documents like <a_dir>/home.html, but PHP-files like <a_dir>/script.php are not processed on the server (i.e. servered to the browser as a regular text-file).

As far as I can tell, PHP is properly installed - in the "normal" directory the files are processed. I've tried to also include a ScriptAlias, but that didn't change anything.

What am I missing?

IronGoofy
  • 201
  • 1
  • 2
  • 7

2 Answers2

1

Can you provide any error messages you're seeing in /var/log/apache2/access.log(or whatever path you're using)? I have just tried this on my ubuntu maverick box with the following:

Alias /a_dir/ "/home/USERNAME/phptest/index.php"

my index.php contains simply:

<?php
phpinfo()
?>

Let me have a look at the errors and access logs and should be able to know more

vsltd
  • 486
  • 2
  • 2
  • I'm not getting any errors, the file is simply served as a text file adn nothing is displayed in the browser. The access log only has the line ::1 - - [12/Apr/2011:11:04:49 +0200] "GET /smartersoftware/index.php HTTP/1.1" 200 19 – IronGoofy Apr 12 '11 at 09:06
  • what does index.php look like? – vsltd Apr 12 '11 at 09:23
  • Just like the one you had in your answer. – IronGoofy Apr 12 '11 at 09:47
  • Could you share the httpd.conf or apache2.conf? I'm new here so not sure about where this would go but imagine [pastie](http://pastie.org/ ) would be best. – vsltd Apr 12 '11 at 09:54
  • It's pretty much a common httpd.conf file see for yourself at http://pastie.org/1786253 – IronGoofy Apr 12 '11 at 10:16
  • you're right - it does look standard. Can you check that: 'log_errors=On display_startup_errors=On' This is within your php.ini – vsltd Apr 12 '11 at 10:38
  • I did those changes, now I found [Tue Apr 12 13:59:59 2011] [warn] Cannot get media type from 'x-mapp-php5' in the error_log. – IronGoofy Apr 12 '11 at 12:02
  • Add this underneath: AddType application/x-httpd-php .php `AddType application/x-mapp-php5 .php` – vsltd Apr 12 '11 at 14:28
  • This didn't change anything .. where is x-mapp-php5 coming from? I thought that .php would already be mapped to x-httpd-php?! – IronGoofy Apr 12 '11 at 17:52
  • glad you got sorted. – vsltd Apr 12 '11 at 21:27
0

The alias was workking fine, it seems that I needed the following lines in my config:

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

With this, the php-file is properly processed. I'm not sure why php-files in another directory worked fine without it, but it looks like everything is working now.

IronGoofy
  • 201
  • 1
  • 2
  • 7