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

I just ran sudo apt-get install lamp-server^ on my Ubuntu 11.04 Desktop computer to get my localhost server up and running. Now when I type in localhost to my web browser it only shows .html files that are in the var/www/ folder and not php. When I try to view a php file, it only "downloads" the file.

Any idea what's happening here?

000-default file:

ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

share|improve this question
    
There are so many "PHP scripts are downloaded, not executed" questions here already... –  womble Aug 2 '11 at 0:12

2 Answers 2

Do you see php5.conf and php5.load under /etc/apache2/mods-enabled/? If not then enable it with sudo a2enmod php5. If yes then sudo /etc/init.d/apache2 restart.

For any other suggestion we need more information. For example the file /etc/apache2/sites-enabled/000-default

share|improve this answer
    
see question for the contents of 000-default –  jollypianoman Aug 1 '11 at 21:53
1  
are you sure that you have installed package libapache2-mod-php5? –  mailq Aug 1 '11 at 22:04
    
it's already installed. –  jollypianoman Aug 1 '11 at 22:35

It sounds like the PHP module isn't loaded by apache or apache has not been notified of the handler. Scan through your apache configs and see if there is a LoadModule for php and an AddHandler.

On my system (sorry, it's CentOS, I don't have Ubuntu available), it looks like this:

LoadModule php5_module modules/libphp5.so 
AddHandler php5-script .php
AddType text/html .php

These are present in a seprate config file (/etc/httpd/conf.d/php.conf) provided by the PHP package. I assume Ubuntu handles this more or less the same.

share|improve this answer
    
I don't have a httpd/ folder in my etc/ folder. –  jollypianoman Aug 1 '11 at 21:54
    
@CodeDude On Ubuntu it is probably called /etc/apache2. Ubuntu and CentOS differ slightly –  Sgaduuw Aug 1 '11 at 21:56
    
ah...I see. Well, in that folder I don't have a php.conf file. Maybe php didn't get installed at all? –  jollypianoman Aug 1 '11 at 21:59
    
check a bit further inside the /etc/apache2 tree. If you don't find anything related to PHP, you could try reinstalling the php package(s). –  Sgaduuw Aug 1 '11 at 22:03
    
I'm going to try that. Thanks for your help. –  jollypianoman Aug 1 '11 at 22:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.