I had Apache2 running on my local ubuntu machine and I installed nginx & hhvm on my local for debugging purposes by following this tutorial.

I would now like to switch back to Apache2 as I had it before, previously I had both Apache & NGINX with PHP5-FPM running and I could switch between them by running:

sudo service nginx stop
sudo service apache2 restart

Now when I try this I get the below error when I try to access my Magento app

/var/www/app/Mage.php was not found

I can however see the default Ubuntu Apache page when I go to http://localhost/

I tried running

~:$ sudo service nginx stop
~:$ sudo service hhvm stop
~:$ sudo service apache2 restart 
 * Restarting web server apache2                                                               [ OK ] 
~:$ sudo service php5-fpm restart 
stop: Unknown instance: 
php5-fpm start/running, process 12258
~:$ sudo service php5-fpm restart 
php5-fpm stop/waiting
php5-fpm start/running, process 12281

And now I get a 503 service unavailable error when I try to access my Magento app in the browser. I know in Magento this error can be caused by a maintenance.flag file in the Magento root directory but this is not the case here.

My Apache error log says:

[Sat Jun 27 11:11:07.902430 2015] [proxy:error] [pid 12223] (111)Connection refused: AH00957: FCGI: attempt to connect to (*) failed
[Sat Jun 27 11:11:07.902490 2015] [proxy_fcgi:error] [pid 12223] [client] AH01079: failed to make connection to backend:[Sat Jun 27 11:11:07.902430 2015] [proxy:error] [pid 12223] (111)Connection refused: AH00957: FCGI: attempt to connect to (*) failed
[Sat Jun 27 11:11:07.902490 2015] [proxy_fcgi:error] [pid 12223] [client] AH01079: failed to make connection to backend:

When I installed HHVM I ran it's install_fastcgi.sh script. Could that be what is causing the issue.

Any idea on how I can switch between NGINX to Apache and not use HHVM on my local.


I tried @mboehn solution below and now I'm getting the original error in the browser when I navigate to my Magento apps URL

enter image description here

This should be looking in /var/www/magento/app/ for Mage.php. And index.php is in /var/www/magento/. The start of index.php is:

 * Compilation includes configuration file
define('MAGENTO_ROOT', getcwd());

$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';

But this is how Magento apps normally run and I made no changes here. Just installed HHVM and stopped it to revert back to my previous Apache config.

There is nothing in the /var/log/apache2/error.log.

In I have:

<VirtualHost *:80>
DocumentRoot /var/www/magento
ServerName http://dev.magento.local
DirectoryIndex index.php
<Directory /var/www/magento>
AllowOverride All
Allow from All

2nd Update

Ok so there was a index.php in the /var/www/ path that was throwing me off, it was just a copy of something I had been working on ages ago that hadn't caused a problem before.

After removing it I get the bellow message in my browser.

File not found.

And now in my apache error log it says [Sat Jun 27 12:33:58.382270 2015] [proxy_fcgi:error] [pid 16003] [client] AH01071: Got error 'Primary script unknown\n'

  • Are you sure that the path /var/www/app/ isn't set somewhere in for example index.php? I believe you should have seen an error in Apache's error.log if it were Apache that returned a 404 (file not found) error.
    – mboehn
    Jun 27, 2015 at 11:13
  • @mboehn it's not a 404 error just a message in the browser. I updated my question with more details. The Magento App is the same as it has always been and it works with HHVM. I need to swicth back to apache as an important product import plugin for Magento does not work with HHVM.
    – Holly
    Jun 27, 2015 at 11:24
  • I'm not sure why, but index.php believes it's being run from /var/www, and that probably means that it is. I would have checked that there isn't a copy or link of index.php in /var/www, and that my HTTP request is actually hitting the Apache configuration that I want it to (and not ie. the default one pointing to /var/www). If you request dev.magento.local/unknownXYZ you should see the path Apache looks for in error.log
    – mboehn
    Jun 27, 2015 at 11:30
  • @mboehn, that was it had a stray index.php file in /var/www/. No I have a message in my error log [Sat Jun 27 12:33:58.382270 2015] [proxy_fcgi:error] [pid 16003] [client] AH01071: Got error 'Primary script unknown\n'
    – Holly
    Jun 27, 2015 at 11:39
  • I'm guessing you have an Apache configuration file point to /var/www as the DocumentRoot. The Apache configuration you've pasted, did you replace the default configuration (/etc/apache/sites-available/default) with it, or did you make another file (now in /etc/apache/sites-enabled/)? You might need to disable the default-site configuration.
    – mboehn
    Jun 27, 2015 at 11:44

2 Answers 2


You might have php5-fpm listening on a unix socket (like /var/run/php5-fpm.sock, while Apache tries to connect to

Check the listen-directive in your php5-fpm configuration (I'm guessing /etc/php5/fpm/pool.d/www.conf). And then either configure Apache to use the unix socket or reconfigure both php5-fpm and nginx to use network sockets (a port)

  • Make php5-fpm use port 9000:
    • In /etc/php5/fpm/pool.d/www.conf, replace listen = /var/run/php5-fpm.sock with listen =
  • Apache already uses port 9000
  • Make ngnix use port 9000:
    • In /etc/nginx/sites-available/default (this is the default file, you might be using another file in the same directory), replace fastcgi_pass unix:/var/run/php5-fpm.sock; with fastcgi_pass;
  • in www.conf I have listen = /var/run/php5-fpm.sock. I want to swicth back to apache, should I configure this to use a port? How? Sorry I'm new to server config.
    – Holly
    Jun 27, 2015 at 10:44
  • why would installing hhvm have changed it.
    – Holly
    Jun 27, 2015 at 10:48
  • I've explained more in my answer now. Exactly why installing hhvm changed this I'm not sure of, but I don't know what the script install_fastcgi.sh does. It seems that having php5-fpm use unix sockets is the default these days.
    – mboehn
    Jun 27, 2015 at 10:55
  • thanks I tried that but it gave me the original error I was getting before. I updated my question.
    – Holly
    Jun 27, 2015 at 11:05

Solved it :)

When I installed HHVM I ran the below shell script which set HHVM and changed some configurations.

sudo /usr/share/hhvm/install_fastcgi.sh

I'm not sure exactly what this did but I'm almost certain it is what caused the issue as when I ran the below uninstall script which also comes with HHVM it fixed everything and now Apache works also.

$ sudo /usr/share/hhvm/uninstall_fastcgi.sh

Your Answer

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

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