Leopard

Installing Ruby on Rails on Leopard

Even though Leopard comes with Ruby on Rails develop environment, we have every reason to install the more recent/better versions.

Dan Benjamin finally released the Leopard edition of the installation tutorial. One of the most trusted sources for installing ruby and other tools.

Securing Leopard

A Shorthand for Clearing Cache in Symfony

In developing with symfony, you delete the cache over and over. The symfony command for this is that:

symfony clear-cache

or

symfony cc

The second one is muct shorter, but we can make it far shorter by making an alias for the command.

  1. Open your bash profile file. That would “~/.bash_login”, “~/.profile” or “~/.bash_profile”.
  2. Add the following code: alias cc="symfony cc"
  3. Close the terminal window and reopen. Now the command cc should work as “symfony cc”.

Quick Look Plug-in Organizer

We have a bunch of Quick Look Plug-ins. If you didn’t know you can view inside compressed files, view your code with syntax coloring and view contents of a folder, it might be good idea to visit a dedicated website or another.

As Apple doesn’t provide double-click install as in prefpanes, you need to move the plug-ins manually to the QuickLook folder. Even worse, you need to create the folder if it doesn’t exist.

Here’s my idea. You make an app designed to organize Quick Look plug-ins, which makes install and uninstall easier. It would also be great if you could make the app a prefpane so that we can have the organizer in System Preferences.

Installing symfony via PEAR on Leopard

This documentatoin is still pre-alpha. If you find any error on this tutorial, please email me. Visit projects.


Installing PEAR and symfony

This article assumes you read my “Install PHP and MySQL via MacPorts on Mac OS X 10.5 Leopard”. This article tries to make a web server for a symfony project locally.

We install symfony via PEAR and make it work with the Ajax tutorial on symfony website.

What is PEAR?

Just read the manual.

Installing PEAR

Leopard, unlike its predecessors, doesn’t have PEAR pre-installed. You need to install it manually. We don’t use MacPorts here. PEAR also has an excellent documentatoin. Visit PEAR manual.

curl http://pear.php.net/go-pear > go-pear.php

This step downloads a file need to install pear. The file will be located under your home folder, and the file name is “go-pear.php”. (Note: We don’t use go-pear.org because go-pear.org is not longer available.)

sudo php -q go-pear.php

Follow the instruction. Default setting doesn’t cause any problem. Just your personal preference. (But, I installed the tool under /usr/local/bin. Concerning why, read the Dan Benjamin’s article.)

Now your have pear command tool installed.

How to See Your Configuration

Everytime you come across a setting problem, it’s always useful to check your currnt configuration. You can check your pear configuration by running

pear config-show

As I would like to install beta packages as well as stable ones, I set preferred package state to be beta.

You can do so by running

sudo pear config-set preferred_state beta

Here’s what I have:

Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /usr/local/bin
PEAR documentation directory   doc_dir          /usr/local/share/pear/docs
PHP extension directory        ext_dir          ./
PEAR directory                 php_dir          /usr/local/share/pear
PEAR Installer cache directory cache_dir        /var/folders/qo/qoHKwm05H3eGEek47+j0Hk+++TI/-Tmp-//pear/cache
PEAR data directory            data_dir         /usr/local/share/pear/data
PEAR Installer download        download_dir     /usr/local/temp/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
PEAR Installer temp directory  temp_dir         /usr/local/temp
PEAR test directory            test_dir         /usr/local/share/pear/tests
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  beta
Unix file mask                 umask            22
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/local/bin/gpg
Signature Key Directory        sig_keydir       /private/etc/pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /Users/takaaki/.pearrc
System Configuration File      Filename         /private/etc/pear.conf

Modifying php.ini to Recoginize PEAR installation

Now to make pear work with PHP, you need to add the pear path in your PHP include path by editing php.ini file. The path you need to include is php_dir, in my case /usr/local/share/pear.

mate /opt/local/etc/php.ini

First of all, though not mandatory, but it is highly recommended that you not use magic quotes in PHP. To turn it off, look for “magic_quotes_gpc = On”, which is around line 440. And change it to

