Asked  11 Months ago    Answers:  5   Viewed   10 times

On my new Ubuntu system, I've managed to get Apache2 up and running for developing my ZendFramework Web Applications...

I've got my available-sites config working correctly because I am able to request localhost and it servers up the correct index.html from my specified directory.

Problem : if I request index.php, firefox attempts to download the file instead of running the script.

Any Ideas why this would happen?

I've added the following to httpd.conf but it hasn't helped.

AddHandler application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml

AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml



If Firefox downloads your PHP files it means that your server doesn't have PHP or the Apache PHP module installed.

Have you installed the Apache PHP module? If not then install it by typing this into a terminal:

sudo apt-get install libapache2-mod-php5

And if yes, do you have your index.php located in /var/www/?

Make sure to enable PHP with the command

sudo a2enmod php5
Friday, July 2, 2021

Finally, thanks to the comment of Ed de Almeida, I found the solution.

I had to install an additional package:

$ sudo apt-get install libapache2-mod-php7.0

Now I could run sudo a2enmod php7.0.

Saturday, May 29, 2021

The two servers should be configured to listen on different ports if you want them both available on the same host.

  • Instructions for changing ports for Apache2 on Ubuntu
  • Instructions for changing ports for Apache Tomcat on Ubuntu

Now, if you've configured Apache to listen on 80 and Tomcat to listen on port 8080, you should be able to access them at http://localhost:80 (or just http://localhost) and http://localhost:8080 respectively.

You should ensure both the servers are actually up as well. netstat -npl | grep :8080 and netstat -npl | grep :80 should help you identify what processes are bound to these two ports. If the ports are bound but don't say java or apache2, you've got some other process listening on these ports and that's going to stop the server that tries to bind to that port from starting up.

For Apache2, you could also run service apache2 status to see what the status is.

If however, you want to run both servers bound to the same port( perhaps 80) then as you seem to have guessed, you'll have to stop the other.

  • To stop Apache2, execute the command service apache2 stop
  • Stopping Tomcat depends on how you started it. You might simply run the script in ${CATALINA_HOME}/bin i.e. the bin directory in your Tomcat installation folder.


You will [probably] need to execute the commands as root so you'll need to prefix sudo.

Saturday, May 29, 2021

Thanks to my friend, I quickly found a solution. I simply added :

RewriteRule ^/php5-fcgi - [L]

To my vhost configuration :

RewriteEngine on  
RewriteRule ^/rsrc/(.*)     -    [L,QSA]  
RewriteRule ^/favicon.ico   -                       [L,QSA] 
RewriteRule ^/php5-fcgi     -                       [L]  
RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]


Saturday, May 29, 2021

After some more research, I've got it figured out. Here is the solution for anyone having the same problem:

Since localhost belongs to the www-data group, I just added my user to that group.

sudo usermod -a -G www-data my_username

Then, I added the folder to the group.

sudo chgrp -R www-data /var/www

Then, I gave write permissions to the www-data group.

sudo chmod -R g+w /var/www

This worked for me without any other issue. Thanks!

Thursday, July 22, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :