2016-12-17 13 views
0

.phpを実行する代わりに、ダウンロードしています。.phpを実行する代わりに、Nginxがファイルをダウンロードしています

私はUbuntu 16.04 LTSと/ etc/nginx/sites-available/defaultにphp7を設定しようとしています。

誰でも手助けできますか?

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

      root /var/www/html; 

      index index.php index.html index.htm index.nginx-debian.html; 
      server_name mydomain.com www.mydomain.com; 

      return 301 https://$server_name$request_uri; 

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

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

    server { 
      index index.html index.htm index.nginx-debian.html; 
      # SSL configuration 
      listen 443 ssl http2 default_server; 
      listen [::]:443 ssl http2 default_server; 
      include snippets/ssl-mydomain.com.conf; 
      include snippets/ssl-params.conf; 

      location /web { 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $remote_addr; 
      proxy_set_header Host $host; 
      proxy_pass http://localhost:32400/web/; 
      } 

    } 

答えて

0

fastcgiのconfigsを逃し見る、あなたはhttpsにすべてをリダイレクトして、HTTPSサーバ部分はPHPを処理しません。

0

2番目のサーバー(ssl)ブロックにlocation ~ \.php$ブロックがないようです。これは、nginxに、PHPを生かすのではなく、実行するように指示するものです。

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

     root /var/www/html; 

     index index.php index.html index.htm index.nginx-debian.html; 
     server_name mydomain.com www.mydomain.com; 

     return 301 https://$server_name$request_uri; 

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

server { 
     index index.html index.htm index.nginx-debian.html; 
     # SSL configuration 
     listen 443 ssl http2 default_server; 
     listen [::]:443 ssl http2 default_server; 
     include snippets/ssl-mydomain.com.conf; 
     include snippets/ssl-params.conf; 

     location /web { 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://localhost:32400/web/; 
     } 

     location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 
     include fastcgi_params; 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     } 
} 
:つまり

、これをやってみます

関連する問題