• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Incorrect cgi-bin configuration

davorg

Basic Pleskian
I'm running 12.5.30 Update #54 on Centos 7.2.

At some point in the last few updates my cgi-bin configuration has been broken and many of my CGI programs have stopped working.

For some of my domains (and I think it might be all of my top-level domains - not the sub-domains) the generated http.conf file is missing a ScriptAlias definition. This means that any requests to cgi-bin are directed to the server's default cgi-bin (/var/www/cgi-bin) and not the domain's own cgi-bin directory (/var/www/domain.tld/cgi-bin).

Obviously the programs aren't in that directory, so the web server generates a 404 error and the error log says stuff like:

"script not found or unable to stat: /var/www/cgi-bin/foo.pl"

I have vague memories of this setting being changed in some older version of Plesk. When I look at the 'cgi_bin_mode' parameter in the dom_param table, they are all set to 'webspace' - which seems to be the correct setting.

Can anyone point to documentation of this change?

And, until I can get this fixed, can someone let me know what ownership and permissions, files in the main /var/www/cgi-bin directory will need in order to be usable by other domains? I've tried making them owned by apache:apache, but I now get a 500 error and a vague "End of script output before headers" error in the log. I think that's a suexec error, but I can't find the suexec log that I used to use to diagnose that.

Thanks for any advice you can give.

Dave...
 
Make sure that you have no any custom vhost templates in /usr/local/psa/admin/conf/templates/custom/ directory. Most probably that default cgi-bin behaviour was customized once.
 
Thanks for the suggestion. That directory doesn't exist.

$ sudo ls /usr/local/psa/admin/conf/templates/custom/
ls: cannot access /usr/local/psa/admin/conf/templates/custom/: No such file or directory
 
Try to update configuration of domains with following command:

# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select name from domains"`; do /usr/local/psa/bin/domain -u $i -cgi-mode webspace; done
 
Thanks for your help.

I've run that command, but it's not clear what it actually does.

I assume it updates the dom_param table - but as I said in my question, that was already set correctly. It doesn't seem to regenerate any http.conf files. They are still dated yesterday and still don't contain any ScriptAlias configuration.
 
Hi davorg,

When I look at the 'cgi_bin_mode' parameter in the dom_param table, they are all set to 'webspace'
Actually, the setting "webspace" is the "old-style" from former Plesk versions. Since 11.5 the usage changed to "www-root". Pls. consider to use the following commands:

Code:
plesk db "select id from domains where name = 'YOUR-DOMAIN.COM'"
or
Code:
plesk db "select id from domains where name = 'SUB-DOMAIN-NAME.YOUR-DOMAIN.COM'"
This print out the corresponding ID from your (sub)domain.

Code:
plesk db "insert into dom_param (dom_id, param, val) values (XX,'cgi_bin_mode','www-root')"
... where XX should be replaced with the previous ID - output. The command will change the "cgi_bin_mode" to "www-root" for the depending (sub)domain.

Code:
plesk repair web YOUR-DOMAIN.COM
or
Code:
plesk repair web SUB-DOMAIN-NAME.YOUR-DOMAIN.COM
This will regenerate the domain - specific configuration files for the domain "(SUB-DOMAIN-NAME.YOUR-DOMAIN.COM)YOUR-DOMAIN.COM".

Pls. check the current configuration afterwards with:
Code:
grep -R 'ScriptAlias "/cgi-bin/"' /var/www/vhosts/system/YOUR-DOMAIN.COM/conf
or for sub-domains:
Code:
grep -R 'ScriptAlias "/cgi-bin/"' /var/www/vhosts/system/SUB-DOMAIN-NAME.YOUR-DOMAIN.COM/conf
... and when the output includes "/var/www/vhosts/YOUR-DOMAIN.COM/httpdocs/cgi-bin/" OR "/var/www/vhosts/YOUR-DOMAIN.COM/SUB-DOMAIN-NAME.YOUR-DOMAIN.COM/cgi-bin/" ( for sub-domains! ) ... you should be fine now. ;)
 
Last edited by a moderator:
Thanks for your suggestions, but this still doesn't seem to work.

Code:
ariaDB [psa]> select * from dom_param where param = 'cgi_bin_mode' and dom_id in (select id from domains where name like '%mag-sol.com');
+--------+--------------+----------+
| dom_id | param        | val      |
+--------+--------------+----------+
|     63 | cgi_bin_mode | www-root |
|     72 | cgi_bin_mode | www-root |
|     69 | cgi_bin_mode | www-root |
|      1 | cgi_bin_mode | www-root |
|     64 | cgi_bin_mode | www-root |
|     65 | cgi_bin_mode | www-root |
|     83 | cgi_bin_mode | www-root |
|     68 | cgi_bin_mode | www-root |
|     66 | cgi_bin_mode | www-root |
|     67 | cgi_bin_mode | www-root |
|     62 | cgi_bin_mode | www-root |
+--------+--------------+----------+
11 rows in set (0.00 sec)

Code:
# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e 'select name from domains where name like "%mag-sol"'`; do plesk repair web $i; done

Time passes...

Code:
# grep -R -l ScriptAlias /var/www/vhosts/system/*mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/code.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/faith.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/git.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/perlanet.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/rpm.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/stuff.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/svn.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/trac.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/wiki.mag-sol.com/conf/httpd.conf
/var/www/vhosts/system/willow.mag-sol.com/conf/httpd.conf

Note that this final list contains entries for ten domains, while the original SQL query returned eleven domains. The one that is missing is the top-level domain "mag-sol.com". Which is, of course, the one I'm most interested in!

Cheers,

Dave...
 
Hi davorg,

the Plesk repair utility has as well the option to be used with the "-v" command - string, which is the equivalent for VERBOSE output ( similar to "debug" ) for the performed commands and depending operations. You should then have the possibility to investigate possible issues/errors/problems in the corresponding repair - log at "/var/log/plesk". Consider to post the corresponding log - file, if you need help with these investigations.

Pls. consider as well to use commands with the EXPLIZIT name "mag-sol.com", so that you are able to investigate, what the root cause of your issue might be.
 
Code:
# plesk repair web -v mag-sol.com

Repairing web server configuration
    Repairing web server configuration for the domain mag-sol.com ... [OK]

Error messages: 0; Warnings: 0; Errors resolved: 0

And in the log:

Code:
# cat repair-20161210-093239.log
[2016-12-10 09:32:39]
[2016-12-10 09:32:39] Repairing web server configuration
[2016-12-10 09:32:39] Repairing web server configuration for the domain mag-sol.com ...
[2016-12-10 09:32:42] [OK]
[2016-12-10 09:32:42] Error messages: 0; Warnings: 0; Errors resolved: 0

So Plesk doesn't report any errors. It just ignores the cgi-bin configuration on top-level domains.
 
Hi davorg,

could you ples check the subscription settings with for example:
Code:
plesk bin subscription --info mag-sol.com | grep CGI
 
Sorry for the delay in replying. I've been fighting fires elsewhere :-(

Here is the output you asked for:

Code:
# plesk bin subscription --info mag-sol.com | grep CGI
CGI support:                            Yes
FastCGI support (required for Ruby on Rails):Yes
CGI support:                            0
FastCGI support (required for Ruby on Rails):0

The first mention of CGI support is from the "Hosting" section. The second is from the "Web Users" section.

Running this code the domain "code.mag-sol.com" (where CGI is working fine) gives the same output.

Code:
[root@faith ~]# plesk bin subscription --info code.mag-sol.com | grep CGI
CGI support:                            Yes
FastCGI support (required for Ruby on Rails):Yes
CGI support:                            0
FastCGI support (required for Ruby on Rails):0

Thanks,

Dave...
 
Back
Top