1

I have a problem in index.php. When i try to run the application i get the text of index.php in the browser.

I am using ubuntu. I recently switched from windows where application was working fine with xampp. Following is the screenshot of my directory structure.

enter image description here

Following is the .htaccess file.

<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

And following is the screenshot of index.php file in the browser. enter image description here

1
  • Then there is no php on your server or it is not active. Commented Oct 20, 2015 at 9:26

1 Answer 1

1

You have to config your apache2 to install and enable mod_php

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo a2enmod php5

sudo /etc/init.d/apache2 restart

Nothing to do with .htaccess file as it work fine, notice that it get index.php as it's intended but apache dont know how to intepret php file, hence it output as raw text.

Regards,

Sign up to request clarification or add additional context in comments.

2 Comments

i followed the above but the problem still there. My PHP version is 5.5.9.
Ah, I forgot to mention you have to enable php by run this command sudo a2enmod php5 and then restart apache2. Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.