views:

376

answers:

3

Hi,

I have a problem with apache2 settings (Ubuntu system). I would like to run symfony project on my localhost but instead of serving .phtml files, browser is trying to download files.

alt text

this is my file .host:

127.0.0.3 test

this is apache2/sites-available/default file

< VirtualHost 127.0.0.3:80>
ServerName test DocumentRoot "/home/m/Pr/workspace/php/test/web"

DirectoryIndex frontend_dev.php

< Directory "/home/m/Pr/workspace/php/test/web">

AllowOverride All

Allow from All   

Alias /sf

/home/m/Pr/workspace/php/test/lib/vendor/symfony/data/web/sf

< Directory

"/home/m/Pr/workspace/php/test/lib/vendor/symfony/data/web/sf">

AllowOverride All

Allow from All   </Directory>

and this is .htaccess in /test

RewriteEngine On RewriteRule ^(.*)$

/web/$1 Options +FollowSymLinks

+ExecCGI AddHandler application/x-httpd-php5 .php .phtml

and this is .htaccess in /test/web

Options +FollowSymLinks +ExecCGI


RewriteEngine On

# uncomment the following line, if you are having trouble # getting no_script_name to work RewriteBase /

# we skip all files with .something #RewriteCond %{REQUEST_URI} ..+$ #RewriteCond %{REQUEST_URI} !.html$
#RewriteRule .* - [L]

# we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]

Another problem is I think apache don't read .htaccess files.

What am i doing wrong? Maybe I forgot about something? Please, help me becouse i have no idea.

A: 

Check the Content-Type headers the server is sending for the .phtml files - chances are it's something the browser doesn't recognise.

Colonel Sponsz
Thanks for replay, could you please say more about your suggestion? In source of page i have only this:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body></body></html>But i think You have something else in mind?
pmoniq
You need to use Firebug (or similar) to check the "Content-Type" header the server is sending with the request - this doesn't show up in the page. See http://en.wikipedia.org/wiki/List_of_HTTP_headers#Responses and http://www.php.net/manual/en/function.header.php
Colonel Sponsz
A: 

yes I don't remember Apache to be prepared for serving phtml files out-of-the-box.

I think you need to assert Content-Type is defined to text/html for the browser to render the file.

Benoit
+2  A: 

You need to declare the AddType directive in your Apache config - I'm not sure adding it to .htaccess will work.

Add this line to either /etc/apache2/mods.enabled/php.conf or /etc/apache2/httpd.conf:

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

Restart Apache and retry.

Raise