Nginx is downloading file instead of doing MySql query












0















I encounter a very strange problem when I try to setup NGINX to use PHP and MySQL.



At first, everything seems to be fine and working. But that impression only lasts until there's a SQL query (at least that's my impression). And instead of passing the result of the query to PHP I get prompted to download a file with type application/octet-stream.



When I'm using SQLite or no database at all, everything is fine though. Does anybody have an idea why this is hapening?



When I have a look into my php info, it get this result:




Additional .ini files parsed:



/etc/php/7.0/fpm/conf.d/10-mysqlnd.ini,
/etc/php/7.0/fpm/conf.d/10-opcache.ini,
/etc/php/7.0/fpm/conf.d/10-pdo.ini,
/etc/php/7.0/fpm/conf.d/15-xml.ini,
/etc/php/7.0/fpm/conf.d/20-calendar.ini,
/etc/php/7.0/fpm/conf.d/20-ctype.ini,
/etc/php/7.0/fpm/conf.d/20-curl.ini,
/etc/php/7.0/fpm/conf.d/20-dom.ini,
/etc/php/7.0/fpm/conf.d/20-exif.ini,
/etc/php/7.0/fpm/conf.d/20-fileinfo.ini,
/etc/php/7.0/fpm/conf.d/20-ftp.ini, /etc/php/7.0/fpm/conf.d/20-gd.ini,
/etc/php/7.0/fpm/conf.d/20-gettext.ini,
/etc/php/7.0/fpm/conf.d/20-iconv.ini,
/etc/php/7.0/fpm/conf.d/20-imagick.ini,
/etc/php/7.0/fpm/conf.d/20-imap.ini,
/etc/php/7.0/fpm/conf.d/20-intl.ini,
/etc/php/7.0/fpm/conf.d/20-json.ini,
/etc/php/7.0/fpm/conf.d/20-mbstring.ini,
/etc/php/7.0/fpm/conf.d/20-mcrypt.ini,
/etc/php/7.0/fpm/conf.d/20-memcache.ini,
/etc/php/7.0/fpm/conf.d/20-mysqli.ini,
/etc/php/7.0/fpm/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/fpm/conf.d/20-pdo_sqlite.ini,
/etc/php/7.0/fpm/conf.d/20-phar.ini,
/etc/php/7.0/fpm/conf.d/20-posix.ini,
/etc/php/7.0/fpm/conf.d/20-pspell.ini,
/etc/php/7.0/fpm/conf.d/20-readline.ini,
/etc/php/7.0/fpm/conf.d/20-recode.ini,
/etc/php/7.0/fpm/conf.d/20-shmop.ini,
/etc/php/7.0/fpm/conf.d/20-simplexml.ini,
/etc/php/7.0/fpm/conf.d/20-sockets.ini,
/etc/php/7.0/fpm/conf.d/20-sqlite3.ini,
/etc/php/7.0/fpm/conf.d/20-sysvmsg.ini,
/etc/php/7.0/fpm/conf.d/20-sysvsem.ini,
/etc/php/7.0/fpm/conf.d/20-sysvshm.ini,
/etc/php/7.0/fpm/conf.d/20-tidy.ini,
/etc/php/7.0/fpm/conf.d/20-tokenizer.ini,
/etc/php/7.0/fpm/conf.d/20-wddx.ini,
/etc/php/7.0/fpm/conf.d/20-xmlreader.ini,
/etc/php/7.0/fpm/conf.d/20-xmlrpc.ini,
/etc/php/7.0/fpm/conf.d/20-xmlwriter.ini,
/etc/php/7.0/fpm/conf.d/20-xsl.ini




And this is my mysql configuration (also from PHP info):



MySQL settings



As you can see, the mysqlnd static shows 0?!



I'm trying to do this with wordpress as well as "Ionize". Ionize is also showing me some MySQL error:



Error inside of Ionize (MySql error)



Does anybody know how to solve (or at least debug since there are no errors inside the log files) this?



Thanks for any hints!










