Nginx starts to downloading index.php instead executing

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












At my hosting control panel I set up my server api for server name (let it be dev.domainname.com).



dev.domainname.com config:



server 
listen 80;
#listen [::]:80;

root /var/www/dev.domainname.com/public;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name dev.domainname.com;

location /
try_files $uri $uri/ =404;




After I open dev.domainname.com brower receive a file called "download". Actually I checked that file - it is my index.php inside /public.



What's wrong?



Some additional info: I've installed SSL-certificate using certbot. https://dev.domainname.com isn't available too, I got ERR_CONNECTION_TIMED_OUT.



sudo tail -n 20 /var/log/nginx/error.log doesn't have any errors for the last hour.



hosts file contains one row:



127.0.0.1 domainname domainname



sudo nginx -t is also ok.







share|improve this question

























    up vote
    0
    down vote

    favorite












    At my hosting control panel I set up my server api for server name (let it be dev.domainname.com).



    dev.domainname.com config:



    server 
    listen 80;
    #listen [::]:80;

    root /var/www/dev.domainname.com/public;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name dev.domainname.com;

    location /
    try_files $uri $uri/ =404;




    After I open dev.domainname.com brower receive a file called "download". Actually I checked that file - it is my index.php inside /public.



    What's wrong?



    Some additional info: I've installed SSL-certificate using certbot. https://dev.domainname.com isn't available too, I got ERR_CONNECTION_TIMED_OUT.



    sudo tail -n 20 /var/log/nginx/error.log doesn't have any errors for the last hour.



    hosts file contains one row:



    127.0.0.1 domainname domainname



    sudo nginx -t is also ok.







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      At my hosting control panel I set up my server api for server name (let it be dev.domainname.com).



      dev.domainname.com config:



      server 
      listen 80;
      #listen [::]:80;

      root /var/www/dev.domainname.com/public;

      # Add index.php to the list if you are using PHP
      index index.php index.html index.htm index.nginx-debian.html;

      server_name dev.domainname.com;

      location /
      try_files $uri $uri/ =404;




      After I open dev.domainname.com brower receive a file called "download". Actually I checked that file - it is my index.php inside /public.



      What's wrong?



      Some additional info: I've installed SSL-certificate using certbot. https://dev.domainname.com isn't available too, I got ERR_CONNECTION_TIMED_OUT.



      sudo tail -n 20 /var/log/nginx/error.log doesn't have any errors for the last hour.



      hosts file contains one row:



      127.0.0.1 domainname domainname



      sudo nginx -t is also ok.







      share|improve this question











      At my hosting control panel I set up my server api for server name (let it be dev.domainname.com).



      dev.domainname.com config:



      server 
      listen 80;
      #listen [::]:80;

      root /var/www/dev.domainname.com/public;

      # Add index.php to the list if you are using PHP
      index index.php index.html index.htm index.nginx-debian.html;

      server_name dev.domainname.com;

      location /
      try_files $uri $uri/ =404;




      After I open dev.domainname.com brower receive a file called "download". Actually I checked that file - it is my index.php inside /public.



      What's wrong?



      Some additional info: I've installed SSL-certificate using certbot. https://dev.domainname.com isn't available too, I got ERR_CONNECTION_TIMED_OUT.



      sudo tail -n 20 /var/log/nginx/error.log doesn't have any errors for the last hour.



      hosts file contains one row:



      127.0.0.1 domainname domainname



      sudo nginx -t is also ok.









      share|improve this question










      share|improve this question




      share|improve this question









      asked 16 hours ago









      Tarasovych

      1137




      1137




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You need to tell nginx how to deal with php files. I create a "macro" which is simply a file containing the following:



          location ~ .php$ 
          fastcgi_param PHP_VALUE "display_errors=Off";
          fastcgi_split_path_info ^(.+.php)(.*)$;
          include fastcgi.conf;
          fastcgi_send_timeout 600;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;



          I then store that in /etc/nginx/macros and include it with



          include macros/php;





          share|improve this answer





















          • Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
            – Tarasovych
            15 hours ago










          • Now I have 502 Bad Gateway...
            – Tarasovych
            15 hours ago










          • Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
            – Cliff Stanford
            14 hours ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1062267%2fnginx-starts-to-downloading-index-php-instead-executing%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You need to tell nginx how to deal with php files. I create a "macro" which is simply a file containing the following:



          location ~ .php$ 
          fastcgi_param PHP_VALUE "display_errors=Off";
          fastcgi_split_path_info ^(.+.php)(.*)$;
          include fastcgi.conf;
          fastcgi_send_timeout 600;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;



          I then store that in /etc/nginx/macros and include it with



          include macros/php;





          share|improve this answer





















          • Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
            – Tarasovych
            15 hours ago










          • Now I have 502 Bad Gateway...
            – Tarasovych
            15 hours ago










          • Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
            – Cliff Stanford
            14 hours ago














          up vote
          0
          down vote













          You need to tell nginx how to deal with php files. I create a "macro" which is simply a file containing the following:



          location ~ .php$ 
          fastcgi_param PHP_VALUE "display_errors=Off";
          fastcgi_split_path_info ^(.+.php)(.*)$;
          include fastcgi.conf;
          fastcgi_send_timeout 600;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;



          I then store that in /etc/nginx/macros and include it with



          include macros/php;





          share|improve this answer





















          • Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
            – Tarasovych
            15 hours ago










          • Now I have 502 Bad Gateway...
            – Tarasovych
            15 hours ago










          • Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
            – Cliff Stanford
            14 hours ago












          up vote
          0
          down vote










          up vote
          0
          down vote









          You need to tell nginx how to deal with php files. I create a "macro" which is simply a file containing the following:



          location ~ .php$ 
          fastcgi_param PHP_VALUE "display_errors=Off";
          fastcgi_split_path_info ^(.+.php)(.*)$;
          include fastcgi.conf;
          fastcgi_send_timeout 600;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;



          I then store that in /etc/nginx/macros and include it with



          include macros/php;





          share|improve this answer













          You need to tell nginx how to deal with php files. I create a "macro" which is simply a file containing the following:



          location ~ .php$ 
          fastcgi_param PHP_VALUE "display_errors=Off";
          fastcgi_split_path_info ^(.+.php)(.*)$;
          include fastcgi.conf;
          fastcgi_send_timeout 600;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;



          I then store that in /etc/nginx/macros and include it with



          include macros/php;






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered 15 hours ago









          Cliff Stanford

          12




          12











          • Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
            – Tarasovych
            15 hours ago










          • Now I have 502 Bad Gateway...
            – Tarasovych
            15 hours ago










          • Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
            – Cliff Stanford
            14 hours ago
















          • Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
            – Tarasovych
            15 hours ago










          • Now I have 502 Bad Gateway...
            – Tarasovych
            15 hours ago










          • Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
            – Cliff Stanford
            14 hours ago















          Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
          – Tarasovych
          15 hours ago




          Can I change php 7.2 to 7.1 to make it work? Or there is other way for 7.1?
          – Tarasovych
          15 hours ago












          Now I have 502 Bad Gateway...
          – Tarasovych
          15 hours ago




          Now I have 502 Bad Gateway...
          – Tarasovych
          15 hours ago












          Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
          – Cliff Stanford
          14 hours ago




          Yes php 7.1 works the same way. If you have bad gateway, are you sure you have php-fpm installed?
          – Cliff Stanford
          14 hours ago












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1062267%2fnginx-starts-to-downloading-index-php-instead-executing%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491