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

11
  • 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.? Oct 9, 2017 at 11:12
  • Have you cleared your browser cache? Oct 9, 2017 at 11:20
  • Yes cleared cache and checked @RichardSmith!
    – DexJ
    Oct 9, 2017 at 12:11
  • 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 Oct 9, 2017 at 12:49
  • 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. Oct 9, 2017 at 14:53

2 Answers 2

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.

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .