Nginx is downloading file instead of doing MySql query
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):
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:
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
add a comment |
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):
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:
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
add a comment |
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):
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:
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
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):
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:
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
mysql nginx php7
asked Sep 2 '16 at 11:49
Marco HegenbergMarco Hegenberg
1011
1011
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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;
.
New contributor
add a comment |
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_pass
es 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)
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
.
New contributor
add a comment |
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;
.
New contributor
add a comment |
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;
.
New contributor
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;
.
New contributor
edited yesterday
Melebius
4,61551839
4,61551839
New contributor
answered yesterday
Aleksey ShaposhnikovAleksey Shaposhnikov
111
111
New contributor
New contributor
add a comment |
add a comment |
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_pass
es 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)
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
add a comment |
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_pass
es 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)
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
add a comment |
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_pass
es 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)
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_pass
es 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)
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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