magic_quotes_gpc = Off

Next, add th PEAR directory path to include path. Find “include_path”, which is around line 470. Add your PEAR directory, which you can find by running pear config-show and remove the semicolumn (;) at the beginning of the line.

My one looks like this:

include_path = ".:/usr/local/share/pear"

Check if PEAR is recongized with your PHP script

Edit test.php file to check if PHP can work with PEAR.

Open test.php.

mate /opt/local/apache2/htdocs/

Write the following and save it.

<?php

if (require 'PEAR.php') {
    echo "You can now use PEAR with PHP!";
} else {
    echo "PEAR is not recoginzed with your PHP.";
}

?>

Visit localhost/test.php. If you get an error, include_path may very well be wrong.

Installing symfony

Follow the symfony official guide. Find the “PEAR installation”

After installation, let’s check if symfony is properly installed or not. Type the following to get the version number of symfony.

symfony -V

(Note: this is capital/large V. symfony -v won’t work.)

If you see the version number of symfony, symfony is installed successfuly.

Set up a Web Server for symfony

There are three ways to install symfony: a) The sandbox, b) Source Download and c) PEAR instllation. We are using PEAR installation approach. We are going to have a web server for a symfony project running. For other instllation, visit symfony’s documentation.

Our aim is to set up a webserver on a Mac for the Easy Ajax Tutorial on symfony documentaion.

Let’s make several settigs clear. Always keep what you try to do in mind:

  • We make a project called “sfdemo” in the folder named “sfdemo” under your user’s Sites folder.
  • Therefore, your path to the project is /Users/[yourusername]/Sites/sfdemo.
  • Symfony projects require a setting where /web under the project directory is set to web root path. (So, browsers only access to /web directory.)
  • That is, Apache needs to access /Users/[yourusername]/Sites/sfdemo/web when your broweser points http://localhost. (Note: Don’t add .com in the URL.)

Before creating a symfony project, we change Apache configuration file (httpd.conf) so that our project works under localhost.

Open Apache configuration file (httpd.conf).

    mate /opt/local/apache2/conf/httpd.conf

Add the following at the beginning. Replace [yourusername] with a real one. Also replace “/usr/local/share/pear/data” with your PEAR data directory path. You can find your by running pear config-show.

    <VirtualHost localhost:80>
    ServerName localhost
    DocumentRoot "/Users/[yourusername]/Sites/sfdemo/web"
    DirectoryIndex index.php
    Alias /sf /usr/local/share/pear/data/symfony/web/sf
    <Directory "/usr/local/share/pear/data/symfony/web/sf">
    AllowOverride All
    Allow from All
    </Directory>
    <Directory "/Users/[yourusername]/Sites/sfdemo/web">
    AllowOverride All
    Allow from All
    </Directory>
    </VirtualHost>

Save the file and restart Apache web server.

    sudo apachectl restart

You will see a warning as the following.

[warn] VirtualHost localhost:80 overlaps with VirtualHost localhost:80, the first has precedence, perhaps you need a NameVirtualHost directive

This means that you already have a setting for localhost:80 in your Apache configuration file. As this is a warning, not an error, let’s ingnore it for a second. You can tweak the configuration anytime when you learned more about Apache.

Let’s make a symfony project.

First, open Terminal and move to the Sites folder.

cd ~/Sites

And create a directory called “sfdemo” and move to the folder.

mkdir sfdemo
cd sfdemo

Create a project called “sfdemo” and make an application called “app” and a module called “cart”. What each command does is not explained here. Visit the tutorial.

symfony init-project sfdemo
symfony init-app app
symfony init-module app cart

Visit localhost/cart. If everything works fine, you will see a symfony page, saying “Module " cart" created”.

References

SuperDuper! for Leopard Coming in a Few Weeks

Dave Nanian:

Anyway, enough of that. At this point, we’re basically locked down. We have a few UI tweaks to complete, and we should have a final release out to everyone within a few weeks.

You’ll notice this is the first timeframe I’ve provided other than ‘soon’… and that means I’m quite confident it’ll be in your hands shortly. So, once again thanks for your patience, and I really think you’re going to be pleased with the update.”

