nginx and apache dont work together

January 27, 2015 2.2k views

I set up Apache on my VPS after I choosed to use Nginx. I changed the port for Nginx to 8000 but when I go to Nginx page http://95.85.39.84:8000/ I get just Apache welcome page. I shut down Apache so dont understand how can be there. when i go to http://95.85.39.84/ i got :

403 Forbidden
nginx/1.6.2

thanks. mike

2 comments
  • Hi! It's a bit unclear what you are trying to accomplish. If you're trying to setup Nginx in front of Apache as a reverse proxy, check out this article:

    If you're still running into issue, could you share your Apache and Nginx configurations?

    by Etel Sverdlov
    This tutorial covers combining apache and nginx to serve sites with more speed. This article takes you from a fresh DigitalOcean droplet to one where apache and nginx are configured to work together.
  • Hi asb,

    we have a lot of website on shared hosting and would like to move one by one all to digitalocean. Also I would like to have some localhost on my VPN.
    And also pushing from my localhost to VPN through capistrano and github. I bit confused if I am right.

6 Answers

I have no idea how to make this work, but it's my understanding that if you create a droplet with a WordPress on 14.04 Application, it installs Nginx as a front end to Apache, and it seems to run really, really fast. You might fire up an instance in a temporary droplet and check the config files to see if those don't shed some light on the subject.

so the nginx is running but the ip of the server shows just This webpage is not available.

apache is running fine on ip:8000.

here is my config file. what i am doing wrong ?

server {
listen 80;

    root /var/www;
    index index.php index.html index.htm;

    server_name 95.85.39.84;

    location / {
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;
    }

}

now when i go to http://qbfweb.com/ or http://95.85.39.84/ i get same page. dont understand. the index.html file is just under /var/www/qbfweb.com/index.html .

i still cant access phpmyadmin. when i type anything i get same index.html. http://95.85.39.84/phpmyadmin/

thanks

Nginx is working on port 80 as this moment, also is set to read files from /var/www; directory, if your apache files where there before you installed the nginx you need to change such files or change the root directive to use the folder where your site is hosted

root /var/www;

to

root /var/www/qbfweb.com;

Also this means nginx is listening on port 80:
server {
listen 80;

And servername is the domain name, no the ip so you should change it
server
name 95.85.39.84;

to

server_name .qbfweb.com; <- notice the . before the domain, that's a wildcard so www, and any other subdomain works too.

I changed nginx default to:
but still the same. at IP and qbfweb.com is the same index.html. really dont understand. when go to http://95.85.39.84:8000/ i get normal apache welcome site.

we have a lot of website on shared hosting and would like to move one by one all to digitalocean. Also I would like to have some localhost on my VPN.
And also pushing from my localhost to VPN through capistrano and github. I bit confused if I am right.

server {
listen 80;

    root /var/www/qbfweb.com;
    index index.php index.html index.htm;

    server_name .qbfweb.com;

    location / {
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;
    }
Have another answer? Share your knowledge.