cups
cups copied to clipboard
Cups web server
I was wondering if it is possible to get the CUPS web interface linux to run php . I ask this because it is installed and already running . I would like to work in additional printer and scanning related functionality through that web interface. It also makes perfect sense that it be integrated into the same interface.
@markosjal Yes, it is possible. Look at the http://localhost:631/help/cgi.html documentation on setting this up.
Not quite so easy. I followed the instructions and after a cups restart PHP code is displayed on page .
So I made sure php was installed , but do not think I need it???
Now after full system restart the phpinfo.php page i created downloads in browser
PHP is not processed
Using Linux Mint 20.1 Ulyssa (based on Ubuntu 20.04) and CUPS from repos
@markosjal Depending on the version of CUPS you are using, you might also need to make sure the execute bit (chmod +x filename.php) is set.
set phpinfo.php with execution bit chmod +x owner is root:root just like the other files there no PHP scripts are executed. Instead. phpinfo.php is downloaded.
There is something missing in the docs to get this working
@markosjal Can you attach the PHP file you are using?
The funtionality is compile time dependent, in 2018 libcupscgi1 was removed and is not packages anymore in ubuntu and think in debian too. I am really not sure what that means, could it be that it is unavailable since version 2.2.9?? Can anyone confirm that it is working in other distros or Macos?
@jschwender The CGI support was simplified in CUPS 2.0, but unfortunately the documentation hasn't been updated.
All that is required is to create a MIME .types file (call it cgi.types) in /etc/cups and then list the extensions you use, e.g.:
application/x-httpd-cgi cgi php
will allow any executable file in the document root with the extensions "cgi" or "php" to be run as a CGI script. You also need the #! line to tell the system which interpreter to use, e.g.:
#!/usr/php -fn
<?php
...
?>
Anyways, I am in the process of updating the documentation and adding some explicit tests to the CUPS sources so this works as expected.
Documentation changes and examples added to Apple CUPS:
[master d03753f33] Update CGI documentation and add testable examples for CGI support (Issue #5940)
and OpenPrinting CUPS:
[master 3318d9f4f] Update CGI documentation and add testable examples for CGI support (Apple #5940)
@markosjal Please let me know if these examples help you get your PHP scripts to work.