0

I Can't stop apache2. I want to use nginx, therefore,I want to remove/stop apache2 but I can't. I've tried all the methods on this Link , but when I refresh http://127.0.0.1/ i still see the apche2 there.

3

What you're seeing is the index.html file that was installed by Apache. Do not trust solely the Index page being served as an indicator of the Web Server being used!

Just because you're seeing the Apache "default" page, doesn't mean that you're actually seeing Apache running, you're just seeing the 'default page' that was installed. Neither NGINX nor Apache will overwrite the index.html file in the default web root if it was already present (in an ideal situation), so whichever was present first is actually the one that installed the index.html file - it won't change just because you installed a different webserver.

You can confirm this by doing: sudo rm /var/www/html/index.html && echo "I am testing things!" | sudo tee /var/www/html/index.html and then refreshing your browser - you'll see that it's different content at this point.

If the nginx software at install time sees an index.html file already in the default webroot /var/www/html/, it is supposed to not overwrite it. This is normal, so users who use the default docroot for their websites don't lose their data.

What we need to do is confirm what Web Server is actually in use.
Always use actual command line tools to verify the web server software in use.

Leveraging sudo netstat -tulpn | grep :80 we can get an idea of what web server is in use:

$ sudo netstat -tulpn | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN      1258/apache2

As you can see, this is an Apache2 web server listening on port 80.

Conversely, if the server is nginx you see something like this:

$ sudo netstat -tulpn | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2772/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      2772/nginx: master

You can also determine if it's Apache2 or NGINX running by checking the output of one of the following commands:

$ pidof apache2
$ pidof nginx

Depending on which of these provides output, you can determine which web server is actually in use.

0

If you want to stop the Apache2 web server then command is

sudo systemctl stop apache2 --- Stop the server

sudo systemctl restart apache2 ---- Restart the web server

You can remove(permanently) the Apache2 web server by command.

sudo apt-get purge -y apache2* --- Uninstall the Apache2 server

After uninstall you can check in browser by entering your localhost(127.0.0.1)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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