# Phpbb forum with rails application

**URL:** <https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009>\
**Category:** Rails\
**Created:** [May 30, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009 "2006-05-30T18:44:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [May 30, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009/1 "2006-05-30T18:44:15Z")

</div>

I would like to knock up a phpbb forum with a rails application.  
I wanted to do this as I want to use ActiveRecord to crawl through the  
user database in the rails app.

Is there a way to do this - on the same domain name and server…

Or does it depend how the server is setup?

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [May 31, 2006, 4:16am UTC](https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009/2 "2006-05-31T04:16:24Z")

</div>

Okay, I see what you mean now.

I wasn’t entirely sure but I think I understand that there are several  
ways to go around this, one of them is your method. Another one would be  
to declare several fastcgi.server in lighttpd for different subdomains.

I just read up on reverse proxying with Apache (I haven’t done anything  
like this before) and it seems I can do a ProxyPassReverse and point  
/foo/ to a subdomain that has been setup (presumebly a virtual host  
which points to the lighttpd server?) - which solves the problem of not  
wanting a subdomain. Am I on the right lines?

Also, wouldn’t it be easier if one declares all those in the lighttpd  
config? How would I host it on lighty, again, without subdomains? Would  
it be proxying again (with lighty, of course)?

Many thanks.

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [May 30, 2006, 8:29pm UTC](https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009/3 "2006-05-30T20:29:23Z")

</div>

I think it depends on how the server was setup. Are you using shared  
hosting  
or do you have a dedicated server and what is the setup for rails and  
for  
php on your server? I did something like this before - where I had a  
php  
app and rails app sharing the same database. What I did was…

-setup apache with mod\_proxy and php and use it to serve the php files  
as  
normal.  
-setup lighttpd to run the rails app on a higher port  
-setup apache virtual hosts to proxy requests to the rails app or  
directly  
serve the php pages depending on the url.

cheers,

AF

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [May 31, 2006, 1:55pm UTC](https://www.ruby-forum.com/t/phpbb-forum-with-rails-application/62009/4 "2006-05-31T13:55:55Z")

</div>

i just finished integrating this and it took some time. Someone here on  
the  
list wrote up a really nice page on the wiki about it which helped a  
great  
deal. I spent a good deal of time working with sessions mostly. What i  
ended up doing was making my sessions table the phpbb sessions table  
(phpbb\_sessions) and making the session\_id cookie the same as phpbb for  
rails and phpbb so that if i logged into my rails app i was already  
logged  
into the forum, and vice versa. I then setup a before\_filter in  
application.rb to check for, say a phpbb cookie to then load the session  
data like this

…  
elsif cookies[:fscookie\_sid] && session[:user].nil?  
sess = Session.find\_by\_session\_id(cookies[:fscookie\_sid],  
:include =\>  
“user”)

```
   if sess && sess.session_user_id > 1

    session[:user] = Hash.new
    session[:user] = sess.user.attributes

    session[:zip] = session[:user]["zipcode"]
    setlocation(session[:zip]) && setdeflocation if session[:zip]

    session.model.session_user_id = sess.user.user_id
    session.model.session_ip = encode_ip
    session.model.session_time = Time.now
    session.model.session_logged_in = 1

   elsif sess && sess.session_user_id == 0
     session.model.session_user_id = 1
   end

 end

```

One thing I did notice is that for some reason the default value of ‘1’  
wasnt being used in the database, so I had to manually set the user\_id  
to 1  
if it was a “guest” user. Still havent figured out why.

If you need any more help you can find me on the rails webchat at  
[http://www.railswebchat.com](http://www.railswebchat.com)

## adam

[http://www.railswebchat.com](http://www.railswebchat.com)
