Topic: Complete Rails and developer tool installation for a new Mac user....

I've just made the move over to Mac, a new MacBook Pro, to be more precise. And I now love Macs.

However, there's still a few things that need configuring on the web development front before I'm infatuated with OS X, i.e. a Parallels installation of XP with access to the OS X localhost, a proper Rails installation (after InstantRails on my old XP machine, Locomotive just isn't doing it for me), and a proper local Apache + MySQL configuration, instead of standalone MAMP. It's a bit messy at the moment.

These divided, standalone, tools just don't feel right - OS X might feel nicer, but it just isn't as easier to configure, on the web development front, at least, as XP was. Excuse the newbie, but that's how it is for me. Unless Leopard can fix things, I think I prefer my machines to be a clean slate, rather than shipping with broken web tools that need extensive, step-by-step, tutorials before they're anywhere near up & running.

So, I'm trying to get my head around the confusion I'm now in. Here's a list of things as they fly off my head, so if you can order them and help me out, you're a legend, and maybe we can use this as a reference point for Mac webdev newbies until Leopard arrives;

- I came to the Rails forum to get some opinions on Locomotive. I tried going through a Facebook app on Rails tutorial, and ran into all kinds on problems when connecting to MySQL from Locomotive (I have Web sharing disabled and, as far as I'm aware, I use MAMP for my MySQL host), i.e. I don't know how to connect Locomotive to a MAMP MySQL, and I'm sure it's not the recommended setup anyway, so I'm not going to try. Do I dump Locomotive and go for the proper, Hivelogic, install of Rails? What about my MAMP installation taking charge of MySQL - will this mess things up for the proper installation of Rails?

- I've completely failed to connect to 'mysqladmin' or make any configuration of mysql via the terminal - I just don't know what directory I need to get myself into to make this work - and I think I've tried them all. I'm sure using MAMP is making this infinitely more confusing, because I'm not 100% sure that I'm using MAMP for MySQL duties. When I create a new MySQL db in phpMyAdmin in the MAMP start page, it seems to add this to the mysql folder in the MAMP application folder, so that would suggest so. MAMP is configured to use port 80 for Apache and port 3306 for MySQL, i.e. the default ports, so I don't know if this cuts out the MySQL that currently sits on OS X.

- This leads me onto a problem with configuring access a Apache+MySQL server that can host across OS X and a Parallels installation of XP. Now, I've gotten quite far with this; I can create a virtual host called 'local' for the MAMP Apache 'localhost'. I can connect to http://local/ in XP too. But, as soon as I hit a link in a CMS installed on http://local/ on OS X, the real server name is generated by the CMS (because it all runs from 'localhost' MySQL), i.e. http://localhost/wordpress, and everything breaks in XP, because 'localhost' is the reserved name on the loopback IP (127.0.0.1) on XP. This means that I need to setup another MySQL server on OS X. This tutorial explains how to do so;

http://dev.mysql.com/doc/refman/4.1/en/ … rvers.html


But, because I'm using MAMP, and because I can't connect to mysql whatsoever from the terminal, I can't do this walkthrough, and I can't get a second MySQL server up and running.


- Whilst browsing this great forum, I came across some details of the Apple developer tools kit, and I'm not sure if I have this installed (does this come on a brand new, Santa Rosa, MacBook Pro?), and if I should attempt to install it anyyway. The same goes for the MacTools kit - apparently this can make it easier to install Rails...

- All this leads to one thing; is there a fantastic, up-to-date, easy to follow installation guide for getting Apache, MySQL, phpMyAdmin, and Rails running on a Mac piloted by a new Mac user? And, is there a guide that covers getting a Parallels XP connected to a nice clean local server, from which all sites installed on OS X are accessible on XP, with no need to faff with the URLs?

If you can help me with one of these, you're great. If you can answer all, I'll probably try to kiss you, because I've spent weeks trying to get this working.

Any help is much appreciated!

Neil

Re: Complete Rails and developer tool installation for a new Mac user....

I highly recommend the Hivelogic installation. I've done it several times and haven't had any problems with it. It uses Mongrel instead of Apache, but I don't think this is a problem for development. You can still set up apache for PHP, just use Mongrel for Rails.

If you go through this tutorial, MySQL should work from the terminal. I recommend getting used to this instead of phpMySQL. Most of the time you will be using migrations in Rails anyway.

Parallels might just work. Try connecting to http://127.0.0.1:3000 in parallels and see if it works (once you have mongrel started).

Railscasts - Free Ruby on Rails Screencasts

Re: Complete Rails and developer tool installation for a new Mac user....

I second the Hivelogic install, I had it setup and running in no time. You're right, you need to install XCode, which you can get from the Apple site or on the CDs that came with your Mac. I recommend the CDs as it's a good 700 MB, so the download might take a while.

Re: Complete Rails and developer tool installation for a new Mac user....

Thanks for the replies.

I finally managed to fix the Parallels problem. I somehow came across activeCollab (which looks pretty cool from the limited time I've spent playing with it), and the installation script enabled me to choose the absolute URL that I wanted the CMS to reference. I chose /local/ (being the virtual host name configured on MAMP) and it worked! So, virtual hosts can enable a CMS installed on 'localhost' to generate links from a virtual host name, they just need to be told to do so in their config files! WordPress also requires a database refresh too, though. But it all works now! I'm not far from reaching my holy grail web dev platform!

That also means that I've got MAMP working the way I want it to, and although I'm sure it wouldn't be a problem to do the same thing on the pre-bundled version of Apache, I'm tempted to stick with MAMP now. But that also means I need to get Locomotive working with the MAMP MySQL installation, because MAMP MySQL socket is using the default MySQL port, which the OS X pre-bundled MySQL will no doubt want to use. Does MySQL still run if Web Sharing (i.e. Apache) is disabled?

So Xcode definitely doesn't come installed on the latest version of OS X on a new MBP? Will installing it at this point affect any software I might have installed, i.e. my MAMP configuration?!?

Re: Complete Rails and developer tool installation for a new Mac user....

Neil wrote:

Does MySQL still run if Web Sharing (i.e. Apache) is disabled?

Yep. If you ran all the packages you get from the MySQL installation it should have set up a system preference panel where you can start/stop mysql.

Neil wrote:

So Xcode definitely doesn't come installed on the latest version of OS X on a new MBP?

It doesn't come installed by default.

Neil wrote:

Will installing it at this point affect any software I might have installed, i.e. my MAMP configuration?!?

It shouldn't. I recommend backing up the config files though.

Railscasts - Free Ruby on Rails Screencasts

Re: Complete Rails and developer tool installation for a new Mac user....

Thanks Ryan. I think I might have confused myself over MySQL - it doesn't come pre-bundled on OS X with Apache, does it?

Re: Complete Rails and developer tool installation for a new Mac user....

I don't think so, but I'm not positive. Either way I recommend downloading the package and installing that.

Railscasts - Free Ruby on Rails Screencasts

Re: Complete Rails and developer tool installation for a new Mac user....

If MySQL doesn't come installed by default (I'm only sure about Apache coming bundled with OS X) then that would certainly explain why I haven't had any luck using MySQL from the command line. I'd have to be in the right directory within the MAMP application folder to access it, wouldn't I?

Now that I have a lovely cross-OS local server, can I configure one of the popular Rails servers to do the same thing? I.e. can I edit a config file in Webrick, Lighttpd, and configure a virtual host that will work across Parallels? I know that using IP addresses will work, but when URLs are dynamically generated by Rails, surely they'll all point to /localhost:3000/ which will obviously break if I'm testing a Rails app in XP...

How do you guys feel about using the OS X Apache installation for Rails?

Re: Complete Rails and developer tool installation for a new Mac user....

Righto - I've followed the Hivelogic installation walkthrough, and its great. However, there is a few things that I thought were worth noting; it doesn't take you through the process on creating a password for the root MySQL account user, and I ran into a couple of errors when trying to download Rails - the error message I received wasn't covered in the walkthrough, but I found that I just had to keep repeating the Rails installation command until it I was finally connected to the Rails download source.

Everything is nearly up & running perfectly, i.e. I can run through the 'Using Ruby on Rails for Mac OS X' tutorial, and I'm having fun being back at the command line, and not having to tinker with Locomotives' GUI! But there's one last issue which I'm not sure will affect Ruby on Rails - I've run across some permissions errors when using WordPress (or any PHP based CMS's) that must be related to my new installation of MySQL or PHP. Does anyone know how to resolve the following and if they will affect Rails(?);

# Error: /config/config.php is not writable
# Error: /public/files is not writable
# Error: /cache is not writable
# Error: /upload is not writable

Re: Complete Rails and developer tool installation for a new Mac user....

I have PHP aswell as Ruby and Rails installed on my computer together with MySQL. The way I did the installation was following Hivelogic's guide (first for LightTPD). Then I came across a guide that helped me configure my PHP to run on LightTPD. I prefered that rather than Apache. However, I recommend to just install Rails with Mongrel.

For your PHP installation I recommend Marc Liyanage's PHP package. Almost a one-click-installation.

Regarding the administrative part of MySQL I recommend YourSQL and MySQL Administrator (from MySQL themselves). YourSQL is nice since you can see the data stored in your database, but MySQL Administrator is way better otherwise (according to me).

Re: Complete Rails and developer tool installation for a new Mac user....

Neil wrote:

- I came to the Rails forum to get some opinions on Locomotive. I tried going through a Facebook app on Rails tutorial, and ran into all kinds on problems when connecting to MySQL from Locomotive (I have Web sharing disabled and, as far as I'm aware, I use MAMP for my MySQL host), i.e. I don't know how to connect Locomotive to a MAMP MySQL, and I'm sure it's not the recommended setup anyway, so I'm not going to try. Do I dump Locomotive and go for the proper, Hivelogic, install of Rails? What about my MAMP installation taking charge of MySQL - will this mess things up for the proper installation of Rails?

I don't think the MAMP-MySQL should produce any problems, as long as you use the correct port (MAMP does not use the default one)

Neil wrote:

But, because I'm using MAMP, and because I can't connect to mysql whatsoever from the terminal, I can't do this walkthrough, and I can't get a second MySQL server up and running.

I recommend you install the Package from MySQL.com and dump MAMP. It installs MySQL into one of the default bin folders

Neil wrote:

- Whilst browsing this great forum, I came across some details of the Apple developer tools kit, and I'm not sure if I have this installed (does this come on a brand new, Santa Rosa, MacBook Pro?), and if I should attempt to install it anyyway. The same goes for the MacTools kit - apparently this can make it easier to install Rails...

ryanb wrote:

It doesn't come installed by default.

but it is on the OS X dvd shipped with the MBP (at least it was on mine, bought it 1/2 year ago). if not you can register at http://developer.apple.com/ and download it.

Re: Complete Rails and developer tool installation for a new Mac user....

Thanks Mutle.

MAMP & Locomotive are history (woohoo!) and I now have MySQL, PHP and phpMyAdmin installed in combination with the pre-bundled Apache installation (I presume it isn't a problem to stick with version 1.3 for the time being?).

Rails is also up and running. However, I still have two issues;

I'm running XP on Parallels, and because I like to work on things locally, I configured Apache as a virtual host named 'local', so that I can access my /Sites/ folder (configured as htdocs in httpd.conf) in XP (for IE browser debugging). This means that I have a cross OS testing environment for everything that runs from Apache. Rails is using Mongrel, and this means that I'll either need to configure Rails sites to run from Apache, or to get Mongrel (or one of the bundled Rails webservers) configured with a virtual host, i.e. 'localrails'. I'm not sure which is the best way to go, so I'd appreciated some advice!

Second issue - after installing PHP, MySQL and phpMyAdmin separately, I'm now seeing file permission errors when trying to run PHP scripts in my /Sites/ folder. I'm the only user on OS X, and should be configured as the admin. I've checked out the file permissions for the folder, and 'Neil' is supposed to be the owner of the folder and have 'Read/Write' permissions. However, I'm still seeing error messages, such as the following
(taken from ActiveCollab installation script);

    * OK: PHP version is 5.2.2
    * OK: 'mysql' extension is loaded
    * OK: 'gd' extension is loaded
    * OK: 'simplexml' extension is loaded
    * Error: /config/config.php is not writable
    * Error: /public/files is not writable
    * Error: /cache is not writable
    * Error: /upload is not writable

I've noticed that there is also the option to choose 'Group' access for /Sites/, for which my user account is once again selected and given Read/Write access. Then there is 'Others' category, and this has 'Read only' access. Is there an option in there which I need to select and give Read/Write permissions to mysql, php ? Or, is there a MySQL/PHP/Apache config file somewhere, within which I need to give global read/write permissions?

Re: Complete Rails and developer tool installation for a new Mac user....

just chmod 776 the files.

if you got no experience with Terminal, launch Terminal.app and enter the following
cd /path/to/activecollab
chmod 776 -R config/config.php public/files cache upload

Re: Complete Rails and developer tool installation for a new Mac user....

mutle wrote:

just chmod 776 the files.

if you got no experience with Terminal, launch Terminal.app and enter the following
cd /path/to/activecollab
chmod 776 -R config/config.php public/files cache upload

Is it possible to chmod the entire /Sites/ directory? Ever since I've installed php/MySQL I've had this issue with every php based CMS, including WordPress (which was working just fine beforehand).

Re: Complete Rails and developer tool installation for a new Mac user....

Neil wrote:

Is it possible to chmod the entire /Sites/ directory? Ever since I've installed php/MySQL I've had this issue with every php based CMS, including WordPress (which was working just fine beforehand).

sure.
chmod 776 -R ~/Sites

Re: Complete Rails and developer tool installation for a new Mac user....

mutle wrote:
Neil wrote:

Is it possible to chmod the entire /Sites/ directory? Ever since I've installed php/MySQL I've had this issue with every php based CMS, including WordPress (which was working just fine beforehand).

sure.
chmod 776 -R ~/Sites

Thanks - for some mad reason it doesn't find the directory;

neils-computer:~ Neil$ chmod 776 -R ~/Sites
chmod: -R: No such file or directory

When I open up the Terminal I can navigate straight to the Sites folder by typing in 'cd sites', so it's strange that it doesn't find the directory. Do I need to type in sudo su and change over to the super user first?

Re: Complete Rails and developer tool installation for a new Mac user....

oops i'm sorry. the command is supposed to be
chmod -R 776 ~/Sites

Last edited by mutle (2007-07-17 07:38:40)

Re: Complete Rails and developer tool installation for a new Mac user....

mutle wrote:

oops i'm sorry. the command is supposed to be
chmod -R 776 ~/Sites

I just tried that, and it removed all of my permissions, apparently. Before typing that I could access my CMS installations, but I couldn't do tasks such as upload an XML archive into WordPress - now I can't even look at the sites, let alone run the scripts......is there a way of reversing this?

Last edited by Neil (2007-07-17 07:57:38)

Re: Complete Rails and developer tool installation for a new Mac user....

And I've just checked the 'Get Info' on the /Sites/ folder using Finder, and I now have the following set;

Owner: Neil
Access: Read & Write

Group: Neil
Access: Read & Write

Others: No Access (This used to be Read Only)

So - it looks like I'm logged or using a service that is under 'Other' when trying to use either Apache/php/MySQL. Should I just set 'Others' to Read/Write access?

Re: Complete Rails and developer tool installation for a new Mac user....

oki, i thought the apache in os x used your user account. just do chmod -R 777 ~/Sites, which gives other Read/Write/Execute too. the problem with finder is, you can't set the execute flag.