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 (an alternative command will be ss -tulpn | grep :80 if netstat isn't installed on your system) 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.
Answer from Thomas Ward on askubuntu.comWhat 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 (an alternative command will be ss -tulpn | grep :80 if netstat isn't installed on your system) 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.
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)
As described in the comments by AdminBee, you need to disable the service on an Ubuntu version with systemd:
sudo systemctl disable apache2
Use enable to enable the service again.
You can then still start/stop the service manually with
sudo systemctl start apache2
sudo systemctl stop apache2
or
sudo service apache2 start
sudo service apache2 stop
if you need it.
To remove Apache:
sudo apt purge apache*
The dot you have after apache2 is most likely to be your problem.
You can check this has worked by using dpkg:
dpkg -l | grep '^ii' | grep -i apache
This will show all currently installed packages matching the (case insensitive) string apache
Videos
How do I make Apache start automatically after a reboot?
Where are the Apache log files?
How do I check if Apache is running?
I've always done it with
sudo apachectl stop
However that won't stop it from starting again at boot time. Also there may be some sort of supervisor script that will re-launch the service if it notices that it's been stopped.
There are a couple things you should look at. First find out what is actually running on port 80 using a command like this.
lsof -i -P | grep :80
Whatever is running on port 80 will come back with a PID looking like this
httpd 1046 apache2 10u IPv4 5203 0t0 TCP xxx.xxx.xxx.xxx:80 (LISTEN)
That is what you want to kill.
Lastly if all else fails you can try to send a Kill TERM sig to the Parent by using the pidFile approach as follows.
kill -TERM `cat /usr/local/apache2/logs/httpd.pid`
This will kill off all children and then the Parent will exit. If you kill off child httpd processes you will see new httpd processes come back because the parent is still active.
you could simply disable it by:
sudo update-rc.d apache2 disable
and then if you would like to enable it again:
sudo update-rc.d apache2 enable
depending on the project i am working on, it is handy to have the service conveniently available, if i wish to re-enable it.
On old,pre systemd distributions under /etc/init.d/ you will find all the init scripts for different boot up services, like apache2, networking, etc.
Depending on which runlevel the computer starts in, different services are started.
So from the /etc/init.d/ folder each "service" is linked to one/many/no run level folders named from rc0.d to rc6.d.
To keep things simple there is a tool for removing/adding these links, hence removing or adding scripts to and from start up.
To disable apache2 simply type:
sudo update-rc.d apache2 disable
This disables apache2 at startup but is not removed so it can be enabled again. To remove the apache2 startup scripts do the following:
To remove apache2 simply type:
sudo update-rc.d -f apache2 remove
###Doing this will cause all runlevel folders that are linked to apache2 to be removed.
apache2 is a metapackage that just selects other packages. If you installed apache by installing that package, you just need to run this to clean up the automatically selected packages:
sudo apt autoremove
If that doesn't work, you might have installed one of the dependents manually. You can target all the apache2- packages from space and nuke the lot:
sudo apt remove apache2*
For future reference, to find out which package a binary is from, you can run this:
dpkg -S `which apache2`
I'd expect that to come back with apache2.2-bin (at the time of writing).
Follow these steps to remove the apache2 service using Terminal:
First stop the apache2 service if it is running with:
sudo service apache2 stopNow remove and cleanup all the apache2 packages with:
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common //or sudo apt-get purge apache2 apache2-utils apache2-bin apache2.2-commonFinally, run
sudo apt-get autoremove
just in case any other cleanup in needed
You can do the following two tests to confirm apache has been removed:
which apache2- should return a blank linesudo service apache2 start- should returnapache2: unrecognized service