Topic: Mac OS X Installing Required Software
Topic type: Topic
Describes the steps necessary for installing Kete's required software on a Mac OS X host.
Originally written by Walter McGinnis, Kete Project Lead for Katipo Communications, Ltd.
Part of the Installation Guide
Note: This section covers both Mac OS X 10.4.11 (Tiger) and Mac OS 10.5.1 (Leopard). Referred to as 10.4 and 10.5 from here forward. Pay careful attention to what steps are marked for each
Compatibility Note: A new set of simplified instructions based on the Homebrew package manager (http://github.com/mxcl/homebrew) for Mac OS X 10.6 Snow Leopard and Mac OS 10.5 Leopard are being trialed. This topic will be updated with those instructions in time for the 1.3 release. In the meantime, for 10.6 simply use the 10.5 instructions. For earlier versions of REE, you may need to configure REE with the "--no-tcmalloc" flag (recommended for 10.5, too).
Install MacPorts
Follow the instruction at http://www.macports.org/install.php to install MacPorts on your system. Make sure you meet all the requirements and test it's working before continuing.
Install Required Software for Running Kete
So lets get installing. Run the followig from the console:
10.4: Tiger needs Ruby and RubyGems installed rom MacPorts, so you'll need to run this next command
10.5: Leopard includes Ruby and RubyGems already, so you can skip to the next command
$ sudo port install ruby rb-rubygems
10.x: Then for both systems, run
$ sudo port install git-core memcached nginx wget zlib unzip gzip libxslt pcre yaz zebra curl readline-5 mysql5 +server
10.4: We can install the Ruby-Mysql adapter via MacPorts
$ sudo port install rb-mysql
10.5: We use the gem version of the Ruby-Mysql adapter
sudo env ARCHFLAGS="-arch i386" gem install mysql --with-mysql-config=/opt/local/bin/mysql_config5
Note: If you use Ruby Enterprise Edition or upgrade to a later version of RubyGems, you may to repeat the above step, but with an additional "--" as shown below:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
(optional - enables conversion of uploaded HTML, Plain Text, PDF, and Microsoft Word documents to the description of the document)
$ sudo port install poppler poppler-data wv lynx
(optional - enables support for harvesting embedded metadata in uploaded files, see mini_exiftool gem step later)
$ sudo port install libexif p5-image-exiftool
Installing the Rails framework
You need an installation of Ruby. Ruby Enterprise Edition is a product from the same people that make mod_rails/Passenger (discussed at the bottom of this page). It's optimized to run faster than a standard installation of Ruby. It requires a few extra installation steps, but it's well worth the effort. (for instructions on using debians packages, see an older version of this topic)
The great thing about Ruby Enterprise Edition (refered to as REE) is that the installer does the installing of Ruby and Rails in one go. It takes less than 15 minutes to setup once downloaded (depending on system speed) and less than 10 minutes to update in the future (depending on the amount of sites you have). Start by following the instructions at http://www.rubyenterpriseedition.com/download.html (download, extract, install). Keep the settings as the default ones REE assigns.
Warning: Versions prior to 20090610 contained a security issue which could cause DoS issues. It is highly recommended that you use 20090610 or a newer version when installing. If you have a previous version of Ruby Enterprise Edition, we recommend upgrading it as soon as possible.
Now add the following to the .bash_profile, and .bashrc filea of any users that'll affect the installation (root, kete, and yourself for example). Be sure to use the correct path for REE; it varies by release. Replace the X's in the string below.
# Use correct Ruby, RubyGem paths
PATH=/opt/ruby-enterprise-1.8.6-2009XXXX/bin:$PATH
export PATH
Then as both root and the kete user, check that we are using the correct RubyGems version:
$ which gem
/opt/ruby-enterprise-1.8.6-2009XXXX/bin/gem # should look something like this with correct date
Note: If you plan to use Ruby Enterprise Edition as well as Capistrano, an extra step is necessary. See how to Configure sudo path in capistrano deployments.
Additional Setup Instructions
MySQL
You'll need to append this to your PATH in ~/.profile file:
/opt/local/lib/mysql5/bin
Now we initialize and configure mysql to start at boot time. We'll also set the mysql root password and set up unicode to be the default charset. Make sure you save your mysql root password, you'll need it later!
$ sudo -u mysql mysql_install_db5
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
$ mysqladmin -u root password 'new-password'
We want Unicode (utf8) to be our mysql default character set, too. Create /opt/local/etc/mysql5/my.cnf via sudo and your favorite text editor and place this in it:
[client]
default-character-set=utf8
[mysqld]
init-connect = SET NAMES utf8
character-set-server = utf8
Restart mysql, connect to the default database, and check that it now has the right settings:
$ sudo launchctl stop org.macports.mysql5
$ sudo launchctl start org.macports.mysql5
If the above doesn't work (it should after next reboot), use this:
$ sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop mysql5
$ sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start mysql5
You can confirm that required (system, server) charset variables now point at utf8 by connecting to the mysql database as mysql root (remember you set that password above) and running:
SHOW VARIABLES LIKE 'character_set%';
Aside from file system and dir, everything else should be utf8.
ImageMagick
Kete uses ImageMagick and Rmagick (the ruby binding for Imagemagick) to create thumbnails of images, make captcha images, etc. I'm not super happy with Rmagick's performance, so we might move to ImageScience in the future, but for you now, we need to install this stuff for images.
Unfortunately installation of Rmagick on Mac OS X isn't as easy it should be because the MacPorts version of ImageMagick isn't configured correctly to find the ghostscript fonts. This is a well known issue and thankfully there are instructions for how to make it work.
To install ImageMagick and Rmagick correctly for 10.4 follow steps 4 through 6 in this guide:
http://rmagick.rubyforge.org/install-osx.html
Or on 10.5 use this installer:
http://norbauer.com/notebooks/code/notes/rmagick-for-rails-on-os-x-leopard
Memcached
We'll turn it on as a daemon that will run at boot (thanks Jesse Byler for the revised plist file). You may want to start it only when you are doing development, since it can eat up RAM. You may just want to manage it directly from the command line via the "memcached" command itself.
$ sudo curl -L http://kete.net.nz/documents/0000/0000/0044/local.server.memcached.plist.txt -o /Library/LaunchDaemons/local.server.memcached.plist
Now it is ready to run:
$ sudo launchctl load -w /Library/LaunchDaemons/local.server.memcached.plist
$ sudo launchctl start local.server.memcached
If you aren't running your development Kete server, you probably want to turn off the Memcached daemon with the following (just remember to turn it on again when you do!):
$ sudo launchctl stop local.server.memcached
HTTP Request Server
We recommend Apache 2 in combination with Ruby Enterprise Edition for optimal performance.If you'd prefer to use Nginx with Mongrel, see an older version of this topic.
Apache 2 was installed earlier so, go ahead and install the passenger gem (the gem was installed during the setup of Ruby Enterprise Edition, if you are using a different interpreter, the run 'gem install passenger' as root, then continue).
root@host: # passenger-install-apache2-module
Copy the Apache2 config lines it gives you at the end of the file to the end of your apache2.conf configuration file at /etc/apache2/apache2.conf. The lines look similar to this (paths may differ depending on which ruby implementation you're using):
LoadModule passenger_module/opt/ruby-enterprise-1.8.6-2009XXXX/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so
PassengerRoot/opt/ruby-enterprise-1.8.6-2009XXXX/lib/ruby/gems/1.8/gems/passenger-2.2.2
PassengerRuby/opt/ruby-enterprise-1.8.6-2009XXXX/bin/ruby
Some of Kete's downloading functionality requires an authorization step. If used a lot this potentially can slow all requests being served from the site. Thankfully there is an easy solution that Kete knows to use if enabled; X-sendfile. You need to do the following to set it up:
root@host: # cd /usr/local/src/; curl -L http://tn123.ath.cx/mod_xsendfile/mod_xsendfile-0.9.tar.gz # or get the latest version of the source
root@host: # tar xfz mod_xsendfile-0.9.tar.gz
root@host: # cd mod_xsendfile-0.9
root@host: # apxs -cia mod_xsendfile.c
Then you need to add the following to your Apache2 config file (either global, or in a virtualhost):
XSendFile on
XSendFileAllowAbove on
And force a reload of apache:
root@host: #apachectlforce-reload
Open up /etc/apache2/httpd.conf in your favourite editor, and change the following settings:
User <- the user running the kete app(s). Usually kete or yourself.
Group <- the group of the user running the kete app(s)
In the same file, uncomment the following line:
Include /private/etc/apache2/extra/httpd-vhosts.conf
In /etc/apache2/extra/httpd-vhosts.conf, uncomment the following line:
NameVirtualHost *:80
Run the following commands (otherwise Kete isn't installable because of missing dependancies).
root@host: # ln -s /usr/local/bin/zebrasrv /usr/bin
root@host: # ln -s /usr/local/bin/zebraidx /usr/bin
And finally, to make the apache restart command more consistant for the rest of the guide, type
root@host: # mkdir /etc/init.d
root@host: # ln -s /usr/sbin/apachectl /etc/init.d/apache2
With those changes made (and files saved), restart Apache:
root@host: # /etc/init.d/apache2 restart
and then look for any errors causes by bad configuration by running:
root@host: # tail -n 200 /var/log/apache2/error_log
Important Note: At this point, Apache2 and Passenger are installed but not yet configured for our Kete site. We'll handle that in a separate step once we have Kete installed. Until then, web requests will throw an error until you have actually deployed your Kete application.
Next step:
Setting Up the Environment
Discuss This Topic
There are 9 comments in this discussion.
Read and join this discussion
nlk
said edit files
I think the install went find. I am having problems editing or finding any of the config files. Also unable to find the ~/profile files or .bash_profile or .bashrc files. I am using the find and still have no luck. I am trying to get this working by the 15th of
Hi nlk,
I'm not sure what level your command line proficiency is, so I apologize if this seems obvious and doesn't help.
Could you do a simple "ls" in from the Terminal to list files under /etc/apache2/ to make sure you have the httpd.conf file please? Something like this:
$ ls -l /etc/apache2/
If you don't see the file in httpd.conf listed in the results or if that directory (/etc/apache2) doesn't exist, there is something strange about your Mac OS 10.5.6 installation. If you do see it, note that you have to edit the file as the super user (i.e. use "sudo" before the command to open the file in your text editor of choice).
As far as "~/.profile", "~/.bash_profile", or "~/.bashrc" files. You understand that the "~" means the home directory of the user you are logged in as, correct? For example, if I was logged in as myself on my laptop "~/.bash_profile" in Mac OS X would actually correspond to "/Users/walter/.bash_profile". Also, there is an "a" option to the ls command to list these special files (files that begin with a "." in their filename) that may help. Try this to list what is in your home directory:
$ ls -la ~
I've also deleted your redundant comments and left the most complete one.
Hope this helps.
Tags: Installation, apache, Mac OS X
nlk
said command line
Walter sorry for the duplicates not sure what happened and thank you for removing.
You are right on the money I need to work on command lines. I was able to get into my ~.profile and update.
when I open the httpd as myself it opens in text editor but like you said I have to use sudo but then there is no application to open
off to learn MAC command lines
thanks for all of your help
Give this howto a try:
http://www.tech-recipes.com/rx/2754/os_x_edit_file_using_textedit_as_root_superuser/
You'll want to replace "/etc/hosts" with "/etc/apache2/httpd.conf", but otherwise I believe that should give you what you want.
Tags: Mac OS X, apache2, httpd.conf, sudo, command line, editor
nlk
said restart apache
that helped able to edit items now
Why when I try to restart I get no such file or directory but the line before says file exists. All the files are saved with the above information.
bash-3.2# ln -s /usr/sbin/apachectl /etc/init.d/apache2
ln: /etc/init.d/apache2: File exists
bash-3.2# /etc/init.d/apache2 restartbash: /etc/init.d/apache2: No such file or directory
nlk
said apache error log
Do I need to install my app (kete) to /Library/WebServer/Documents/kete
bash-3.2# tail -n 200 /var/log/apache2/error_log
[Tue Dec 23 11:36:01 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Dec 23 11:36:02 2008] [notice] Digest: generating secret for digest authentication ...
[Tue Dec 23 11:36:02 2008] [notice] Digest: done
[Tue Dec 23 11:36:02 2008] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Tue Dec 23 12:38:22 2008] [notice] caught SIGTERM, shutting down
[Tue Dec 23 12:39:00 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Dec 23 12:39:01 2008] [notice] Digest: generating secret for digest authentication ...
[Tue Dec 23 12:39:01 2008] [notice] Digest: done
[Tue Dec 23 12:39:01 2008] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Tue Dec 23 16:10:31 2008] [error] [client ::1] File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://localhost/
[Sun Dec 28 09:26:19 2008] [notice] caught SIGTERM, shutting down
[Sun Dec 28 09:26:45 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using michael-e-caseys-mac-mini.local for ServerName
[Sun Dec 28 09:26:52 2008] [notice] Digest: generating secret for digest authentication ...
[Sun Dec 28 09:26:52 2008] [notice] Digest: done
[Sun Dec 28 09:26:52 2008] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Mon Dec 29 11:38:15 2008] [notice] caught SIGTERM, shutting down
[Mon Dec 29 11:38:40 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using michael-e-caseys-mac-mini.local for ServerName
[Mon Dec 29 11:38:48 2008] [notice] Digest: generating secret for digest authentication ...
[Mon Dec 29 11:38:48 2008] [notice] Digest: done
[Mon Dec 29 11:38:48 2008] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Mon Dec 29 14:59:38 2008] [error] [client ::1] File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://localhost/
[Mon Dec 29 15:25:24 2008] [error] [client ::1] File does not exist: /Library/WebServer/Documents/kete
[Mon Dec 29 15:25:38 2008] [error] [client ::1] File does not exist: /Library/WebServer/Documents/apps
[Mon Dec 29 15:51:08 2008] [error] [client fe80::21f:f3ff:fefa:d2f2] File does not exist: /Library/WebServer/Documents/usrs
[Mon Dec 29 15:51:08 2008] [error] [client fe80::21f:f3ff:fefa:d2f2] File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://michael-e-caseys-mac-mini.local/usrs/nancy/apps/kete
[Mon Dec 29 15:51:27 2008] [error] [client fe80::21f:f3ff:fefa:d2f2] File does not exist: /Library/WebServer/Documents/usres
[Wed Dec 31 09:34:06 2008] [error] [client ::1] File does not exist: /Library/WebServer/Documents/apps
[Wed Dec 31 09:35:05 2008] [notice] caught SIGTERM, shutting down
[Wed Dec 31 15:41:29 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed Dec 31 15:41:29 2008] [notice] Digest: generating secret for digest authentication ...
[Wed Dec 31 15:41:29 2008] [notice] Digest: done
[Wed Dec 31 15:41:29 2008] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Wed Dec 31 15:41:39 2008] [error] [client 10.200.0.54] File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://10.200.0.54/
[Wed Dec 31 15:41:52 2008] [error] [client 10.200.0.54] File does not exist: /Library/WebServer/Documents/kete
[Fri Jan 02 11:51:24 2009] [notice] caught SIGTERM, shutting down
[Fri Jan 02 11:51:25 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Fri Jan 02 11:51:26 2009] [notice] Digest: generating secret for digest authentication ...
[Fri Jan 02 11:51:26 2009] [notice] Digest: done
[Fri Jan 02 11:51:26 2009] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations
[Mon Jan 05 11:06:24 2009] [error] [client ::1] File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://localhost/
[Mon Jan 05 11:22:42 2009] [notice] caught SIGTERM, shutting down
Hello again,
Check the note at the bottom of this step of the installation:
Important Note: At this point, Apache2 and Passenger are installed but not yet configured for our Kete site. We'll handle that in a separate step once we have Kete installed. Until then, web requests will throw an error until you have actually deployed your Kete application.
In other words, at this point in the installation Apache will throw errors. Please carry on with the next steps and let us know if that doesn't fix things for you.
Tags: apache, Installation, Mac OS X, passenger, mod_rails



nlk
said installation help
I am working with MAC OS X 10.5.6 and Apache2 my problem is I am new to all and having problem locating the httpd.conf files that I need to update. I did a find but doesn't look right I don't have the line that has to be un-commented.