Running Mojo as CGI without ScriptAlias

1,300 views
Skip to first unread message

Sergey Sinkovsky

unread,
Dec 19, 2010, 2:58:12 PM12/19/10
to mojol...@googlegroups.com
Hi-

I'm trying to start Mojo app as CGI on shared hosting, put everything in cgi-bin directory.
And I'm able to open page.

With my set of controllers I get smth like:
Page not found, want to go <a href="/~user_id//cgi-bin/path/to/app/script/app_name/">home</a>?
Unfortunately I'm not able to use ScriptAlias directive in .htaccess file. I only have mod_rewrite.
When I try to use mod_rewrite rule, I always get wrong redirects to that 
"/~user_id//cgi-bin/path/to/app/script/app_name/" path.
Have anyone set up Mojo on shared hosting and has working solution? 
Please, I really don't want to write that in php :(


--
Sergey Sinkovsky

Charlie Brady

unread,
Dec 19, 2010, 9:21:29 PM12/19/10
to mojol...@googlegroups.com

On Sun, 19 Dec 2010, Sergey Sinkovsky wrote:

> I'm trying to start Mojo app as CGI on shared hosting, put everything in
> cgi-bin directory.
> And I'm able to open page.
>
> With my set of controllers I get smth like:
>
> Page not found, want to go <a
> href="/~user_id//cgi-bin/path/to/app/script/app_name/">home</a>?

Try:

<a href="">home</a>

Or use url_for.

kberov

unread,
Dec 20, 2010, 1:20:58 PM12/20/10
to Mojolicious
Usually on shared hosts the customers (you)
are allowed to set their on things in .htaccess
also in the Document root it is allowed to have cgi scripts if they
are with the extension .cgi.
but you are also able to set whatever file as an executable cgi script
Here is an example:
# Make sure that directory listings are disabled
IndexOptions -FancyIndexing
Options -Indexes +ExecCGI

<Files ~ ".cgi$">
SetHandler cgi-script
</Files>
#set explicitly filenames as cgi scripts
<Files ~ "(amojoapp|anotherapp|thirdapp)$">
SetHandler cgi-script
</Files>

it is also possible to set the script as fcgi script the sameway

AddHandler fastcgi-script .fcgi
#or
<Files ~ "(amojoapp|anotherapp|thirdapp)$">
SetHandler cgi-script
</Files>

#-----------------
Options +ExecCGI -Indexes +FollowSymLinks
#AddHandler cgi-script .cgi
<Files ~ ".cgi$">
SetHandler cgi-script
Options +ExecCGI
</Files>

<Files ~ ".fcgi$">
SetHandler fastcgi-script
Options +ExecCGI
</Files>





This way you can even keep the file structure as created by mojo

Cheers.


On Dec 20, 4:21 am, Charlie Brady <charlieb-m...@budge.apana.org.au>
wrote:

Ulrich Habel

unread,
Dec 21, 2010, 4:37:11 AM12/21/10
to mojol...@googlegroups.com
> Usually on shared hosts the customers (you)
> are allowed to set their on things in .htaccess

[...]

Guys! This is awesome stuff! Thanks for clarifying the usage for .htaccess
files for Mojo! Very cool! We do have some documentation on our growing
wiki about this:

https://github.com/kraih/mojo/wiki/Apache-deployment

@kberov, @Sergey: Could you verify it and merge your configuration parts
and include them inside the wiki? That would be great! I've added a
section about shared environments. Maybe we can mangle the information
together.

Thanks
Uli

Sergey Sinkovsky

unread,
Dec 21, 2010, 7:52:34 AM12/21/10
to mojol...@googlegroups.com
Thanks for your responses.
I managed to configure with cgi-handler in htdocs directory.

so when I access domain.com/my_app/script/my_app it works,
and even routes work as domain.com/my_app/script/my_app/route/path

But I want to configure so I have domain.com/route/path will work and
$self->redirect_to('route') will not redirect to domain.com/my_app/script/my_app/route
but to domain.com/route.

I'm going to play with mod_rewrite and setting ENV variable SCRIPT_FILENAME, cause looks like Mojo uses it.




--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To post to this group, send email to mojol...@googlegroups.com.
To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.




--
Sergey Sinkovsky

Sergey Sinkovsky

unread,
Dec 21, 2010, 11:28:40 AM12/21/10
to mojol...@googlegroups.com
While RewriteRule [E=SCRIPT_NAME:/] didn't work,
$ENV{SCRIPT_NAME} = / in script/my_app did the trick.
--
Sergey Sinkovsky
Reply all
Reply to author
Forward
0 new messages