vletroye / SynoPackages

Various Synology Packages built with Mods Packager
124 stars 23 forks source link

MODS Sample - Simple CGI is downloaded, not executed #6

Open ikalkov opened 4 years ago

ikalkov commented 4 years ago

I have DSM 6.2.2-24922 Update 4 and can install the mod successfully. However, when I try to launch it from the application list, an empty window opens and "index.php" is downloaded, instead of being executed. Other Sample MODS show the same behavior. I can't find any issues in the log files.

Ideas?

vletroye commented 4 years ago

This typically happens when the right version of php is not installed. The latest versions of the cgi router in my packages is using php3.0.

Is it installed on your Synology?

ikalkov commented 4 years ago

Thank you very much for the prompt answer. We have PHP 7.3 installed and this is what router.cgi script is using /usr/local/bin/php73-cgi (https://github.com/vletroye/SynoPackages/blob/master/MODS%20Sample%20-%20Simple%20CGI/package/ui/router.cgi#L54).

Ist 7.3 is what you mean by php3.0? There is no PHP 3.0 package in Synology Packet Center. I see your last commit in MODS Web Console is named "Fix php page being downloaded instead of executed" and this package is working just fine with our DSM configuration. Should I apply these changes to Simple CGI?

vletroye commented 4 years ago

Oh yes, sorry.... I was meaning php7.3.

I just reinstalled the latest MODS_Sample_Simple_CGI.spk to be sure... and it's working fine on my Synology...

Another reason why the script is sometimes downloaded : an error during the execution.. Ex.: due to an access denied.

This can happen if the log file may not be written... : LOG="/var/log/@SYNOPKG_PKGNAME@" Could you check that the two log files exist via ls -la /var/log -rw-r--rw- 1 root root 333 Jan 8 18:44 MODS_Sample_Simple_CGI -rw-r--rw- 1 root root 0 Jan 8 18:44 MODS_Sample_Simple_CGI_ERR

Notice: you may only access /var/log if your are connected as root via ssh drwxr-x--- 16 system log 4096 Jan 8 18:44 log

The execution will also fail if the ini file does not exist: ls -la /usr/local/etc/php73/cli/php.ini -rw-r--r-- 1 root root 8072 Oct 29 22:06 /usr/local/etc/php73/cli/php.ini

You can do a quick test. As a second line of the router.cgi, type: exit Now, if the router.cgi is correctly called, you should see a message "Sorry, the page you are looking for is not found." instead of the getting the file downloaded

If you get the message, than the issue is with the router.cgi. Simply comment the line declaring the LOG so you won't have access issue with it.

LOG="/var/log/@SYNOPKG_PKGNAME@"

Next, try to execute the script (index.php) directly in the console ssh: /usr/local/bin/php73-cgi -c /usr/local/etc/php73/cli/php.ini -d open_basedir=none /var/packages/MODS_Sample_Simple_CGI/target/ui/index.php

You should get the html page:

Content-type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
  <title>Home | Simple PHP Website</title>
etc....

if you didn't see the message "Sorry, the page you are looking for is not found." but still got the file downloaded, then the pblm is with the web server nor redirecting the call to the router. First check that you are using Nginx and not apache, as HTTP back-end server.

image

If you are using Nginx, then check that the custom config of the package, for Nginx, is linked to the right location: ls -la /usr/syno/share/nginx/conf.d/dsm.MODS_Sample_Simple_CGI.conf

lrwxrwxrwx 1 root root 57 Jan 8 18:44 /usr/syno/share/nginx/conf.d/dsm.MODS_Sample_Simple_CGI.conf -> /volume1/@appstore/MODS_Sample_Simple_CGI/ui/dsm.cgi.conf

If it is there, then it seems to be not load properly. Restart first Nginx to be sure: synoservicecfg --restart nginx

If it still does not work, did you customize Nginx ? its config should load all dsm.*.conf files under /usr/syno/share/nginx/conf.d/ as you can see via: cat /etc/nginx/nginx.conf | grep syno

include /usr/syno/share/nginx/conf.d/dsm.*.conf;

If all these are fine... I would reboot at least once the Synology...

V.

vletroye commented 4 years ago

Another stupid trick which worked for me : clear your cache (Ex. within Chrome : your browsing data).

This is especially valid if you installed/uninstalled/re-installed the package and tried it several times...

ikalkov commented 4 years ago

Oh, wow. Thanks for the detailed answer, I appreciate it. I'll check tomorrow and report.

vletroye commented 4 years ago

I had myself a lot of issues when I wrote and tested this technique with nginx ;)