Mac OS X
From StatusNet
Contents |
Requirements
10.6 Snow Leopard
Snow Leopard ships with PHP 5.3.0 which appears to include all PHP extension requirements for StatusNet 0.9.x except for tidy (and pcntl, needed for background daemons). A fallback for tidy is being discussed (bug 1870). You may still need to enable PHP in your Apache configuration if you haven't.
- Tidy is no longer required for 0.9.x.
You'll still need to install MySQL; MySQL's installer packages should work.
If you're not willing to wait for the remaining fixes, you may find it easier to make a fresh PHP install, see sections below!
An alternative is to use, MAMP (Mac+Apache+MySQL+PHP), its simple and straight forward. Just extract the archive, copy to webservices folder, rename and you are good to go. This is for small installations only. see more detailed instructions @ http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Mac_OS_X#MAMP_-_An_easier_way_to_get_Apache.2FMySQL.2FPHP_set_up I had used the 0.9 version, 0.83 version gets stuck at finding 'tidy'
10.5 and below
Apple's stock PHP distribution through 10.5 doesn't include the gettext or gd modules, which StatusNet 0.8.x requires. You'll need to install a version of PHP which does include these modules.
- Problems with PHP 5.3 should be resolved in the latest 0.9.x code.
Server setup
Some random, disorganized notes...
- MacPorts (http://www.macports.org/) is probably the best way to go. You can get the main things you need installed quickly in /opt e.g.:
sudo port -s install php5 +mysql5 +apache2 +pear
- apache runs as user _www not www-data, so the avatar dir needs to be owned/writable by _www
How to configure MySQL?
1. To test if the MySQL is working, create the test database
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
2. If you want to start MySQL during start,
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
3. If you want to start MySQL from commond line, add the alias into your profile
vi ~/.profile alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &' alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
close all console window and Terminal and restart Terminal
mysqlstart
4. confirm mysql is running
mysqladmin5 -u root -p ping
If you get the following error...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
...set the mysqld_safe socket path in a new MySQL configuration file. Create /opt/local/etc/mysql5/my.cnf, add the following to it, save, the try again.
[mysqld_safe] socket = /tmp/mysql.sock
5. If you've installed MacPort's PHP 5 you will probably need to tell PHP where the MySQL socket is. Edit your php.ini file located at /opt/local/etc/php.ini.
mysql.default_socket = /tmp/mysql.sock
How to configure Apache and PHP5 on Mac?
After you follow the instruction above to install php, mysql, apache etc, and follow the screen instruction to copy the php.ini and active PHP module in Apache, you will need to configure your WWW home directory.
1. Make sure you disable the out-of-box Apached installed on Mac in the Preference/sharing
2. Set Apache's Document Root, Enable User Directories:
sudo pico /opt/local/apache2/conf/httpd.conf
DocumentRoot "<your www root>" <Directory "<your www root>">
Add index.php to the dir_module directive:
<IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
Add a new mimetype so that Apache will direct files ending in .php to the PHP module for processing. Add the following within the <IfModule mime_module> block. Without this, all you'll see is the text of your PHP scripts
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
And finally, to enable user directories, uncomment:
Include conf/extra/httpd-userdir.conf
Save and close the httpd.conf file.
5. Starting and Stopping Apache
/opt/local/apache2/bin/apachectl start
Debugging
Laconica's logging functions send messages to syslogd. By default OS X doesn't bother to write most of the syslog facilities.levels Laconica uses to the system.log, so what I did was edit /etc/syslog.conf to write the messages to a new "debug.log" file by adding this line:
sudo port -s install php5 +mysql5 +apache2 +pear *.err;*.debug;*.warn;*.notice;*.info /var/log/debug.log
Then restarted syslogd (the Mac way):
sudo port -s install php5 +mysql5 +apache2 +pear *.err;*.debug;*.warn;*.notice;*.info /var/log/debug.log sudo launchctl stop com.apple.syslogd; sudo launchctl start com.apple.syslogd
And I can use the Console.app to filter messages with "laconica" as the sender... or tail the file...
sudo port -s install php5 +mysql5 +apache2 +pear *.err;*.debug;*.warn;*.notice;*.info /var/log/debug.log sudo launchctl stop com.apple.syslogd; sudo launchctl start com.apple.syslogd tail -f /var/log/debug.log |grep laconica
Is there a better way?