Posted by ahmadster at August 6th, 2006
I’m a clean-system freak, I don’t like junk scattered all over my OS.
Bash and Sudo
Many of the settings here are related to things I want to install later on like Python. Here is my /etc/bashrc
# System-wide .bashrc file for interactive bash(1) shells.
# classify and colorify with ll
alias ll='ls -lahFG'
# Textmaket is my favorite editor
export EDITOR='mate -w'
export LESSEDIT='mate -l %lm %f'
# make apps in /usr/local/bin the default
export PATH=/usr/local/bin:$PATH
# make graphics lib apps also available
export PATH=/usr/local/graphicslibs/bin:$PATH
# make postgresql apps available
export PATH=/usr/local/pgsql/bin:$PATH
# make python apps available
export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}
# things I picked up from gentoo
export TERM=xterm-color
export DISPLAY=:0.0
export LESS='-X -e'
export PAGER=less
# this makes the prompt green when logged in as a normal user, and red when working as root.
# very good, thank you gentoo
if [ `/usr/bin/whoami` = 'root' ]
then
export PS1='[3[01;31m]h [3[01;34m]W $ [3[00m]'
else
export PS1='[3[01;32m]h [3[01;34m]W $ [3[00m]'
fi
# Make bash check it's window size after a process completes
shopt -s checkwinsize
Now close your terminal and start a new one. Time to do sudo.
I hate retyping my password every time I need to do anything useful. So I made sudo not ask me by editing the /etc/sudoers file like this
# visudo
Then I made sure the %admin group had NOPASSWD: ALL like this
%admin ALL=(ALL) NOPASSWD: ALL
*BE VERY CAREFUL. If you mess up this file you cannot do anything as root anymore since sudo will be busted, if that happens there is a quick fix. Reboot and hold Command+s as your machine boots up. You will enter into Single-User mode. There you can mount your drive like this
mount -uw /
That will put you back into your drive and you can fix the /etc/sudoers file again.
You can also run
fsck -yf
while you are in there, if you have something wrong with your drive.
Postfix
Enable postfix as a daemon. Edit /System/Library/LaunchDaemons/org.postfix.master.plist ( see Getting Started with launchd to know what the different locations mean).
You want to remove the “-e 60″ from program arguments. Then add a new boolean key under the root named “OnDemand”. Set it to false. Plist should look like this.
.....
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.postfix.master</string>
<key>Program</key>
<string>/usr/libexec/postfix/master</string>
<key>ProgramArguments</key>
<array>
<string>master</string>
</array>
<key>QueueDirectories</key>
<array>
<string>/var/spool/postfix/maildrop</string>
</array>
<key>OnDemand</key>
<false/>
</dict>
</plist>
Next, go to /etc/postfix and backup the current master.cf. Then copy the master.cf.defaultserver over it.
Do the same with main.cf, but edit main.cf with the setting you like.
Postfix may complain if you don’t have mydomain_fallback set to something in main.cf. Set it to localhost.
Open Console and look at /var/log/mail. Then unload, load, and start postfix
launchctl stop org.postfix.master
launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist
launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist
launchctl start org.postfix.master
Telnet to port 25 and check it out.
Apache2
Get the latest apache2 you want to install (use your favorite mirror from apache.org).
*IMPORTANT: as of Apr 16th, 2006 httpd-2.2.0 segfaults on MacIntel. Use httpd-2.0.55 instead
curl -O http://www.tux.org/pub/net/apache/dist/httpd/httpd-2.0.55.tar.gz
tar xzfv httpd-2.0.55.tar.gz
cd httpd-2.0.55
Now configure
./configure --prefix=/usr/local/apache2 \
--enable-ssl
--enable-dav \
--enable-dav-fs \
--enable-dav-lock \
--enable-vhost-alias \
--enable-mods-shared=max \
--enable-module=most
make
sudo make install
Next, there are a few small modifications to the config files.
First edit /usr/local/apache2/conf/httpd.conf. Set the user and group to www
User www
Group www
For apache 2.2.0, Un-comment these extra config files
# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
# Distributed authoring and versioning (WebDAV)
Include conf/extra/httpd-dav.conf
# Various default settings
Include conf/extra/httpd-default.conf
You may now modify extra/httpd-vhosts.conf to set all your virtual hosts there.
Now edit extra/httpd-mpm.conf to set the correct pid file location OSX expects
#
# PidFile logs/httpd.pid
PidFile /private/var/run/httpd.pid
#
For apache 2.0.55 do the same as above, but everything is in the httpd.conf file
To make OSX use our new apache instead of the default, we just replace the apachectl file with our new one
cd /usr/bin
mv apachectl apachectl-1.3
ln -s /usr/local/apache2/bin/apachectl apachectl
PHP
What I like about this, is that it does not taint my OSX. It installs clean. I need php 4, if you want php it’s pretty much the same. You can look at PHPMac.com for more info.
Recompile with postgresql, mcrypt, and a few other things. Download the latest php from php.net, untar and use this to configure it:
./configure '--prefix=/usr' \
'--mandir=/usr/share/man' \
'--infodir=/usr/share/info' \
'--disable-dependency-tracking' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
--with-gd --with-jpeg-dir=/usr/local/graphicslibs \
--with-png-dir=/usr/local/graphicslibs \
'--with-ldap=/usr' '--with-kerberos=/usr' \
'--enable-cli' \
'--with-zlib-dir=/usr' \
'--enable-trans-sid' '--with-xml' \
'--enable-exif' '--enable-ftp' \
'--enable-mbstring' '--enable-mbregex' \
'--enable-dbx' '--enable-sockets' \
'--with-iodbc=/usr' '--with-curl=/usr' \
'--with-config-file-path=/etc' \
'--sysconfdir=/private/etc' '--with-pgsql' \
--with-bz2 --with-dom --with-iconv \
--with-mcrypt --without-msql --without-mssql \
--with-ncurses --disable-cgi --with-openssl \
--enable-sockets --with-zlib
Obviously, these are my preferences, you may add or remove what you like. For me, I needed mcrypt. I had to download libmcrypt-2.5.7 from SourceForge.net: mcrypt and do a normal ./configure && make && sudo make install. PostgreSQL was already installed, so that worked.
Now in the php source directory we
make && sudo make install
PostgreSQL
The best universal and latest postgres I found was Marc Liyanage’s. Again, clean installation into /usr/local/pgsql. Follow the instructions on his site and you will be happy.
Graphics Libs (imagemagick, etc…)
This is also from Kyng Chaos - Mac OS X - UNIX Porting Downloads. Download and install the Graphics Libs, it will install into /usr/local/graphicslibs. Since we already have the path set in our bashrc (see above). We will have all our favorite image tools in the command line.
Python, iPython, wxPython
Python.org now has the latest version of Python available for OSX correctly. Just download and install. The default installation is pretty good, it even comes with readline. Except that I want the rest of the system to use this python by default also. The installation modifies the current users .bash_profile to include the correct python path. I actually keep a very good /etc/bashrc that takes care of that (see above).
To get python to talk to PostgreSQL you need psycopg. It’s version 2 isn’t working yet. But version 1 is pretty good. Download it from PsycopgOne - psycopg - Trac. There are many steps to get to it, but it’s totally doable.
To get there you need mxDateTime from egenix here eGenix.com mx Extensions for Python. Download it and untar it then do
sudo python setup.py install
That will do it.
Now untar psycopg, configure like this
export MACOSX_DEPLOYMENT_TARGET=10.4
./configure \
--with-mxdatetime-includes=\
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/mx/DateTime/mxDateTime \
--with-postgres-libraries=`pg_config --libdir` \
--with-postgres-includes=`pg_config --includedir`
Then make && sudo make install
For iPython, just download and install also as usual
sudo python setup.py install
No problems there since readline is already included with Python.