0

I was having some problems with apache2 in Ubuntu and decided to uninstall and reinstall it. The problem now is that when I try

which apache2

or even

sudo service apache2 start

I get absolutely no response. I tried inspecting element of one of my PHP scripts and Failed to load resource: net::ERR_CONNECTION_REFUSED shows up in the log. The one command that seems to work is

whereis apache2

which returns apache2: /etc/apache2 /usr/share/apache2

Is there any way to fix this?

Ph33ly
  • 663
  • 3
  • 13
  • 29
  • You need to include at least what OS/distro you are using as a tag so someone who knows that disto can offer some help. – Brian Topping May 03 '15 at 15:39
  • Sorry about that, added the changes – Ph33ly May 03 '15 at 15:41
  • If this is a case of a server your server maybe compromised and might contain rootkits. I had a simillar situation with rsync not showing up with the which command. Solution is recover your important files and spin-up a new server – Shenal Silva May 03 '15 at 15:42
  • Sorry to ask but how would I go about recovering my important files? – Ph33ly May 03 '15 at 15:45

1 Answers1

0

Are you sure that you tried the following (with the following order too)?

First Uninstall Apache

sudo apt-get --purge remove apache2
sudo apt-get autoremove

Then, install it as normal...

sudo apt-get install apache2
sudo /etc/init.d/apache2 restart

Then goto to a terminal and check (as i did in my terminal) :

andreas@ubuntu:~/Desktop$ ps -ALL |grep apache2
1564  1564 ?        00:00:00 apache2
...

Finally check from your browser:

http://localhost
Andreas Venieris
  • 452
  • 3
  • 15
  • Ok I tried going through the commands again and followed your steps but `ps -ALL |grep apache2` and localhost don't respond – Ph33ly May 03 '15 at 15:51
  • Did you tried to `sudo apt-get update` and then restart? – Andreas Venieris May 03 '15 at 15:56
  • yea, still no response – Ph33ly May 03 '15 at 15:59
  • I am affraid that you have still files on your system from old apache2 installation. Do you know how to setup apache in different port (say 8080) than the default (80)? – Andreas Venieris May 03 '15 at 16:04
  • I found this answer (http://stackoverflow.com/questions/3940909/configure-apache-to-listen-on-port-other-than-80) but I don't have httpd.conf. I checked apache2.conf and `listen 80` isn't there either. Would it be somewhere else? – Ph33ly May 03 '15 at 16:17
  • In apache2 there is some slight different approach. Please read the comments in `/etc/apache2/apache2.conf` and you will see that there is a file in the same dir, called `ports.conf` that will contains all the ports definition. If this is not your case then your `/etc/apache2/` may be corupted. I suggest to remove it and try to re-install apache2... again!! – Andreas Venieris May 03 '15 at 16:27
  • Sorry about that I just found it. And changed the port. I tried restarting after with `sudo service apache2 restart` but still no response.... – Ph33ly May 03 '15 at 16:31
  • first try this command to load apache `sudo /etc/init.d/apache2 reload`. If still fails then try following this steps: http://www.cyberciti.biz/faq/troubleshooting-apache-webserver-will-not-restart-start/ – Andreas Venieris May 03 '15 at 16:38
  • I'm having some problems trying to ssh into the server. I also found this `The program 'apache2' is currently not installed. You can install it by typing: sudo apt-get install apache2-bin` and when I install apache2-bin I still get the error...Is there some way to completely wipe everything and install from the ground up? – Ph33ly May 03 '15 at 17:02
  • Yes, try this: http://askubuntu.com/questions/176964/permanently-removing-apache2 – Andreas Venieris May 03 '15 at 17:12
  • Thanks! I got my server up now!....sort of a side question if you don't mind but is there a reason my php files are being printed in browser instead of running it? – Ph33ly May 03 '15 at 17:46
  • OK... I am glad it works. Now you have to make your `apache` to understand php. Your last problem is relatively easy to be solved... Just check here: http://stackoverflow.com/questions/12142172/apache-shows-php-code-instead-of-executing – Andreas Venieris May 03 '15 at 18:14