Hello,
This post documents all that I did to install SwiftRiver v0.3 on Mac
OS X Version 10.6.6 (including the issues I ran into, and what I
needed to do to overcome them) I spent about 4 hours getting it all to
work, so I hope this post saves other people some time ;-)
1. Read install guide for Ubuntu:
http://wiki.ushahidi.com/doku.php?id=swiftserversetup
2. Signup to SwiftRiver forum:
http://groups.google.com/group/swiftriver
3. Check whether PHP is installed?
bart:Documents $ php -v
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
bart:Documents $
So PHP 5.3.3 came built-in.. sweet!
4. Turn on apache server via System Preferences->Sharing and enable
'Web Sharing'
browse to
http://localhost/
bart:Documents $ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 200 OK
Date: Mon, 21 Mar 2011 16:34:27 GMT
Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8l DAV/2
Content-Location: index.html.en
Vary: negotiate
TCN: choice
Last-Modified: Mon, 21 Mar 2011 16:13:05 GMT
ETag: "130d9-33-49f006713a640"
Accept-Ranges: bytes
Content-Length: 51
Connection: close
Content-Type: text/html
Content-Language: en
<html><body><h1>It REALLY works!</h1></body></html>Connection closed
by foreign host.
bart:Documents $
Great.. apache is there too. Now MySQL.
5. Read 'Installing MySQL on Mac OS X'
http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html
Check for previously installed mysql client and server
$ which mysql
$ which mysqld
Found none.
MySQL installation requires a Mac OS X user account named mysql. A
user account with this name should exist by default on Mac OS X 10.2
and up.
Check for username 'mysql' in /etc/passwd
Found:
_mysql:*:74:74:MySQL Server:/var/empty:/usr/bin/false
Perhaps this should be renamed to 'mysql' ?
6. Download MySQL package (.DMG) here:
http://dev.mysql.com/downloads/mysql/
Make sure to choose the version suited to your OS build / processor.
Mine was 32 bit Mac OS X ver 10.6
Install MySQL Community Server, as well as Preferences Pane.
Add aliases to your .profile (or other shell startup profile file) as
required:
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
bart:~ $ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights
reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 1.1.5 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.10 |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | i386 |
| version_compile_os | osx10.6 |
+-------------------------+------------------------------+
7 rows in set (0.01 sec)
mysql>
We currently have ver. 5.5.10 installed
7. Now to enable PHP with the default built-in Apache web server read
this:
http://www.php.net/manual/en/install.macosx.bundled.php
**IMPORTANT! Read the full article, including the comments! It will
save you time ;-)
AddModule and AddType are the main edits to httpd.conf as described in
the comments.
You also would need to add:
php_value mysql.default_socket /tmp/mysql.sock
to /private/etc/apache2/other/php5.conf
8. Create the /Library/WebServer/Documents/phpinfo.php file with the
following line of code:
<?php phpinfo(); ?>
Save file, restart Apache Webserver via System PReferences, and browse
to:
http://localhost/phpinfo.php
If you can see the PHPinfo dump you know that PHP scripts can now be
served by Apache. yay!
9. cURL
When i looked up phpinfo.php output I found cURL was already
enabled..phew!
Saved me compiling it from source ;-)
10. PEAR
I ran $pear and got output!! So pear also came installed by default..
cool.
I have no idea what pear does, so a quick look at the man pages:
DESCRIPTION
PEAR is an acronym for "PHP Extension and Application Repository"
and is pronounced just like the
fruit. The purpose of PEAR is to provide:
o A structured library of open-source code for PHP users
o A system for code distribution and package maintenance
o A standard style for code written in PHP
o The PHP Extension Community Library (PECL)
o A web site, mailing lists and download mirrors to support
the PHP/PEAR community
So.. its kinda like CPAN for PHP (for those familiar with perl)
nice! :-)
Now install log module as so:
$ sudo pear install log
WARNING: channel "
pear.php.net" has updated its protocols, use "pear
channel-update
pear.php.net" to update
WARNING: "pear/DB" is deprecated in favor of "pear/MDB2"
Did not download optional dependencies: pear/DB, pear/MDB2, pear/Mail,
use --alldeps to download automatically
pear/Log can optionally use package "pear/DB" (version >= 1.3)
pear/Log can optionally use package "pear/MDB2" (version >= 2.0.0RC1)
pear/Log can optionally use package "pear/Mail"
downloading Log-1.12.5.tgz ...
Starting to download Log-1.12.5.tgz (46,311 bytes)
.............done: 46,311 bytes
install ok: channel://
pear.php.net/Log-1.12.5
11. Setup a MySQL DB and User
Connect to MySQL like so:
bart:/ $ mysql -u root -p
(By default the root account has no password, just hit enter, you
should change that immediately though! See
http://www.cyberciti.biz/faq/mysql-change-root-password/)
Now create a new database:
create database swiftriver;
And create a user and give them permissions to the new database:
grant usage on *.* to swiftriver@localhost identified by '[your
password here]';
grant all privileges on swiftriver.* to swiftriver@localhost;
12. Download code from
https://github.com/downloads/ushahidi/Sweeper/Sweeper_V0.3.zip
13. Unzip Sweeper to your DocumentRoot, in my case:
$ unzip Sweeper_V0.3.zip -d /Library/WebServer/Documents/
Change the permissions of some of the files that Sweeper needs to
manage.
I changed them to a+rw for all files under DocumentRoot (Note, this is
probably a security issue, dont do this witha production webserver!)
14. Now go to your browser and fire up
http://localhost/index.php
I passed the first 3 checks (Introduction / Server Checks /
Permissions)
On Step 4, I input:
Database server: localhost
Username: swiftriver
Password: your_password_here
DB Name: swiftriver
15. Hit an error!!
Something went wrong while trying to connect to the database. Here are
the details: exception 'PDOException' with message 'SQLSTATE[HY000]
[2002] No such file or directory' in /Library/WebServer/Documents/
installer/steps/DBSetup.php:146
A search for PDO in phpinfo shows that PHP was compiled to look for -
with-mysql-sock=/var/mysql/mysql.sock
whereas on Mac OS X its installed in /tmp/mysql.sock
So do the following:
sudo cp /etc/php.ini.default /etc/php.ini
sudo vim /etc/php.ini
search for and change to:
mysql.default_port = /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
pdo_mysql.default_socket=/tmp/mysql.sock
Now restart Apache and MySQL services and fire up
http://localhost/index.php
16. Everything works smoothly until you hit the Kohana error :-/
First read this:
http://michaeldpeters.com/userguide/guide/kohana/tutorials/clean-urls
and make the appropriate changes to DocumentRoot/web/applications/
bootstrap.ini
Kohana::init(array(
'base_url' => '/web/',
'index_file' => FALSE,
));
Add following to /private/etc/apache2/httpd.conf
# Adding Kohana specific <Directory/> directive to httpd.conf
<Directory "/Library/WebServer/Documents/web">
Order allow,deny
Allow from all
AllowOverride All
</Directory>
**NOTE In the above bit, you need to set your own DocumentRoot in my
case it is /Library/WebServer/Documents
Restart Apache and MySQL services!