LAMP (leopard, apache, mysql, php)

## Introduction

instructions for setting up dynamic web server and services on mac os x (10.5, should be similar for 10.4)

## semi-quick semi-easy totally sweet setup (a wee bit of compile time, but its worth it … smoke em if you got em boys)
1. download and install macports from macports.org

1. make sure you have xcode dev tools
installed, you can grab a copy for leopard with the free iphone sdk … also cool
iphone simulator :) ,might also want x11 for headers or some reason. )
2. might also want to make sure your paths are set up properly in .profile and .bash_profile
echo $PATH
/opt/local/bin:/opt/local/sbin:...

3. sometimes you may need to move conflicting files in /usr/local , you can safely move it /usr/local.bak

2. install mysql (easy)
$ sudo port install mysql5 +server

1. install dbs
$ sudo -u mysql mysql_install_db5
2. #secure dbs (recommmended)
$ /opt/local/lib/mysql5/bin/mysql_secure_installation
might also need
$ sudo ln -s /tmp/mysql.sock /opt/local/var/run/mysql5/mysqld.sock
3. *optional setup launch deamon
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

3 . install apache2 (this will probably FAIL on leopard, see below, rinse repeat, milage may vary)
$ sudo port install apache2

1. $ sudo port install db44 +darwin_8 +universal #(magic :P)
2. $ sudo port install gawk #(deps order gets screwed up so have to do this one first manually)
3. now try apache2 again
3a. $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist #(optional setup launch deamon )

4. install php finally … (easy, but so many choices … )
$ sudo port install php5 +apache2 +imap +ipc +macosx +mysql5 +pear +sockets +sqlite +tidy

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

might also want to …
$ sudo mv /usr/sbin/apachectl /usr/sbin/apachectl-leopard
$ sudo ln -s /opt/local/apache2/bin/apachectl /usr/sbin/apachectl

4.b upgrade php

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

5. configure setup apache + php
1. apache conf include vhosts
$ sudo cp /opt/local/apache2/conf/httpd.conf.sample /opt/local/apache2/conf/httpd.conf

2. find ssl in conf
disable ssl … for now , had this working before

add this httpd.conf

# plugins
Include conf/extras-conf/*.conf
# OS X User Homes
# uncomment for tiger
# Include /etc/httpd/users/*.conf
# uncomment for leopard
# Include /etc/apache2/users/*.conf
# PJK
Include /Users/pkhalil/Sites/conf.d/apache/*.conf

add this to php_php.conf

<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>

3. php.ini
should be good to go …
$ sudo cp /opt/local/etc/php.ini-recommended /opt/local/etc/php.ini
1. PEAR
2. PECL

4. reboot apache
$ sudo apachectl start
1. link macport logs to normal /var/log
$ sudo mv /opt/local/apache2/logs /opt/local/apache2/logs.bak; sudo ln -s /var/log/apache2/ /opt/local/apache2/logs

6. configure setup mysql
1. my.conf
2. import dbs

DONE!
keep in mind if things start to go wrong you can easly scrap everything and start from scratch.
$ sudo rm -rf /opt

some handy port commands
————————
* port sync (run this before selfupdate or outdated)
* port selfupdate
* port upgrade outdated
* port clean
* port -f uninstall outdated
* port activate
* port deactivate

Handy packages on Ports
———————-
* apache2
* php5
* mysql5
* memcached
* ffmpeg
* pngcrush
* png2ico
* cmatrix ;)
* emacs :P
* ack
* gnupg
* lynx
* subversion
* wget
* curl
* eggdrop
* logrotate
* ?perl? ?ruby? ?ect?

coming soon …

  • subversion
  • memcached
  • ffmpeg
  • imagemagick
  • mechanize
  • php-xdebug
  • kcachegrind
  • selenium core
  • mysqldiff
  • phpmyadmin
  • openx
  • wordpress
  • trac
  • splunk
  • php unit
  • apc
  • …. and more!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*