Why do I still see an Apache site on Nginx?
Solution 1
Even after you remove apache2 completely, you will still have its "default site" files sitting in /var/www/
. By default, Nginx will attempt to serve these or its own version of these files for sites it cannot otherwise match. You can see this all in /etc/nginx/sites-available/default
.
What you're seeing is by design, it was just unexpected.
To fix it, you can edit or remove the default site... Or alter the files in /var/www/
to better suit your needs. If you want rid of the default, you can delete /etc/nginx/sites-available/default
. It's just a symlink so if you want to restore it, you can with:
sudo ln -s /etc/nginx/sites-{available,enabled}/default
And remember to reload after making configuration changes:
sudo service nginx configtest # make sure the config is good before reloading!
sudo service nginx reload
Solution 2
Both Nginx and Apache are referring to the /var/www
HTML file.
Run this command and refresh the page:
mv /var/www/html/index.html index.html_bkp
Related videos on Youtube
Newbie
Updated on September 18, 2022Comments
-
Newbie almost 2 years
I installed nginx then I installed apache2, after a while I removed apache2. After a couple of weeks I noticed something strange when I accessed
http://localhost
: nginx handles the request but when I type in my IP address or anyone in my network types in my IP, it results in an apache2 page loading saying it's correctly working.I purged and removed Apache but I still can't get rid of this problem, tried reinstalling and purging again then restarting. Any ideas of what could be the problem?
PS my computer doesn't recognize apache2 as being installed in anyway and all Apache files and binaries are not found even when I manually search for them.
root@elite-HP-Pro3500-G2-MT-PC:/home/elite# whereis apache2 apache2: root@elite-HP-Pro3500-G2-MT-PC:/home/elite# sudo service apache2 start Failed to start apache2.service: Unit apache2.service failed to load: No such file or directory. root@elite-HP-Pro3500-G2-MT-PC:/home/elite# sudo apt-get purge apache2 apache2-utils Reading package lists... Done Building dependency tree Reading state information... Done Package 'apache2' is not installed, so not removed Package 'apache2-utils' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 19 not upgraded.
-
Oli about 9 yearsFor technical reasons, the
apache2
package is just a metapackage that depends on other packages. You have to remove related packages too to remove the binary. -
Newbie about 9 yearsi've searched /user/sbin and /user/bin and i can't find it, do you know other locations where the binary could be? @Oli
-
Oli about 9 yearsSee my answer on the question I closed this against.
-
Newbie about 9 years@Oli i've already followed that tutorial to remove apache2 but it still exists somehow, and i've found that problem only occurs when i'm using anything other than the loopback (localhost) it will redirect towards apache2 but if i use a localhost nginx works
-
Oli about 9 yearsAre you sure it's actually Apache serving it and not just the default site files (in /var/www) that ships with default Apache install, now being hosted by ngninx? That's what it sounds like. If not, I'd be tracking down what's running with
htop
and finding out which servers are running. -
Newbie about 9 years@Oli yep that solved my problem, apache's index file in var/www thank you, btw i already looked in multiple questions before posting this :P so it's not a duplicate my problem was different
-
-
Anupam about 7 yearsWow - never guessed that. Tried all sort of playing-around with Apache until I read this post!
-
Ryan almost 4 years
ls -lah /etc/nginx/sites-available/default
says "No such file or directory" so my problem must be different. -
jx12345 over 2 yearsIf you check the response headers in your browser dev tools you should see
Server: nginx/1.18.0 (Ubuntu)
or similar so you can see that nginx rather than apache is serving up the page