LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-25-2011, 12:50 AM   #1
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Rep: Reputation: 40
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
 
Old 04-25-2011, 03:48 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
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.
 
1 members found this post helpful.
Old 04-25-2011, 04:04 AM   #3
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by smoker View Post
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

Last edited by Larry James; 04-25-2011 at 04:10 AM.
 
Old 04-25-2011, 07:14 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
1 members found this post helpful.
Old 04-25-2011, 08:43 AM   #5
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by bathory View Post
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
 
Old 04-25-2011, 10:12 AM   #6
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Print output of a script to screen using Perl/Multiple installation of Perl Modules metallica1973 Linux - General 1 02-17-2011 05:59 PM
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
call perl script through another perl script with arguments nanda22 Linux - Newbie 21 07-21-2009 12:18 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 05:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 02:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration