Test.pl Perl script not working in cgi-bin CENTOS

System hostname
upgrade21.netstores.com (155.138.148.99)Operating system
CentOS Linux 8.4.2105Time on system
Friday, July 9, 2021 6:41 AMKernel and CPU
Linux 4.18.0-305.3.1.el8.x86_64 on x86_64

I am testing the CENTOS installation of Virtualmin again, and have the same issue with a basic perl cgi-bin of standard default virtualhost.

I create a new virtualhost http://wwwc.netstores.com with a standard helloworld perl file.
http://wwwc.netstores.com/cgi-bin/test.pl

It does not work.

I know that CENTOS is end of life, but this is a simple perl file.

[root@upgrade21 cgi-bin]# perl test.pl
Content-type: text/html

Hello World![root@upgrade21 cgi-bin]# more test.pl
#!/usr/bin/perl

use strict;
use warnings;

print “Content-type: text/html\n\n”;

print “Hello World!”;

Does not work in basic Centos Install

Here is the error and access log from httpd.conf
182.53.36.40 - - [09/Jul/2021:08:09:59 +0000] “GET /cgi-bin/test.pl HTTP/1.1” 500 527 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36 OPR/77.0.4054.172”
182.53.36.40 - - [09/Jul/2021:08:10:01 +0000] “GET /cgi-bin/test.pl HTTP/1.1” 500 527 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36 OPR/77.0.4054.172”

error
[Fri Jul 09 08:10:00.007291 2021] [cgid:error] [pid 26542:tid 140440506451712] [client 182.53.36.40:53255] End of script output before headers: test.pl
[Fri Jul 09 08:10:01.742685 2021] [cgid:error] [pid 26542:tid 140440380561152] [client 182.53.36.40:53261] End of script output before headers: test.pl

I explained the situation with CentOS 8 in some depth on one of your other threads.

To summarize: We don’t recompile Apache on CentOS 8 (but we did on 7 and below), so suexec only works in /var/www. You’d have to recompile to make it run anywhere else. We consider CGI and suexec deprecated. There is always a better way to run applications than CGI.

CentOS 8 isn’t EOL. It’s the recommended version of CentOS for new Virtualmin installs. But not if you absolutely must have CGI working for Virtualmin-managed domains.

Joe, I understand that php has become the application programming application of choice, hence whmcs which I have already tested and works on the OS.

So I just tested CentOS 7, and was able to get cgi-bin working in that version.

see: http://wwwc7.netstores.com/cgi-bin/test.pl

System hostname
upgrade23.netstores.com (127.0.0.1)Operating system
CentOS Linux 7.9.2009Time on system

but I was unaware on the CENTOS
Operating system
CentOS Linux 8.4.2105

That the only place for cgi to work is in /var/www

I will test that.

Now I can include the httpd.conf from cpanel / Centos CENTOS 6.10 If I can attach to see if I can get similar use with CentOS 7.

http://wwwc7.netstores.com/httpd.conf

So, I tried putting the test.pl file in /var/ww/cgi-bin and still get an error.

So, I have not seen a post on what to do with Centos 8 to get the script aliases to work.
I absolutely need to have a version that will run all the programs. Do you have any other install for say Centos 6?

I just really need to recompile a CENTOS to work like the Cpanel apache configuration and I would be very happy to see if I can get the one script alias bin to work for all Vhosts on the server the same as the httpd.conf from the apache configuration on the Cpanel version I am running now.

Perhaps you know someone that is a Cpanel Easy Apache 4 configuration expert that can help recompile the Apache on CENTOS 7 (the method done by cpanel) and make work on the virtualmin/webmin solution.

I am very impressed with the interface, but I have many years experience, but not with reconfiguring apache and always relyed on Cpanel tech support for configuration/upgrade issues.

httpd -v
Server version: Apache/2.4.41 (cPanel)
Server built: Jan 21 2020 16:06:23

vs
Server version: Apache/2.4.6 (CentOS)
Server built: Dec 13 2020 00:35:05

Any thoughts on how to compile apache with the same configuration / modules enable as the cpanel EasyApache4 compiled version that uses the httpd.conf that I linked to?

Please pick one OS and one topic here in the forum and stick to it until the problem is understood and a solution implemented. I’ve already told you how to make this work on Ubuntu; you were like 30 seconds away from having it working.

The one OS you choose cannot be CentOS 6; it reached end of life months ago. And, it has exactly the same CGI+suexec implementation as CentOS 7: We rebuilt the suexec package to point to /home. There is no reason at all to even consider a dead OS version, and we will not support deployment on a dead OS version.

