1

i installed nginx on server(ubuntu 16.04) which already had apache2 and, done this following configuration,

->changed apache port 80 to 8888 so nginx would listen to 80
->restarted apache and nginx in sequence.

still getting apache default page when i type http://localhost i also stopped apache2 service and restarted nginx service to ensure only once server run at time but still getting apache default page on localhost request!!! which should be actually nginx default page cuase apache service is not running anymore.

One thing i found suspicious is 'htcacheclean' process is running,is that responsible for the returning Apache page?!

how this is happening is strange for me!! kindly share hint if you ever faced this kind of issue.

ss -tlnp return following for the port 80
State   Recv-Q  Send-Q     Local Address:Port   Peer Address:Port
LISTEN    0        0                     *:80                      **:* *

ss -tlnp | grep nginx command output shows nginx

ss -tlnp | grep nginx command output

DexJ
  • 111
  • 1
  • 4
  • On what port does `nginx` run in your machine? It defaults to apache because `apache2` uses port `80` by default. How does your `/etc/nginx/nginx.conf` look like? What does `ss -tlnp` return or rather, what does `lsof -i :80` return` when apache is not active and `nginx` is.? – Valentin Bajrami Oct 09 '17 at 11:12
  • Have you cleared your browser cache? – Richard Smith Oct 09 '17 at 11:20
  • Yes cleared cache and checked @RichardSmith! – DexJ Oct 09 '17 at 12:11
  • ss -tlnp command output updated in question @val0x00ff – DexJ Oct 09 '17 at 12:20
  • 1
    @DexJ I need to know the service name on that port. Can you run `ss -tlnp | grep nginx` or `lsof -i :80`. If `lsof` command is not available you can install it using `aptitude install lsof` – Valentin Bajrami Oct 09 '17 at 12:49
  • can you run `curl -I http://` please, so you can see if the webserver answering is nginx or apache – Diego Velez Oct 09 '17 at 14:27
  • 6
    You should check if Apache and Nginx have the same document root directory. In this case, check the document root directory (usually it is `/var/www/html/`) and if there is `index.html` file remove it, or rename it. Most likely it is the default `index.html` file created by Apache. – RoseHosting Oct 09 '17 at 14:53
  • @val0x00ff updated ss -tlnp | grep nginx commnad output in question it says nginx – DexJ Oct 10 '17 at 04:50
  • if this is not prod server , just disable apache server for a while and see the results.. as said if its still saving apachee default page its to do with index file as said by Rosehosting – Aravinda Oct 10 '17 at 04:53
  • after disabling apache and clearing browser cache and after verifying document root, still its there ? then go for clearing nigix cache.. https://stackoverflow.com/questions/6236078/how-to-clear-the-cache-of-nginx may be nigix is holding a copy ! – Aravinda Oct 10 '17 at 04:56
  • @DiegoVelez it shows apache 2 while i am requesting but isn't that weird cause i checked > service --status-all and found apache process is not running...! but i found another related process updated question plz check :) – DexJ Oct 10 '17 at 10:09

2 Answers2

2

Its because nginx may have same DocumentRoot as apache and It's index.html is still in /var/www/html. I had the same problem.

Vaibhav Panmand
  • 1,038
  • 7
  • 17
kyle
  • 21
  • 2
0

Faced the same issue in my linux. Solution is to purge apache2 entirely. for me the command - sudo apt purge apache2

Here is the complete solution to the problem-

  1. use gunicorn to start your django site
  2. edit nginx configurations to tell it to listen on another port except port 80

3.Boom solved.(Don't forget to restart nginx)

Here is how to- (my django site name is 'mysite'; replace it with yours(folder containing wsgi file.))

  1. in your django site folder command:gunicorn mysite.wsgi:application
  2. editing nginx - command: sudo nano /etc/nginx/sites-available/mysite_nginx.conf with code:-

server { listen 8001; server_name 192.168.1.36; # Your machine's local IP address

location / {
    proxy_pass http://127.0.0.1:8000;  # Gunicorn's default bind address
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

And then, create a symlink for it- command: sudo ln -s /etc/nginx/sites-available/mysite_nginx.conf /etc/nginx/sites-enabled

3.Restart nginx service- command: sudo service nginx restart or command: sudo /etc/init.d/nginx start

Finally, it will be available to every device connected to your local network use 'http://your_machine_ip:8001' to access it

Pardon me for beginner silly mistakes; I'm new to it.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://serverfault.com/help/whats-reputation) you will be able to [comment on any post](https://serverfault.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/562106) – unNamed Aug 22 '23 at 10:05