简体   繁体   中英

phpspreadsheet not working IIS (Windows server 2012 R2) BUT working on local XAMPP Server

I have developed a website using php & mysql where the user have to upload a excel file. In local server (XAMPP), I have download phpspreadsheet and I am able to upload excel file to mysql database. But when I am working in same thing on IIS (Windows server 2012 r2), excel file not upload to mysql and below basic code not working on IIS (Windows server 2012 r2) and show

This page isn't working. 10.10.10.2 is currently unable to handle this request. HTTP ERROR 500

In IIS windows server 2012 r2, I am using php 7.4.13.Below code working on XAMPP SERVER but not working on IIS (Windows server 2012 R2)

<?php

require 'vendor/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Color;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'This new hello World !');

$writer = new Xlsx($spreadsheet);
$writer->save('ThisMyExcelExample.xlsx');
?>

On Windows Server, there are more steps involved. make sure that you made the following steps

  • Open the Server Manager application and go through the “Add Roles and Features” wizard.
  • On the Server Roles page, select “Web Server (IIS)” , be sure to enable CGI
  • Installing PHP on IIS
  • In the Actions pane, you will be able to choose “Add Module Mapping.” Enter the necessary details to tell IIS that *.php files should be run by php-cgi.exe
  • Now, select your server in the Connections pane of IIS Manager and choose “Default Document.” In the subsequent Actions pane, click “Add…” and add “index.php.”
  • also make sure to configure PHP on IIS

please check the following article How to Host PHP on windows with IIS its helpful & will guide you with attached images of steps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM