Installing Rails and Apache on OS X (PPC)
As of May 3, 2006, these instructions worked perfectly for me on a fresh OS X install. Feel free to post a comment if you run into any errors, and I will do my best to help. Check /private/var/log/httpd/error_log and ~/Sites/Rails/TestRailsApp/log/development.log for errors. If you need to paste a bunch of messages, please use http://rafb.net/paste and link to it in your comments.
2. Open a terminal window
bash> echo $PATH
Make sure /opt/local/bin/ and /opt/local/sbin are first in your path. If they aren’t, then add this line to your ~/.bash_profile:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Close the terminal and open another… make sure step 2 was successful!
3. sudo bash
echo $PATH again to make triple sure step 2 actually worked.
4. port -d selfupdate
5. port install rb-rubygems
6. port install rb-zip (this will probably take _for_ever_)
7. port install fcgi
8. port install lighttpd
9. gem install rails -v 1.0.0 (Yes to all dependencies)*
Note: You can install rails 1.1.0, but for my purposes I wanted to stay with 1.0.0. If you do choose to install 1.1, you can always run step 9 again, then run gem uninstall rails and choose 1.1 to uninstall.
10. gem install fcgi
If you are still sudo’d, then exit to a normal terminal after step 10.
11. mkdir ~/Sites/Rails, cd ~/Sites/Rails
12. rails TestRailsSite
13. Fix permissions so Apache can use the site:
sudo chgrp -R www TestRailsSite
cd TestRailsSite
chmod 0775 db
chmod 0777 log
chmod 0775 public
chmod 0666 log/*.log
14. Configuring Apache
sudo vi /etc/httpd/httpd.conf
Make sure the following lines are somewhere in the file:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
Add this near the bottom of the file:
Alias /piper/ “/Users/YOURUSERNAME/Rails/piper_ror/public/”
Alias /piper “/Users/YOURUSERNAME/Rails/piper_ror/public/”
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
15. Configure project files.
vi public/.htaccess
Make sure these two lines are uncommented (edit as needed, of course):
RewriteEngine On
and
RewriteBase /TestRailsSite/
Change the line ‘RewriteRule ^(.*)$ dispatch.cgi [QSA,L]’ to:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
16. sudo gem install fcgi
I know, we did this once, but for some reason I had a problem with one of my machines and the first install didn’t complete successfully. Running it again at this point has fixed it anywhere I had that problem.
17. sudo apachectl graceful
navigate to http://localhost/TestRailsSite/ and you should see the welcome page!
May 3rd, 2006 11:24
[…] Option 3: Probably one of the hardest ways (Darwinports/Apache/Rails/Fastcgi): If you want to use a library like rb-zip, the only way I could get it to work was to install everything via darwinports. This isn’t the easiest process, but I have broken it down into exact steps. Follow them closely and you shouldn’t have any problems. I have put these steps into a separate article, which you can find here (PPC) or here (Intel). […]
June 7th, 2006 01:09
Hi Bryan
I am a newbie with Rails (even If I am writing OO since 92…) I successfully installed it on my Cube (OS X 10.4.6, Apache 1.4, MySQL 4.1.18)…
I am trying to hook up Rails into Apache, according to your instructions..
BUT
1- LoadModule fastcgi_module libexec/httpd/mod_fastcgi.so
and
AddModule mod_fastcgi.c were added to my conf file
seems quite normal…
2- FastCgiIpcDir /tmp/fcgi_ipc/ and AddHandler fastcgi-script .fcgi where not in my httpd.conf file, so I added these lines… (maybe at the wrong place.. in a block :
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
)
2- when navigating to httpd://localhost/TestRailsSite/
I get an error msg :
The requested URL /TestRailsSite/ was not found on this server…. and the var log gives :
File does not exist: /Library/WebServer/Documents/TestRailsSite/
fastcgi is running well…
[Wed Jun 7 08:40:30 2006] [notice] FastCGI: process manager initialized (pid 13286)
[Wed Jun 7 08:40:30 2006] [notice] Apache/1.3.33 (Darwin) PHP/5.0.4 mod_fastcgi/2.4.2 mod_jk/1.2.5 mod_ssl/2.8.24 OpenSSL/0.9.7i DAV/1.0.3 configured — resuming normal operations
…. seems to be a problem with the directory definition but I am not an indian… so Apache is a little bit confusing…
is it the fact that I am using Apache 1.4 and not 2.0 ?
thansk for your advices
Yves
June 7th, 2006 08:31
Hi Yves,
It could be that you are using Apache 1.4 insead of 2, but I haven’t done any testing with older versions myself. Is there any reason you haven’t upgraded to the new apache?
It looks like my post got munched a little bit during an edit. There should be four lines here that need to be added to the httpd.conf:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
if you run apachectl configtest, does it pass okay?