LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   How to enable Perl Script in UserDir? (https://www.linuxquestions.org/questions/ubuntu-63/how-to-enable-perl-script-in-userdir-876894/)

Larry James 04-25-2011 12:50 AM

How to enable Perl Script in UserDir?
 
Can someone tell me how to enable perl script to be run from user directories in Apache2?

My userdir.conf is as follows:
Code:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        AddHandler cgi-script .cgi .pl

        <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options +ExecCGI +Includes MultiViews Indexes SymLinksIfOwnerMatch
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                </Limit>
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all
                </LimitExcept>
        </Directory>
</IfModule>

At present a perl script file will work perfectly if it is in the /cgi-bin/ directory. However, I would like to be able to work on the system as a normal user and perform programming.

When trying to execute a perl script from my public_html director the log reads:

Code:

Options ExecCGI is off in this directory:
I'm running on Ubuntu 10.10. I used apt-get to install the latest version of Apache2 from the default repo.

Thanks in advance for any suggestions or comments.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

smoker 04-25-2011 03:48 AM

The easiest way is to add a .htaccess file to the directory concerned containing :
Code:

Options +ExecCGI
You do not need the + signs in the main config files, which you have included above.

Remember to restart apache after making changes to the main config files. This is not necessary for .htaccess files.

Larry James 04-25-2011 04:04 AM

Quote:

Originally Posted by smoker (Post 4335278)
The easiest way is to add a .htaccess file to the directory concerned containing :
Code:

Options +ExecCGI
You do not need the + signs in the main config files, which you have included above.

Remember to restart apache after making changes to the main config files. This is not necessary for .htaccess files.

Thanks. I forgot to mention that I had tried it in the userdir.conf file with both the + and without the +.

I added an .htaccess file to the directory with the following entry:

Code:

Options +ExecCGI
I tried it with the + and without the +. It still gives the same error.

There might be something before the configuration gets to the userdir.conf file. I tested other options in the userdir.conf to make changes. Not of them took effect such as turning on Indexes and turning it off.

I also tested to see was the userdir.conf file actually being parsed. I did this by purposely misspelling a word. It's being parsed because the server won't load if the userdir.conf syntax is incorrect.

So, something before or after the loading of the userdir.conf is preventing the userdir.conf configuration from being effective.

Thanks for the time and any other ideas.

By the way, I've being manually configuring web servers for a long time. I'm sure I can eliminate Ubuntu's nice configuration arrangement and make one big httpd.conf file that will work. But I'm trying to take advantage of this intended convenient design.

Edit: By the way, most of the other modules have two files in the mods-available area, a *.conf and a *.load. I have just one perl.load module which I used the a2enmod to enable. Is there a perl.conf file that's missing and possible defaulting to preventing ExecCGI from the /home or the public_html directories?

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

bathory 04-25-2011 07:14 AM

Hi,

Ditch the Limit directives and use Allow to see if it actually works:
Code:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root
        AddHandler cgi-script .cgi .pl
 <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options +ExecCGI +Includes MultiViews Indexes SymLinksIfOwnerMatch
Allow from all
 </Directory>
</IfModule>

If it doesn't work check if apparmor forbids the execution of scirpts from inside the homedir

Regards

Larry James 04-25-2011 08:43 AM

Quote:

Originally Posted by bathory (Post 4335466)
Hi,

Ditch the Limit directives and use Allow to see if it actually works:
Code:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root
        AddHandler cgi-script .cgi .pl
 <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options +ExecCGI +Includes MultiViews Indexes SymLinksIfOwnerMatch
Allow from all
 </Directory>
</IfModule>

If it doesn't work check if apparmor forbids the execution of scirpts from inside the homedir

Regards

Thanks, bathory. I replaced the content of my userdir.conf file as you suggested. It didn't make a difference. I had already isolated only the bare elements as presented in all the docs I could find:

https://help.ubuntu.com/8.04/serverguide/C/httpd.html
Quote:

ExecCGI - Allow execution of CGI scripts. CGI scripts are not executed if this option is not chosen.


Most files should not be executed as CGI scripts. This would be very dangerous. CGI scripts should kept in a directory separate from and outside your DocumentRoot, and only this directory should have the ExecCGI option set. This is the default, and the default location for CGI scripts is /usr/lib/cgi-bin.
And

http://library.linode.com/web-server...10.10-maverick
Quote:

File excerpt: /etc/apache2/sites-available/bucknell.net

Options ExecCGI
AddHandler cgi-script .pl
Please lots more but a repeat of the same which appears to be very simple.

Again, no changes I make to the "userdir.conf" file makes any difference unless I either remove it with a2dismod or type a syntax error. If I remove it the ~userdir isn't available for any normal html files. If I type a syntax error Apache2 won't load. If I do anything else, it retains the defaults no matter how I configure the userdir.conf file.

So it appears that something else is affecting this behavior. I'm reviewing the apparmor application which I'm not familiar with. Do you know how to check what it's doing or how to temporary disable it to see if it's the culprit?

The jury is still out on this one.

Thank!

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

Larry James 04-25-2011 10:12 AM

Ok guys, I got it to working. Thanks, bathory, thanks, smoker. Your input helped me to feel more certain that I was missing something very simple and that there wasn't much more to the configuration than what was in the manuals I had read. I revisited each step and it appears the virtual host I was using for my browser wasn't the one that the server was choosing as the default.

I have a number of virtual host setup.

When I accessed the userdir from a different host name it worked. ( http://hera5.apollo3.com , http://newhera5.apollo3.com ). By the way the hera5.apollo3.com is the one in the "default" (00default) file, so I was a bit thrown off by working solely with that one for the preceding 8 hours before posting my query.

If anyone has a similar problem I'll organize the resolution clearer if my quick reference isn't making the best sense.

Thanks again for the input. Your response made it clear that there wasn't something extremely complex that had to be addressed and it was just as simple as adding the Options directive as mentioned in the manual.

This simplicity is most likely the reason I couldn't turn anything up in my many Google searches... it just works!

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames


All times are GMT -5. The time now is 06:54 AM.