New accounts are not being created with the ScriptAlias directive in httpd.conf

BianchiDude

Well-Known Member
PartnerNOC
Jul 2, 2005
619
0
166
New accounts are not being created with the ScriptAlias directive in httpd.conf

I have to add this line to all accounts manually:
ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/

CGI IS CHECKED in the package,

New Account info returns HasCGI = YES!
| HasCgi: y
| UserName: cditest
| PassWord: testtest

Why isnt it putting the ScriptAlias directive in httpd.conf????
 

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
I'm reviving this very old post because I have this exact same problem, but 3 years later.

I always had to manually add the ScriptAlias directive to the httpd.conf, but now that I've upgraded to Apache2, all those were stripped out!!!

As best I can tell, by looking at /var/cpanel/templates/apache2/vhost.default , Apache2 checks to see if I have mod_alias available (which is nowhere to be found anywhere during the EasyApache 3.2 process) and then checks some sort of "scriptalias" variable to see if it's set to "1".

Here's that logic:
Code:
[% IF supported.mod_alias -%]
[% IF scriptalias == 1 -%]
ScriptAlias /cgi-bin/ [% vhost.documentroot %]/cgi-bin/
[% END -%]
[% END -%]
Where is this setting it's looking at? I don't think it's the "HASCGI=1" option.

The bottom line is that many of my accounts have the "HASCGI=1" set in their /var/cpanel/users/<username> settings file, yet not a single ScriptAlias exists in my httpd.conf file after upgrading to Apache2.

Please help!
Matt
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
308
cPanel Access Level
Root Administrator
What do you have defined in Basic WHM/cPanel Setup for
Code:
* Automatically create a cgi-bin script alias. This setting can be individually overridden during account creation.
 

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
Oh yeah! I forgot about that setting.

It is currently set to "n" with the expectation that individual "allow CGI" checkboxes would enable the feature for the account. But is this option *only* looked at during account creation?

What is supposed to happen during account creation that's not happening now, during a /scripts/rebuildhttpdconf ?

Thanks!
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
308
cPanel Access Level
Root Administrator
If ScriptAlias is disabled in Basic WHM/cPanel Setup and CGI is disabled during account creation, then the VirtualHost is created with these entries and no ScritpAlias:

Code:
    Options -ExecCGI -Includes
    RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
If ScriptAlias is disabled in Basic WHM/cPanel Setup and CGI is enabled during account creation, then ScriptAlias is not added and CGI remains enabled.

Hence: the setting in Basic WHM/cPanel Setup governs the inclusion of ScriptAlias.

The CGI setting in account and package creation determines whether CGI remains enabled.
 

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
To make sure I understand you correctly, I need to have the CGI script alias option in WHM Setup set to "y" if I easily want to use the check box in the WHM Account manager.

Otherwise, when the CGI option in WHM Setup is set to "n", then checking the box in the account manager will have no effect at all (which is what's happening right now)?

Assuming I go back & set the WHM Setup option to "y" & then run /script/rebuildhttpdconf, will all my ScriptAliases magically appear?

Thanks so much,
Matt
 
Last edited:

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
308
cPanel Access Level
Root Administrator
To make sure I understand you correctly, I need to have the CGI script alias option in WHM Setup set to "y" if I easily want to use the check box in the WHM Account manager.

Otherwise, when the CGI option in WHM Setup is set to "n", then checking the box in the account manager will have no effect at all (which is what's happening right now)?

Assuming I go back & set the WHM Setup option to "y" & then run /script/rebuildhttpdconf, will all my ScriptAliases magically appear?

Thanks so much,
Matt
Yes, once you change the setting in Basic WHM Setup, rebuilding httpd.conf will set ScriptAlias appropriately.

Code:
[email protected] [~/tmp]# grep -i scriptalias -c /usr/local/apache/conf/httpd.conf
765
[email protected] [~/tmp]# /scripts/rebuildhttpdconf 
[Cpanel::AdvConfig::apache]: Creating missing document root /home/hometest/data/hmscenar/public_html for hmscenar
[Cpanel::AdvConfig::apache]: Creating missing document root /home/wherecre/home/isthiswr/public_html for isthiswr
[Cpanel::AdvConfig::apache]: Creating missing document root /data/home/bug6005/public_html for bug6005
[Cpanel::AdvConfig::apache]: Creating missing document root /data/home/wheredat/public_html for wheredat
Built /usr/local/apache/conf/httpd.conf OK
[email protected] [~/tmp]# grep -i scriptalias -c /usr/local/apache/conf/httpd.conf
16
[email protected] [~/tmp]# /scripts/rebuildhttpdconf 
[Cpanel::AdvConfig::apache]: Creating missing document root /home/hometest/data/hmscenar/public_html for hmscenar
[Cpanel::AdvConfig::apache]: Creating missing document root /home/wherecre/home/isthiswr/public_html for isthiswr
[Cpanel::AdvConfig::apache]: Creating missing document root /data/home/bug6005/public_html for bug6005
[Cpanel::AdvConfig::apache]: Creating missing document root /data/home/wheredat/public_html for wheredat
Built /usr/local/apache/conf/httpd.conf OK
[email protected] [~/tmp]# grep -i scriptalias -c /usr/local/apache/conf/httpd.conf
768
The first grep was with ScriptAlias enabled. The second was after disabling it in WHM Setup. The third was after re-enabling it in WHM Setup.

ScriptAlias is not necessary for CGI capabilities; it simply instructs Apache to treat files in the specified directory as CGI programs.
 
Last edited:

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
Worked like a charm!!! Thanks! For the record, here's all I had to do:

1. Login to WHM & go to "Basic cPanel/WHM Setup" (first link).
2. Change the "CGI Script Alias" setting from "n" to "y".
3. Run "/scripts/rebuildhttpdconf".
4. Run "service httpd restart".

Bam! All my ScriptAliases suddenly appeared.

Matt