Nginx starts to downloading index.php instead executing
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
.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.
16.04 server php nginx
add a comment |Â
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.
16.04 server php nginx
add a comment |Â
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.
16.04 server php nginx
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.
16.04 server php nginx
asked 16 hours ago
![](https://i.stack.imgur.com/zueWr.jpg?s=32&g=1)
![](https://i.stack.imgur.com/zueWr.jpg?s=32&g=1)
Tarasovych
1137
1137
add a comment |Â
add a comment |Â
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;
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
add a comment |Â
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;
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
add a comment |Â
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;
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
add a comment |Â
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;
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;
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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