They took a long time. There are a lot of comments asking when exacty their Leopard-compatible version comes out. Probably the hardest part of developing is to tell the ETA.

Preliminary Report on the Setup

I finally got PHP 5 and MySQL 5 working together on my Mac. I installed them with MacPorts.

I already have PEAR installed as written in a previous blog entry.

Which means… I’m getting close.

You may see a nice write-up on the installation here. Stay tuned. Visit Projects for any progress.

Installing Symfony on Leopard

I installed symfony via pear, but getting a symfony project working on my Mac turned out to be a nasty thing. In Ruby on Rails, you run a server script and visit 0.0.0.0:3000. That’s it. On the other hand, symfony works on Apache. So I really need to know httpd.conf, especially virtual hosts.

It seems that most of the tutorials on symfony official website use MacPorts.

Not so much as tweaking what I just installed, I will have to use MacPorts. I really don’t want to mess up with my system. I don’t have time to understand the instruction. I just need a project working on my Mac.

Installing PEAR on Leopard

PHP that comes with Leopard doesn’t have PEAR. You need to install it manually. Here’s how I installed it.

  1. In Terminal, run curl http://pear.php.net/go-pear > go-pear.php. This step downloads a file need to install pear. The file will be located under your home folder, and the file name is “go-pear.php”.
  2. Run sudo php -q go-pear.php. You will be asked for your password.
  3. Follow the instruction. Default setting doesn’t cause any problem. Just your personal preference. (But, I installed the tool under /usr/local/bin.)

Now your have pear command tool installed. You can check your pear configuration by running pear config-show. As I would like to install beta packages as well as stable ones, I set preferred package state to be beta.

You can do so by running sudo pear config-set preferred_state beta. (Again you may be asked for your password.)

Here’s what I have:

Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /usr/local/bin
PEAR documentation directory   doc_dir          /usr/local/share/pear/docs
PHP extension directory        ext_dir          ./
PEAR directory                 php_dir          /usr/local/share/pear
PEAR Installer cache directory cache_dir        /var/folders/qo/qoHKwm05H3eGEek47+j0Hk+++TI/-Tmp-//pear/cache
PEAR data directory            data_dir         /usr/local/share/pear/data
PEAR Installer download        download_dir     /usr/local/temp/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
PEAR Installer temp directory  temp_dir         /usr/local/temp
PEAR test directory            test_dir         /usr/local/share/pear/tests
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  beta
Unix file mask                 umask            22
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/local/bin/gpg
Signature Key Directory        sig_keydir       /private/etc/pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /Users/takaaki/.pearrc
System Configuration File      Filename         /private/etc/pear.conf

Now to make pear work with PHP, you need to add the pear path in your PHP include path by editing php.ini file. The path you need to include is php_dir, in my case /usr/local/share/pear.

Failing to Compile MySQL

I was installing my system from scratch today. This is a clean install, so I need to install all Unix command-line tools I need. Luckily, though, Leopard comes with updated and new tools such as ruby, rails and svn. But, it doesn’t come with MySQL.

I’m not a user of MacPosts or Fink, so I referred to Dan Benjamin’s tutorial on compiling MySQL. I followed every single step, but I failed and failed. After looking into the problem, I noticed what was wrong.

The problem is that my download of the souce file “mysql-5.0.45.tar.gz” was not complete. I don’t know how curl command works, but here are steps I took instead.

  1. Make a folder named “src” at my home folder
  2. Download the source file and put the file to the src folder. (It says “Compressed GNU TAR archive (tar.gz)” As of this writing, the latest version is 5.0.51.)
  3. Double click the source file to extact files. Here, a folder will show up full with files. (This stem is equivalent to tar command in the tutorial)
  4. Using Terminal, type in cd ~/src/[folder_made_in_step3]. (The name of the folder depends on the name of the source file. The tutorial says “mysql-5.0.45”, but it’s totally up to what version to the source file you downloaded.)

Then, you can start to configure MySQL following the tutorial.

Syndicate content