php - xlsx file uploading 500 error. Amazon AWS
I have a simple html form which uploads .xlsx file to the web server. It works fine in localhost but not in amazon aws. Gives 500 internal server error after submitting the form.
Added below mime type line to /etc/httpd/conf/httpd.conf and restarted the apache web server
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
But still giving 500 internal server error.
Access Log
106.193.45.134 - - [11/Nov/2020:20:10:15 +0000] "GET /assets/google-fonts/nunito.css HTTP/1.1" 404 196 "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/exams" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:15 +0000] "GET /admin/assets/images/logo.png HTTP/1.1" 404 196 "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/exams" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:21 +0000] "GET /admin/add-questions?node=EX-803724 HTTP/1.1" 200 33642 "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/exams" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:21 +0000] "GET /assets/google-fonts/nunito.css HTTP/1.1" 404 196 "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:22 +0000] "GET /assets/js/validation/custom.js HTTP/1.1" 304 - "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:22 +0000] "GET /admin/assets/images/logo.png HTTP/1.1" 404 196 "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:10:32 +0000] "POST /admin/app/import-question.php HTTP/1.1" 500 - "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:11:21 +0000] "POST /admin/app/import-question.php HTTP/1.1" 500 - "http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
106.193.45.134 - - [11/Nov/2020:20:12:24 +0000] "-" 408 - "-" "-"
Error log
[Sun Nov 08 03:28:01.164234 2020] [lbmethod_heartbeat:notice] [pid 11174] AH02282: No slotmem from mod_heartmonitor
[Sun Nov 08 03:28:01.164288 2020] [http2:warn] [pid 11174] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun Nov 08 03:28:01.164294 2020] [http2:warn] [pid 11174] AH02951: mod_ssl does not seem to be enabled
[Sun Nov 08 03:28:01.168564 2020] [mpm_prefork:notice] [pid 11174] AH00163: Apache/2.4.46 () configured -- resuming normal operations
[Sun Nov 08 03:28:01.168576 2020] [core:notice] [pid 11174] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Nov 09 00:37:39.754360 2020] [proxy_fcgi:error] [pid 24378] [client 150.136.192.92:39689] AH01071: Got error 'Primary script unknown\n'
[Tue Nov 10 01:53:56.920943 2020] [proxy_fcgi:error] [pid 24350] [client 106.13.118.194:54806] AH01071: Got error 'Primary script unknown\n'
[Wed Nov 11 13:52:21.182692 2020] [proxy_fcgi:error] [pid 319] [client 169.45.99.50:59122] AH01071: Got error 'Primary script unknown\n'
[Wed Nov 11 13:54:29.578626 2020] [proxy_fcgi:error] [pid 302] [client 169.45.99.50:57770] AH01071: Got error 'Primary script unknown\n'
[Wed Nov 11 13:54:29.579326 2020] [proxy_fcgi:error] [pid 24378] [client 169.45.99.50:57772] AH01071: Got error 'Primary script unknown\n'
[Wed Nov 11 14:42:03.952827 2020] [core:alert] [pid 3857] [client 106.193.45.134:7908] /var/www/html/.htaccess: AddType requires at least two arguments, a mime type followed by one or more file extensions, referer: http://ec2-54-254-14-220.ap-southeast-1.compute.amazonaws.com/admin/add-questions?node=EX-803724
[Wed Nov 11 14:42:11.233041 2020] [core:alert] [pid 25769] [client 106.193.45.134:7909] /var/www/html/.htaccess: AddType requires at least two arguments, a mime type followed by one or more file extensions
[Wed Nov 11 14:42:17.225650 2020] [core:alert] [pid 24330] [client 106.193.45.134:7913] /var/www/html/.htaccess: AddType requires at least two arguments, a mime type followed by one or more file extensions
[Wed Nov 11 15:12:03.140625 2020] [mpm_prefork:notice] [pid 11174] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Nov 11 15:24:56.800211 2020] [suexec:notice] [pid 12386] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Nov 11 15:24:56.816223 2020] [lbmethod_heartbeat:notice] [pid 12386] AH02282: No slotmem from mod_heartmonitor
[Wed Nov 11 15:24:56.816270 2020] [http2:warn] [pid 12386] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Wed Nov 11 15:24:56.816276 2020] [http2:warn] [pid 12386] AH02951: mod_ssl does not seem to be enabled
[Wed Nov 11 15:24:56.818907 2020] [mpm_prefork:notice] [pid 12386] AH00163: Apache/2.4.46 () configured -- resuming normal operations
[Wed Nov 11 15:24:56.818930 2020] [core:notice] [pid 12386] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Nov 11 15:28:05.126291 2020] [mpm_prefork:notice] [pid 12386] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Nov 11 15:28:06.178758 2020] [suexec:notice] [pid 12467] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Nov 11 15:28:06.194217 2020] [lbmethod_heartbeat:notice] [pid 12467] AH02282: No slotmem from mod_heartmonitor
[Wed Nov 11 15:28:06.194265 2020] [http2:warn] [pid 12467] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Wed Nov 11 15:28:06.194277 2020] [http2:warn] [pid 12467] AH02951: mod_ssl does not seem to be enabled
[Wed Nov 11 15:28:06.196829 2020] [mpm_prefork:notice] [pid 12467] AH00163: Apache/2.4.46 () configured -- resuming normal operations
[Wed Nov 11 15:28:06.196853 2020] [core:notice] [pid 12467] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Nov 11 20:04:20.990338 2020] [proxy_fcgi:error] [pid 12468] [client 130.61.96.72:22196] AH01071: Got error 'Primary script unknown\n'
Screenshot headers problem due to header?? there is no xlsx mime type!!!
Answer
Solution:
[12-Nov-2020 04:57:10 UTC] PHP Notice: Undefined index: role in /var/www/html/admin/add-questions.php on line 159
[12-Nov-2020 04:57:10 UTC] PHP Notice: Undefined index: role in /var/www/html/admin/add-questions.php on line 176
[12-Nov-2020 04:57:10 UTC] PHP Notice: Undefined index: role in /var/www/html/admin/add-questions.php on line 192
[12-Nov-2020 11:12:02 UTC] PHP Notice: Undefined index: avator in /var/www/html/assets/app/auth.php on line 85
[12-Nov-2020 11:12:15 UTC] PHP Fatal error: Uncaught Error: Call to undefined function simplexml_load_string() in /var/www/html/admin/constants/SimpleXLSX.php:542
Stack trace:
#0 /var/www/html/admin/constants/SimpleXLSX.php(416): SimpleXLSX->getEntryXML('_rels/.rels')
#1 /var/www/html/admin/constants/SimpleXLSX.php(206): SimpleXLSX->_parse()
#2 /var/www/html/admin/app/import-question.php(12): SimpleXLSX::parse('/tmp/phpVZdYx2')
Installed php-xml package, after that it worked.. thanks Aleksander Wons
Source