title: Try_files for php causing error on fastcgi-php.conf, "try_files" directive is duplicate in /etc/nginx/snippets/fastcgi-php.conf:5
body: <p>I tried to add try_files to check if php file exist, but it give me error.</p>
  
  <pre><code>"try_files" directive is duplicate in /etc/nginx/snippets/fastcgi-php.conf:5
  </code></pre>
  
  <p>Here the location I want to add try_files</p>
  
  <pre><code>location ~ \.php$ {
      try_files $uri =404;
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/run/php/php7.0-fpm-user.sock;
  }
  </code></pre>
  
  <p>Here's my compete server block.</p>
  
  <pre><code>server {
      listen 80;
      server_name www.example.com example.com;
      return 301 https://example.com$request_uri;
  }
  
  
  
  server {
      listen 443 ssl;
      server_name www.example.com;
      ssl_certificate /home/user/ssl/example.com.ssl-bundle.crt;
      ssl_certificate_key /home/user/ssl/example.com.key;
      return 301 https://example.com$request_uri;
  }
  
  
  
  server {
      listen 443 ssl;
  
      root /home/user/public_html;
      index index.php index.html index.htm index.nginx-debian.html;
  
      server_name example.com;
      ssl_certificate /home/user/ssl/example.com.ssl-bundle.crt;
      ssl_certificate_key /home/user/ssl/example.com.key;
  
      location = /favicon.ico {
          log_not_found off;
          access_log off;
      }
  
      location = /robots.txt {
          allow all;
          log_not_found off;
          access_log off;
      }
  
      include /home/user/public_html/nginx.conf;
  
      location / {
          try_files $uri $uri/ /index.php?$args;
      }
  
      location ^~ /wp-login.php {
          auth_basic "Administrator Login";
          auth_basic_user_file /etc/nginx/.htpasswd;
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.0-fpm-user.sock;
      }
  
      location /phpmyadmin {
          auth_basic "Restricted Content";
          auth_basic_user_file /etc/nginx/.htpasswd;
      }
  
      # Phpmyadmin Configurations
      location /phpmyadmin {
          root /home/user/public_html/;
          index index.php index.html index.htm;
          auth_basic "Restricted Content";
          auth_basic_user_file /etc/nginx/.htpasswd;
          location ~ ^/phpmyadmin/(.+\.php)$ {
              try_files $uri =404;
              root /home/user/public_html/;
              fastcgi_pass unix:/run/php/php7.0-fpm-user.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
          }
          location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
              root /home/user/public_html/;
          }
      }
  
      location /phpMyAdmin {
          rewrite ^/* /phpmyadmin last;
      }
  
      location ~ \.php$ {
          try_files $uri =404;
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.0-fpm-user.sock;
      }
  
      location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
          expires max;
          log_not_found off;
      }
  
  }
  </code></pre>
  
  <p>What's wrong with my server block? Why try_files gives me error? Is it fastcgi-php.conf bug? my Nginx version is 1.12.1</p>
  
  <p>Another question, please check on my phpmyadmin block, i get it from here <a href="https://serverfault.com/questions/433785/nginx-phpmyadmin-redirecting-to-instead-of-phpmyadmin-upon-login">https://serverfault.com/questions/433785/nginx-phpmyadmin-redirecting-to-instead-of-phpmyadmin-upon-login</a>
  this format works, but as far as I know, root is not supposed to have trailing slash.</p>
  
  <p>Thanks</p>