Working with MacPorts on Mac OS X
From EdVoncken.NET
Contents |
[edit] Installing MacPorts
The current version of MacPorts is 1.6.0 - download the appropriate DMG file and install as usual. You'll need Xcode installed, which is on the Leopard DVD set if not already installed.
In your shell .profile two environment variables are changed:
# Settings for MacPorts PATH=/opt/local/bin:$PATH MANPATH=$MANPATH:/opt/local/man
In my case, they were not set automatically so I added them after installing MacPorts.
[edit] Porticus, a GUI for MacPorts
Porticus is a free GUI for the MacPorts package manager. Highly recommended!
[edit] Port variants
Some packages can be built in several variations, for example PHP:
# port variants php5
php5 has the variants:
universal
darwin_6
darwin_7
macosx
apache: for Apple Apache
apache2: for current Apache
fastcgi: add fastcgi binary
gmp: Add GNU MP functions
imap: enable operation with IMAP protocol
tidy: add Tidy support
mssql: add support for MS-SQL server
snmp: use Apple snmp
macports_snmp: use MacPorts snmp
mysql3: build MySQL 3 support
mysql4: build MySQL 4 support
mysql5: build MySQL 5 support
oracle: Add Oracle oci8 database functions with the Oracle Instant Client
postgresql: provide postgresql support
sqlite: build sqlite support
ipc: build IPC support
pcntl: provide process control
pear: add pear stuff
sockets: Add socket communication functions
[edit] Useful ports
Usually, you'll want an uptodate webserver environment with database support. See Install Apache 2 and PHP 5 with MacPorts.
- mysql5
- the MySQL database server, version 5.x.
port install mysql5
- apache2
- the Apache webserver, version 2.x. After installation, do not forget to activate the webserver on startup:
port install apache2 launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
- php5
- the PHP interpreter. You'll at least want support for Apache 2, MySQL 5 and Pear:
port install php5 +apache2 +mysql5 +postgresql +sqlite +pear
- If this is your first install, you might want
cd /opt/local/apache2/modules /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
- Copy /opt/local/etc/php.ini-dist to /opt/local/etc/php.ini
- phpmyadmin
- a web interface for MySQL administration. The dependency checker will install MySQL, PHP and various other ports for you.
[edit] Troubleshooting
[edit] sqlite3 fails to build
During installation of the Apache port, SQLite is built as a dependency. The build fails in alter.c:
./src/alter.c: In function 'renameTableFunc': ./src/alter.c:77: error: 'TK_SPACE' undeclared (first use in this function) ./src/alter.c:77: error: (Each undeclared identifier is reported only once ./src/alter.c:77: error: for each function it appears in.) ./src/alter.c:79: error: 'TK_LP' undeclared (first use in this function) ./src/alter.c:79: error: 'TK_USING' undeclared (first use in this function) ./src/alter.c: In function 'renameTriggerFunc': ./src/alter.c:135: error: 'TK_SPACE' undeclared (first use in this function) ./src/alter.c:148: error: 'TK_DOT' undeclared (first use in this function) ./src/alter.c:148: error: 'TK_ON' undeclared (first use in this function) ./src/alter.c:151: error: 'TK_WHEN' undeclared (first use in this function) ./src/alter.c:151: error: 'TK_FOR' undeclared (first use in this function) ./src/alter.c:151: error: 'TK_BEGIN' undeclared (first use in this function) ./src/alter.c: In function 'reloadTableSchema': ./src/alter.c:246: error: 'OP_DropTrigger' undeclared (first use in this function) ./src/alter.c:251: error: 'OP_DropTable' undeclared (first use in this function) ./src/alter.c:256: error: 'OP_ParseSchema' undeclared (first use in this function) ./src/alter.c: In function 'sqlite3AlterRenameTable': ./src/alter.c:366: error: 'OP_String8' undeclared (first use in this function) ./src/alter.c:367: error: 'OP_VRename' undeclared (first use in this function) ./src/alter.c: In function 'sqlite3AlterFinishAddColumn': ./src/alter.c:479: error: 'TK_NULL' undeclared (first use in this function) gnumake: *** [alter.lo] Error 1
Some searching on the Internet pointed me to a working solution:
port install gmake port clean sqlite3 port install sqlite3