Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 808 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nginx serves .php files as downloads, instead of executing them

#11
If anything else doesn't help you. And maybe earlier you installed apache2 with info.php test file. Just clear App Data (cache,cookie) for localhost.
Reply

#12
check your nginx config file extension is *.conf.
for example: /etc/nginx/conf.d/myfoo.conf

I got the same situation. After I rename the my config file from myfoo to myfoo.conf, it fixed.
Do not forget to restart nginx after rename it.
Reply

#13
> First you have to ``Remove cache`` in your browser

Then open terminal and run the following command:

sudo apt-get install php-gettext
sudo nano /etc/nginx/sites-available/default

Then add the following code in the ``default`` file:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name localhost;

location / {
try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

If any mismatch just correction and restart Nginx from terminal by the following command

> sudo systemctl restart nginx

Then go to browser and Enjoy ...
Reply

#14
This workded for me.

**1) MyApp file**

vi /etc/nginx/sites-available/myApp

server {
listen 80;
listen [::]:80;

root /var/www/myApp;
index index.php index.html index.htm;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

PHP5 users

Change

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

to

fastcgi_pass unix:/var/run/php5-fpm.sock;

------------------

**2) Configure cgi.fix_pathinfo**

Set cgi.fix_pathinfo to 0

Location:

PHP5
/etc/php5/fpm/php.ini

PHP7
/etc/php/7.0/fpm/php.ini

------------------

**3) Restart services**

FPM

php5 `sudo service php5-fpm restart`

php7 `sudo service php7.0-fpm restart`

NGINX

sudo service nginx restart
Reply

#15
For me it helped to add `?$query_string` at the end of /index.php, like below:

location / {
try_files $uri $uri/ /index.php?$query_string;
}

Reply

#16
For me it was the line:
fastcgi_pass unix:/var/run/php5-fpm.sock;

which had to be just:
fastcgi_pass unix:/run/php5-fpm.sock;
Reply

#17
I my case I was not using `/etc/nginx/sites-available/default` I was using a different server block configuration file (e.g. example.com), and the only way I was able to fix this problem is by removing the default server block configuration file symbolic link:

$ rm /etc/nginx/sites-enabled/default
then reloading Nginx:

$ sudo systemctl reload nginx
Reply

#18
I was about to go mental trying to fix this, for me the issue was that Cloudflare had cached the php file and kept making me download it.

The fix for me was to purge the cache on Cloudflare.
Reply

#19
I had been having the same problem what solved it was this server block also have this block above other location blocks if you have css not loading issues. Which I added to my sites-available conf file.

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Reply

#20
So this is what finally worked in my case as rewrite rules where the culprit
I changed the nginx rewrite rules as follows..

location /vendors { rewrite ^/vendors/?$ /vendors.php break; }

becomes...

location /vendors { rewrite ^/vendors/?$ /vendors.php last; }

Apparently without the **last** keyword, the request didn't get restarted, so it never hit the `.php` location segment, and was simply interpreted as a download –
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through