M
M
Messi2017-05-16 21:10:50
PHP
Messi, 2017-05-16 21:10:50

Why is Nginx downloading php files?

Apache2 (PHP7) is installed in Ubuntu, I raised sites locally, everything is ok. Installed Nginx, in the folder with php7 there is (apache2, cli, fpm).
1. Created a folder /var/www/bets/index.php
2. In /etc/hosts added 127.0.0.1 bets.dev
3. In /etc/nginx/sites-available created a file bets.dev

server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## слушаем ipv6

    server_name bets.dev;
    root        /var/www/bets;
    index       index.php;

    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log;

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

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        try_files $uri =404;
    }
    error_page 404 /404.html;

    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }

    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

4. sudo ln -s /etc/nginx/sites-available/bets.dev /etc/nginx/sites-enabled/
5. Перезагрузил сервер nginx
6. При переходе по ссылке bets.dev, скачивает php файл.
Почему так?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max Kostikov, 2017-05-16
@mxms

А зачем вам Apache, если вы используете php-fpm через сокет? Запустите его как сервис, для начала.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question