straup / privatesquare

privatesquare is a simple web application to record and manage a database of foursquare check-ins.
http://straup.github.com/privatesquare/
BSD 2-Clause "Simplified" License
59 stars 15 forks source link

Problems deploying somewhere besides a domain root #4

Closed markpasc closed 12 years ago

markpasc commented 12 years ago

I tried to set up privatesquare at a path on an existing domain, such as www.example.com/privatesquare/, using:

Alias /privatesquare /home/markpasc/privatesquare/www

but this made the api/ endpoint return 404 responses. The Apache error page reads:

The requested URL /home/markpasc/privatesquare/www/api_rest.php was not found on this server.

and the error log gets a:

File does not exist: /var/www/home

so seems like the relevant RewriteRule in www/.htaccess makes Apache misinterpret the rewritten aliased file path /home/markpasc/privatesquare/www/api_rest.php as the URL www.example.com/home/markpasc/privatesquare/www/api_rest.php for some undoubtedly silly reason.

I also noticed the forms in the sign-up and sign-in pages use root-relative URLs instead of the abs_root_url, so the forms only submit to the correct location when deployed to the root of a domain. Additionally I wasn't able to get privatesquare to authorize against Foursquare properly until I switched it to be at the root of a domain.

Is it a boondoggle trying to run privatesquare somewhere besides / yet? I was only trying as I already have a domain with a few other apps like that, but can run it at a domain root for now. (The README mentions it should be possible but seems to me that statement could be boilerplate about Flamework.)

straup commented 12 years ago

No, although I've not tried it with Aliases.

It works fine running it out of a ~ directory for example:

http://example.com/~asc/privatesquare/www/

I can look at this in the morning. As for the relative URLs for signin/out that's just a hangover from old Flamework code; it should be updated (in both places, if necessary).

straup commented 12 years ago

Just noticed this again. Did you ever get it sorted out? @vicchi has done a lot of work to get ps running in non-vanilla environments and added lots of documentation in the README file. That might offer some hints.

markpasc commented 12 years ago

I took another look. I had to add a RewriteBase to the www/.htaccess, for all the reasons named in the documentation: it's a relative substitution in an htaccess, about a directory outside the DocumentRoot. But then it seemed to work fine. (I got a database error checking in, since I neglected to migrate the database—I only updated code to the newest. But I signed in and got that far, so it looks to have worked.)

Just for reference that's:

<Directory /home/markpasc/privatesquare/www>
    Options FollowSymLinks Indexes -MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

<VirtualHost *:80>
    ServerName example.com
    Alias /privatesquare /home/markpasc/privatesquare/www
</VirtualHost>

and:

diff --git a/www/.htaccess b/www/.htaccess
index 74d807f..b1397d3 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -53,6 +53,7 @@ ErrorDocument 403 /403.php

 # Get mod_rewrite fired up
 RewriteEngine on
+RewriteBase /privatesquare/

 # See also: the 'php-ini' command in the root Makefile
 RewriteRule   ^php.ini         - [R=404,L]

Seems like the RewriteBase has to name the path I used in the Alias to work (it didn't work for me in the apache conf section), so I don't know that it can be fixed/defaulted in the www/.htaccess file. Since that solves my problem, and the documented installation techniques use root domains, this seems fixed to me. Thanks!