And, you should not recompile Apache unless you really know what you’re doing (and probably not even then). I’m sorry I mentioned it. I was not recommending you recompile Apache. I was saying that’s the only way to make CentOS 8 run suexec apps in /home, which is where Virtualmin puts domain user homes. My recommendations are, in order:

  1. Don’t use CGI+suexec, unless you have no choice. There are better ways to run all apps, including Perl apps.
  2. If you must use CGI+suexec, put your apps in the usual location (/home/domain/cgi-bin), and don’t use CentOS 8. Debian/Ubuntu and CentOS 7 all have suexec docroot set to home in a fresh Virtualmin install.
  3. If you absolutely cannot put your apps into the usual location (why not?), use Debian or Ubuntu and configure suexec docroot to point to this other location.

That’s it. You’re making this way too complicated and embarking on dangerous journeys into unsupported and likely poorly maintained custom Apache builds and that’s not going to make your life easier than just putting things where they usually go.

To be clear: If you’d just put your apps into the default suexec docroot (whether that is /home or /var/www), you wouldn’t have to think about recompiling or reconfiguring Apache. If you must keep your apps somewhere other than the suexec docroot, the only options are Debian/Ubuntu with an appropriate suexec-custom config or rebuilding Apache with your preferred docroot (again, this is not a recommendation!).

1 Like

Joe:

Thank you for the clarification on the solution you have created with Virtualmin. I really like the interface, and it may work, but only if I can recompile apache to work the exact same way as the Cpanel, Centos 6 EasyApache4 way. This allows for several options, which I can share with you again the Cpanel httpd.conf as well as the EasyApache4 config file. What this allows, if you read the httpd.conf file, is 1. For all virtual hosts to use the standard public_html directory. 2. Server wide system ScriptAlias in the for both Cpanel Scripts and our Application Scripts 3. php configuration for running apps in php like Whmcs which supports Virtualmin/webin for creating accounts automatically, and 4. Allows for reading files in public_html directory by using the http://domain.com/~userid I need to have all 4 of these Apache options to be able to switch from Cpanel to Virtualmin .

So, I will need to somehow recompile the apache binary to be able to have all of these same features. It is a must. This is the application (the netstores / pos2net ) shopping cart solution.

You can see the apache build custom file from easy apache here:

http://netstores.com/CP/current_state_at_2019.json

And the Apache conf file here.

http://netstores.com/CP/httpd.conf

If you would be so kind to explain where you apache build location is on CENTOS 7, and if I can rebuild the httpd or do you only install the binaries and don’t include the configuration files for the build?

Virtualmin is not cPanel. It is not modeled after cPanel. And, honestly, I don’t really know cPanel; I was required to use it back in the early 00s for a customer and that’s why Virtualmin exists, but that’s the last time I’ve looked at it. You’re never going to get along with Virtualmin as long as you expect it to be cPanel; it just isn’t. We didn’t set out to build a cPanel clone, because we don’t think the way they do things is the right way. So, if what they do is the right way for you and you are happy with cPanel, continuing to use cPanel is your best bet for continuing happiness.

We use the OS-provided packages for everything. Rebuilding packages randomly is a bug not a feature, so we don’t do it except when it’s absolutely unavoidable. The “Apache build location” is on the distro vendor’s build farm, not on your Virtualmin system. And, while we did formerly rebuild Apache, we rebuilt the OS-standard Apache, with no modifications other than the suexec docroot. And, for CentOS 8, we no longer do that, because it’s a bug not a feature, and suexec is no longer the best safe way to run any app. The OS packages will be better tested, receive faster security updates, and be better documented and supported than anything a small company like Virtualmin…or even cPanel…could ever achieve.

This is what I’m trying to say: You should not be rebuilding Apache on a production server. What you’re viewing as an important and valuable feature of cPanel, I view as one of its most serious design flaws.

I will add to that a security SNAFU, if you intend to compile Apache on your own, @netstores. Any delay on your part is compiling will leave you vulnerable to zero day and n day vulnerability in Apache, where n is the number of days you delay in compiling Apache after the latest release is made available.

While most of us aim at automating our work as much as we can, this strategy of yours takes you in the opposite direction.

I thought I should point this out.

Additionally, the pre-compiled Apache that Virtualmin offers is tested by the Apache community for security vulnerabilities. Compile Apache on your own and you are in uncharted waters.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.