share|improve this question



























    0















    I encounter a very strange problem when I try to setup NGINX to use PHP and MySQL.



    At first, everything seems to be fine and working. But that impression only lasts until there's a SQL query (at least that's my impression). And instead of passing the result of the query to PHP I get prompted to download a file with type application/octet-stream.



    When I'm using SQLite or no database at all, everything is fine though. Does anybody have an idea why this is hapening?



    When I have a look into my php info, it get this result:




    Additional .ini files parsed:



    /etc/php/7.0/fpm/conf.d/10-mysqlnd.ini,
    /etc/php/7.0/fpm/conf.d/10-opcache.ini,
    /etc/php/7.0/fpm/conf.d/10-pdo.ini,
    /etc/php/7.0/fpm/conf.d/15-xml.ini,
    /etc/php/7.0/fpm/conf.d/20-calendar.ini,
    /etc/php/7.0/fpm/conf.d/20-ctype.ini,
    /etc/php/7.0/fpm/conf.d/20-curl.ini,
    /etc/php/7.0/fpm/conf.d/20-dom.ini,
    /etc/php/7.0/fpm/conf.d/20-exif.ini,
    /etc/php/7.0/fpm/conf.d/20-fileinfo.ini,
    /etc/php/7.0/fpm/conf.d/20-ftp.ini, /etc/php/7.0/fpm/conf.d/20-gd.ini,
    /etc/php/7.0/fpm/conf.d/20-gettext.ini,
    /etc/php/7.0/fpm/conf.d/20-iconv.ini,
    /etc/php/7.0/fpm/conf.d/20-imagick.ini,
    /etc/php/7.0/fpm/conf.d/20-imap.ini,
    /etc/php/7.0/fpm/conf.d/20-intl.ini,
    /etc/php/7.0/fpm/conf.d/20-json.ini,
    /etc/php/7.0/fpm/conf.d/20-mbstring.ini,
    /etc/php/7.0/fpm/conf.d/20-mcrypt.ini,
    /etc/php/7.0/fpm/conf.d/20-memcache.ini,
    /etc/php/7.0/fpm/conf.d/20-mysqli.ini,
    /etc/php/7.0/fpm/conf.d/20-pdo_mysql.ini,
    /etc/php/7.0/fpm/conf.d/20-pdo_sqlite.ini,
    /etc/php/7.0/fpm/conf.d/20-phar.ini,
    /etc/php/7.0/fpm/conf.d/20-posix.ini,
    /etc/php/7.0/fpm/conf.d/20-pspell.ini,
    /etc/php/7.0/fpm/conf.d/20-readline.ini,
    /etc/php/7.0/fpm/conf.d/20-recode.ini,
    /etc/php/7.0/fpm/conf.d/20-shmop.ini,
    /etc/php/7.0/fpm/conf.d/20-simplexml.ini,
    /etc/php/7.0/fpm/conf.d/20-sockets.ini,
    /etc/php/7.0/fpm/conf.d/20-sqlite3.ini,
    /etc/php/7.0/fpm/conf.d/20-sysvmsg.ini,
    /etc/php/7.0/fpm/conf.d/20-sysvsem.ini,
    /etc/php/7.0/fpm/conf.d/20-sysvshm.ini,
    /etc/php/7.0/fpm/conf.d/20-tidy.ini,
    /etc/php/7.0/fpm/conf.d/20-tokenizer.ini,
    /etc/php/7.0/fpm/conf.d/20-wddx.ini,
    /etc/php/7.0/fpm/conf.d/20-xmlreader.ini,
    /etc/php/7.0/fpm/conf.d/20-xmlrpc.ini,
    /etc/php/7.0/fpm/conf.d/20-xmlwriter.ini,
    /etc/php/7.0/fpm/conf.d/20-xsl.ini




    And this is my mysql configuration (also from PHP info):



    MySQL settings



    As you can see, the mysqlnd static shows 0?!



    I'm trying to do this with wordpress as well as "Ionize". Ionize is also showing me some MySQL error:



    Error inside of Ionize (MySql error)



    Does anybody know how to solve (or at least debug since there are no errors inside the log files) this?



    Thanks for any hints!










    share|improve this question

























      0












      0








      0








      I encounter a very strange problem when I try to setup NGINX to use PHP and MySQL.



      At first, everything seems to be fine and working. But that impression only lasts until there's a SQL query (at least that's my impression). And instead of passing the result of the query to PHP I get prompted to download a file with type application/octet-stream.



      When I'm using SQLite or no database at all, everything is fine though. Does anybody have an idea why this is hapening?



      When I have a look into my php info, it get this result:




      Additional .ini files parsed:



      /etc/php/7.0/fpm/conf.d/10-mysqlnd.ini,
      /etc/php/7.0/fpm/conf.d/10-opcache.ini,
      /etc/php/7.0/fpm/conf.d/10-pdo.ini,
      /etc/php/7.0/fpm/conf.d/15-xml.ini,
      /etc/php/7.0/fpm/conf.d/20-calendar.ini,
      /etc/php/7.0/fpm/conf.d/20-ctype.ini,
      /etc/php/7.0/fpm/conf.d/20-curl.ini,
      /etc/php/7.0/fpm/conf.d/20-dom.ini,
      /etc/php/7.0/fpm/conf.d/20-exif.ini,
      /etc/php/7.0/fpm/conf.d/20-fileinfo.ini,
      /etc/php/7.0/fpm/conf.d/20-ftp.ini, /etc/php/7.0/fpm/conf.d/20-gd.ini,
      /etc/php/7.0/fpm/conf.d/20-gettext.ini,
      /etc/php/7.0/fpm/conf.d/20-iconv.ini,
      /etc/php/7.0/fpm/conf.d/20-imagick.ini,
      /etc/php/7.0/fpm/conf.d/20-imap.ini,
      /etc/php/7.0/fpm/conf.d/20-intl.ini,
      /etc/php/7.0/fpm/conf.d/20-json.ini,
      /etc/php/7.0/fpm/conf.d/20-mbstring.ini,
      /etc/php/7.0/fpm/conf.d/20-mcrypt.ini,
      /etc/php/7.0/fpm/conf.d/20-memcache.ini,
      /etc/php/7.0/fpm/conf.d/20-mysqli.ini,
      /etc/php/7.0/fpm/conf.d/20-pdo_mysql.ini,
      /etc/php/7.0/fpm/conf.d/20-pdo_sqlite.ini,
      /etc/php/7.0/fpm/conf.d/20-phar.ini,
      /etc/php/7.0/fpm/conf.d/20-posix.ini,
      /etc/php/7.0/fpm/conf.d/20-pspell.ini,
      /etc/php/7.0/fpm/conf.d/20-readline.ini,
      /etc/php/7.0/fpm/conf.d/20-recode.ini,
      /etc/php/7.0/fpm/conf.d/20-shmop.ini,
      /etc/php/7.0/fpm/conf.d/20-simplexml.ini,
      /etc/php/7.0/fpm/conf.d/20-sockets.ini,
      /etc/php/7.0/fpm/conf.d/20-sqlite3.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvmsg.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvsem.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvshm.ini,
      /etc/php/7.0/fpm/conf.d/20-tidy.ini,
      /etc/php/7.0/fpm/conf.d/20-tokenizer.ini,
      /etc/php/7.0/fpm/conf.d/20-wddx.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlreader.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlrpc.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlwriter.ini,
      /etc/php/7.0/fpm/conf.d/20-xsl.ini




      And this is my mysql configuration (also from PHP info):



      MySQL settings



      As you can see, the mysqlnd static shows 0?!



      I'm trying to do this with wordpress as well as "Ionize". Ionize is also showing me some MySQL error:



      Error inside of Ionize (MySql error)



      Does anybody know how to solve (or at least debug since there are no errors inside the log files) this?



      Thanks for any hints!










      share|improve this question














      I encounter a very strange problem when I try to setup NGINX to use PHP and MySQL.



      At first, everything seems to be fine and working. But that impression only lasts until there's a SQL query (at least that's my impression). And instead of passing the result of the query to PHP I get prompted to download a file with type application/octet-stream.



      When I'm using SQLite or no database at all, everything is fine though. Does anybody have an idea why this is hapening?



      When I have a look into my php info, it get this result:




      Additional .ini files parsed:



      /etc/php/7.0/fpm/conf.d/10-mysqlnd.ini,
      /etc/php/7.0/fpm/conf.d/10-opcache.ini,
      /etc/php/7.0/fpm/conf.d/10-pdo.ini,
      /etc/php/7.0/fpm/conf.d/15-xml.ini,
      /etc/php/7.0/fpm/conf.d/20-calendar.ini,
      /etc/php/7.0/fpm/conf.d/20-ctype.ini,
      /etc/php/7.0/fpm/conf.d/20-curl.ini,
      /etc/php/7.0/fpm/conf.d/20-dom.ini,
      /etc/php/7.0/fpm/conf.d/20-exif.ini,
      /etc/php/7.0/fpm/conf.d/20-fileinfo.ini,
      /etc/php/7.0/fpm/conf.d/20-ftp.ini, /etc/php/7.0/fpm/conf.d/20-gd.ini,
      /etc/php/7.0/fpm/conf.d/20-gettext.ini,
      /etc/php/7.0/fpm/conf.d/20-iconv.ini,
      /etc/php/7.0/fpm/conf.d/20-imagick.ini,
      /etc/php/7.0/fpm/conf.d/20-imap.ini,
      /etc/php/7.0/fpm/conf.d/20-intl.ini,
      /etc/php/7.0/fpm/conf.d/20-json.ini,
      /etc/php/7.0/fpm/conf.d/20-mbstring.ini,
      /etc/php/7.0/fpm/conf.d/20-mcrypt.ini,
      /etc/php/7.0/fpm/conf.d/20-memcache.ini,
      /etc/php/7.0/fpm/conf.d/20-mysqli.ini,
      /etc/php/7.0/fpm/conf.d/20-pdo_mysql.ini,
      /etc/php/7.0/fpm/conf.d/20-pdo_sqlite.ini,
      /etc/php/7.0/fpm/conf.d/20-phar.ini,
      /etc/php/7.0/fpm/conf.d/20-posix.ini,
      /etc/php/7.0/fpm/conf.d/20-pspell.ini,
      /etc/php/7.0/fpm/conf.d/20-readline.ini,
      /etc/php/7.0/fpm/conf.d/20-recode.ini,
      /etc/php/7.0/fpm/conf.d/20-shmop.ini,
      /etc/php/7.0/fpm/conf.d/20-simplexml.ini,
      /etc/php/7.0/fpm/conf.d/20-sockets.ini,
      /etc/php/7.0/fpm/conf.d/20-sqlite3.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvmsg.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvsem.ini,
      /etc/php/7.0/fpm/conf.d/20-sysvshm.ini,
      /etc/php/7.0/fpm/conf.d/20-tidy.ini,
      /etc/php/7.0/fpm/conf.d/20-tokenizer.ini,
      /etc/php/7.0/fpm/conf.d/20-wddx.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlreader.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlrpc.ini,
      /etc/php/7.0/fpm/conf.d/20-xmlwriter.ini,
      /etc/php/7.0/fpm/conf.d/20-xsl.ini




      And this is my mysql configuration (also from PHP info):



      MySQL settings



      As you can see, the mysqlnd static shows 0?!



      I'm trying to do this with wordpress as well as "Ionize". Ionize is also showing me some MySQL error:



      Error inside of Ionize (MySql error)



      Does anybody know how to solve (or at least debug since there are no errors inside the log files) this?



      Thanks for any hints!







      mysql nginx php7






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 2 '16 at 11:49









      Marco HegenbergMarco Hegenberg

      1011




      1011






















          2 Answers
          2






          active

          oldest

          votes


















          1














          In Nginx configuration files, located in /etc/nginx/nginx.conf or /etc/nginx/sites-available/, you have the http2 protocol turned on in the configuration files for the port 80. Just replace the listen 80 http2; with listen 80;.






          share|improve this answer










          New contributor




          Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




























            0














            nginx doesn't download files, it just sends HTTP responses.

            Nginx is usually is responsible for setting the Content-Type: field on the HTTP header and as a default,
            nginx uses a MIME of application/octet-stream as a fallback when it can't determine the content type.

            When a browser receives a header with this content type, it will prompt the download action, as application/octet-stream is the MIME type for binary files.

            This to me is an indication that nginx isn't configured properly because when it fastcgi_passes properly it returns the html/plain header.

            You can also set the mime type directly



            http://nginx.org/en/docs/http/ngx_http_core_module.html#types



            or this snippet will set the default MIME for nginx to text/plain



            sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
            # change application/octet-stream to text/plain
            sudo sed -i 's/default_type application/octet-stream/default_type text/plain/'
            /etc/nginx/nginx.conf


            Also, if you get nginx and PHP configured correctly and sending the right Content-Type: headers, browsers like Chrome will continue to cache the previous values - so it will continue to prompt a download.

            This can be overcome, by opening developer tools, going in the the settings for the developer tools themselves and then clicking disable cache (while dev tools is open)






            share|improve this answer
























            • Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

              – Marco Hegenberg
              Sep 2 '16 at 13:48













            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            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%2f820010%2fnginx-is-downloading-file-instead-of-doing-mysql-query%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            In Nginx configuration files, located in /etc/nginx/nginx.conf or /etc/nginx/sites-available/, you have the http2 protocol turned on in the configuration files for the port 80. Just replace the listen 80 http2; with listen 80;.






            share|improve this answer










            New contributor




            Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              1














              In Nginx configuration files, located in /etc/nginx/nginx.conf or /etc/nginx/sites-available/, you have the http2 protocol turned on in the configuration files for the port 80. Just replace the listen 80 http2; with listen 80;.






              share|improve this answer










              New contributor




              Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                1












                1








                1







                In Nginx configuration files, located in /etc/nginx/nginx.conf or /etc/nginx/sites-available/, you have the http2 protocol turned on in the configuration files for the port 80. Just replace the listen 80 http2; with listen 80;.






                share|improve this answer










                New contributor




                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                In Nginx configuration files, located in /etc/nginx/nginx.conf or /etc/nginx/sites-available/, you have the http2 protocol turned on in the configuration files for the port 80. Just replace the listen 80 http2; with listen 80;.







                share|improve this answer










                New contributor




                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer








                edited yesterday









                Melebius

                4,61551839




                4,61551839






                New contributor




                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered yesterday









                Aleksey ShaposhnikovAleksey Shaposhnikov

                111




                111




                New contributor




                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Aleksey Shaposhnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.

























                    0














                    nginx doesn't download files, it just sends HTTP responses.

                    Nginx is usually is responsible for setting the Content-Type: field on the HTTP header and as a default,
                    nginx uses a MIME of application/octet-stream as a fallback when it can't determine the content type.

                    When a browser receives a header with this content type, it will prompt the download action, as application/octet-stream is the MIME type for binary files.

                    This to me is an indication that nginx isn't configured properly because when it fastcgi_passes properly it returns the html/plain header.

                    You can also set the mime type directly



                    http://nginx.org/en/docs/http/ngx_http_core_module.html#types



                    or this snippet will set the default MIME for nginx to text/plain



                    sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
                    # change application/octet-stream to text/plain
                    sudo sed -i 's/default_type application/octet-stream/default_type text/plain/'
                    /etc/nginx/nginx.conf


                    Also, if you get nginx and PHP configured correctly and sending the right Content-Type: headers, browsers like Chrome will continue to cache the previous values - so it will continue to prompt a download.

                    This can be overcome, by opening developer tools, going in the the settings for the developer tools themselves and then clicking disable cache (while dev tools is open)






                    share|improve this answer
























                    • Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                      – Marco Hegenberg
                      Sep 2 '16 at 13:48


















                    0














                    nginx doesn't download files, it just sends HTTP responses.

                    Nginx is usually is responsible for setting the Content-Type: field on the HTTP header and as a default,
                    nginx uses a MIME of application/octet-stream as a fallback when it can't determine the content type.

                    When a browser receives a header with this content type, it will prompt the download action, as application/octet-stream is the MIME type for binary files.

                    This to me is an indication that nginx isn't configured properly because when it fastcgi_passes properly it returns the html/plain header.

                    You can also set the mime type directly



                    http://nginx.org/en/docs/http/ngx_http_core_module.html#types



                    or this snippet will set the default MIME for nginx to text/plain



                    sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
                    # change application/octet-stream to text/plain
                    sudo sed -i 's/default_type application/octet-stream/default_type text/plain/'
                    /etc/nginx/nginx.conf


                    Also, if you get nginx and PHP configured correctly and sending the right Content-Type: headers, browsers like Chrome will continue to cache the previous values - so it will continue to prompt a download.

                    This can be overcome, by opening developer tools, going in the the settings for the developer tools themselves and then clicking disable cache (while dev tools is open)






                    share|improve this answer
























                    • Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                      – Marco Hegenberg
                      Sep 2 '16 at 13:48
















                    0












                    0








                    0







                    nginx doesn't download files, it just sends HTTP responses.

                    Nginx is usually is responsible for setting the Content-Type: field on the HTTP header and as a default,
                    nginx uses a MIME of application/octet-stream as a fallback when it can't determine the content type.

                    When a browser receives a header with this content type, it will prompt the download action, as application/octet-stream is the MIME type for binary files.

                    This to me is an indication that nginx isn't configured properly because when it fastcgi_passes properly it returns the html/plain header.

                    You can also set the mime type directly



                    http://nginx.org/en/docs/http/ngx_http_core_module.html#types



                    or this snippet will set the default MIME for nginx to text/plain



                    sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
                    # change application/octet-stream to text/plain
                    sudo sed -i 's/default_type application/octet-stream/default_type text/plain/'
                    /etc/nginx/nginx.conf


                    Also, if you get nginx and PHP configured correctly and sending the right Content-Type: headers, browsers like Chrome will continue to cache the previous values - so it will continue to prompt a download.

                    This can be overcome, by opening developer tools, going in the the settings for the developer tools themselves and then clicking disable cache (while dev tools is open)






                    share|improve this answer













                    nginx doesn't download files, it just sends HTTP responses.

                    Nginx is usually is responsible for setting the Content-Type: field on the HTTP header and as a default,
                    nginx uses a MIME of application/octet-stream as a fallback when it can't determine the content type.

                    When a browser receives a header with this content type, it will prompt the download action, as application/octet-stream is the MIME type for binary files.

                    This to me is an indication that nginx isn't configured properly because when it fastcgi_passes properly it returns the html/plain header.

                    You can also set the mime type directly



                    http://nginx.org/en/docs/http/ngx_http_core_module.html#types



                    or this snippet will set the default MIME for nginx to text/plain



                    sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
                    # change application/octet-stream to text/plain
                    sudo sed -i 's/default_type application/octet-stream/default_type text/plain/'
                    /etc/nginx/nginx.conf


                    Also, if you get nginx and PHP configured correctly and sending the right Content-Type: headers, browsers like Chrome will continue to cache the previous values - so it will continue to prompt a download.

                    This can be overcome, by opening developer tools, going in the the settings for the developer tools themselves and then clicking disable cache (while dev tools is open)







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 2 '16 at 13:35









                    the_velour_fogthe_velour_fog

                    1,4771028




                    1,4771028













                    • Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                      – Marco Hegenberg
                      Sep 2 '16 at 13:48





















                    • Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                      – Marco Hegenberg
                      Sep 2 '16 at 13:48



















                    Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                    – Marco Hegenberg
                    Sep 2 '16 at 13:48







                    Replaced application/octet-stream with text/plain and restarted nginx (service nginx restart), but it will still give me a application/octet-stream to download. :-/ But inside the developer tools I see that the response is "AAASBAAAAAAAAAMAAACAAAQAAAAAAAUA////AAAECAAAAAAAf/8AAAAACAcAAAAAAAAAAAAAAAAB". In IE it's not downloading anything, instead it's just showing "€ÿÿÿÿ"

                    – Marco Hegenberg
                    Sep 2 '16 at 13:48




















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f820010%2fnginx-is-downloading-file-instead-of-doing-mysql-query%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    數位音樂下載

                    格利澤436b

                    When can things happen in Etherscan, such as the picture below?