Viewing my Website (Ansible Nginx conflict?)

I am actually not sure entirely where this should go, but I’ve deployed the Ansible directory successfully as seen on my staging server: http://tpt-staging.tk/

HOWEVER, I just deployed my wordpress website with Cap to my staging server and I’m still seeing the “Welcome to nginx on Debian!” text, rather than my own website…

I’ve launched multiple sites on this system and can’t find where the error is for this one. Any ideas of what aspect might be the bug?

I’m a little confused about how you’ve deployed.

I’ve deployed the Ansible directory

and

HOWEVER, I just deployed my wordpress website with Cap to my staging server

Are you using Trellis (Ansible) or just Capistrano for deploys?

Hi there,
Sorry for the confusion.
I ran ./deploy.sh to push the Ansible files to the server. And that is working (tpt-staging.tk). However, when I run Capistrano from the root of my website folder, scripts/deploy staging it all runs smoothly and it says it deployed, but the website is not showing up at the URL where my staging or production servers are.

Does that make sense?

Here’s my nginx/templates/wordpress.conf.j2 file if that is helpful:

location / {
  try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
  client_max_body_size 10M;
  try_files $uri =404;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_read_timeout 300;

  default_type text/html;

  set $memcached_raw_key $scheme://$host$request_uri;

  set $memcached_key data-$memcached_raw_key;

  set $memcached_request 1;

  if ($request_method = POST) {
    set $memcached_request 0;
  }

  if ($uri ~ "/wp/wp-") {
    set $memcached_request 0;
  }

  if ($args) {
    set $memcached_request 0;
  }

  if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_") {
    set $memcached_request 0;
  }

  if ($memcached_request = 1) {
    add_header X-Cache-Engine "yes";
    memcached_pass {{ memcached_listen_ip }}:{{ memcached_port }};
    error_page 404 502 504 = @nocache;
    break;
  }

  fastcgi_pass unix:/var/run/php5-fpm-$site_name.sock;
}

location @nocache {
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_read_timeout 300;
  add_header X-Cache-Engine "no";
  fastcgi_pass unix:/var/run/php5-fpm-$site_name.sock;
}

Why are you running both Ansible and Capistrano to deploy? Ansible deploys are very similar to how Capistrano runs, and is all you should need. Capistrano is not necessary when using Ansible.

Sorry maybe I’m using the wrong language. You have to have Ansible on the server to run the wordpress sites. So I’ve loaded Ansible on the server and then the Wordpress site via the command line and both have loaded successfully. But there is a conflict somewhere.

I’m wondering if anyone knows where I might have a conflict. I’ve reviewed all the ansible files and can’t see a conflict. It appears set up correctly. I’ve run it across other sites that I have working and it seems like it’s identical, but I’m clearly missing something.

I don’t think so. We’re still curious why you’re deploying with both Ansible and Capistrano. Capistrano is not necessary in this situation, and could very well be the issue here.

Running ansible-playbook is what sets up your server. Running ./deploy.sh is what deploys the site, the same way that Capistrano deploys.

I guess I’m not following.

Why wouldn’t I use Capistrano? That’s what I use to deploy the wordpress staging & production sites. And I use Ansible-bedrock to configure the servers… It’s worked on many sites so far, but this is a brand new production and I’m not sure what I’m missing. That’s what all the Roots documents recommend and how Roots is set up to deploy.

The issue is with getting the Wordpress site to be visible.
Would this be it?
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts–3

Or if you’re saying I don’t need both, should I remove Ansible and just deploy with Cap?

Just to clear up some terminology and tools here:

Trellis

Set of Ansible playbooks.

  • server.yml: provisions the server (installs software and configures it)
  • deploy.yml: deploys your code (clones your project to the remote server)

Capistrano

Deploys your code and nothing else.

So if you’ve used Trellis to provision your server (meaning you ran ansible-playbook server.yml) then it’s easiest to also use Trellis to deploy your site via deploy.sh.

You could use Capistrano to deploy sites, especially if its been working, but it requires more work and could lead to problems.

Using Trellis for both is more foolproof since all the configuration you did to define your wordpress_sites gets used for provisioning and deploys meaning its all consistent.

Now, if you do want to use Trellis for provisioning and Capistrano for deploys, it’s much harder for us to help you since it isn’t really designed to be used that way.

Capistrano was the older deploy method before Trellis/bedrock-ansible existed.

Yes, thank you. I’m using the version just prior to the launch of Trellis.
So exactly what swalkinshaw mentioned without Trellis. I’m using bedrock-ansible & bedrock-capistrano. Sorry am a little behind. Thought I could get some help here.

I was just looking for some insight if anyone knew why the conflict might be happening when it’s worked so beautifully so many times :slight_smile: I’ll keep on debugging.

Thanks

Thanks for clearing that up :slightly_smiling:

Most of the help I can offer is that you’ll usually see that Nginx welcome page when the document root is not set up correctly. I’d verify that your Nginx server block is pointing to the correct directory (the root directive). And that it points to the WP site directory containing the index.php file.

Thanks! I’ll give it a shot :slightly_smiling: