Using postfix on linux for sending only outgoing messages

Summary: What you want is to set up a null client. See my notes below for what constitutes an ’smtp server entry’.

So for my local dev environments I’ve been in the habit of setting up php’s mail function to work by doing a ’sudo apt-get install sendmail’ and editing the php.ini to point the sendmail_path to /usr/sbin/sendmail. (I’d recommend this procedure only if you’re working locally and don’t plan on opening port 25 to anything public, won’t want to mess with domain names, and won’t be dealing with mx records, etc.).

Well when I actually had to setup a server with a public domain, and needed emails to work efficiently from php with a qualified domain while worrying about port 25 being secure, I was in for some fun. For starters I’d recommend postfix over sendmail. Much easier to configure. Sendmail has many more config files, and you have to re-compile some of them after edits, etc. So once you have postfix installed, if you just want to send outgoing emails, then you can increase security and reduce overhead by making postfix not listen on the SMTP port. I wanted postfix as an smtp client only. With sendmail you can do this, and even kill all the daemons. With postfix you still need the daemon going, but when we’re done, nothing will be listening on port 25, smtp.

So what we are setting up is called a ‘null client’. You just have to modify /etc/postfix/ and master/cf according to the instructions at

The main thing that was unclear to me is what line(s) constitute a ‘SMTP server entry’ in After commenting out the line close to the top with ’service’ as ’smtp’ and ‘type’ as ‘inet’, I figured this was enough, as ’sudo lsof -i’ indicated nothing was listening on port 25, or as smtp. I would leave the other smtp service entries alone, the ones with ‘type’ as ‘unix’.

Then do ’sudo postfix reload’ and for good measure we may as well do ’sudo /etc/init.d/postfix restart’, or the equivalent on your linux distro.

PHP and MySQL setup on Mac OS X 10.5 Leopard

Full fledged open-source MAMP development environment with php, mysql, and apache on Mac OS X 10.5 Leopard

Goal: A complete php development environment using Mac OS X 10.5 Leopard’s out of the box apache2/php install, and an install of the latest mysql and eclipse software with all the necessary plugins for php debugging. ALL 64-BIT!

Admittedly, it was a challenge to get a fully functioning php dev environment up based on Mac OS X 10.5 Leopard’s configuration. But I succeeded in not installing a separate apache/php 32-bit install, or bailing out to use a linux Virtual Box.

Enabling PHP


This one was pretty easy. Just uncomment out the line

#LoadModule php5_module        libexec/apache2/

in the httpd.conf apache config (/etc/apache2/httpd.conf) so it includes the php5 module that comes with the OS.

Make sure your extension_dir in php.ini points to /usr/lib/php5/extensions/no-debug-non-zts-20060613/ or go nuts and do your own extension directory.

Debugging 64-bit

This was one of the trickier things. You need to get an X-Debug extension setup. Hopefully you can just use my 64-bit extension file, and put that in your extensions directory (/usr/lib/php5/extensions/no-debug-non-zts-20060613/). Then add the zend_extension directive to the php.ini, along with the X-Debug settings, pointing to your (local or remote) host. In your php.ini:

(left bracket)xdebug(right bracket)
xdebug.remote_enable=true  ; if debugging on remote server, put client IP here
xdebug.remote_handler=dbgp (specific to 64-bit Mac OS X)

If that short version doesn’t work, you need to compile a 64-bit extension from the xdebug source, which was sort of tricky. You’ll need to get a compiler installed on your Mac OS if you haven’t got the right developer tools installed (XCode from the install disk or mac;s website), and then follow the instructions in this article.

Installing MySQL

Use the installer from MySQL’s site, and it goes pretty seamlessly. You may have to edit the php.ini to use the mysql server.

The tricky part of this is if you use a framework, or your code uses the pdo database interface. Again, you can try my 64-bit version, or compile your own pdo_mysql extension. Enable the extension in the php.ini by addin gthe line (specific to 64-bit Mac OS X)


So there is a Cacao version that is 64-bit. I guess the difference here, as I’ve read online, is that the Carbon version is more stable, but also legacy and in the future will be deprecated soon.

I love using the update site to get plugins. That seemed to work best for PDT php, aptana, SVN (subclipse), and various editors, etc.


I sort of copped-out here when I learned the 64-bit version of eclipse doesn’t work well with Flex-Builder as an Eclipse plugin. I’m planning on installing the stand-alone version of flex builder, and using that separately (a little but resource wasteful, but far more convenient).

Importing an existing folder as a new Eclipse Project

I absolutely hate the new project dialog in eclipse. It seems like each plugin (PHP, Flex, Aptana, SVN, etc.) has its own way of doing a new project.

Here’s one reason I hate these dialogs – If I want to add a new project into my workspace, I can’t put the files there first and then make it a project. Why would I want to do this? 1)I want to clone a git project from a remote repository into my workspace. Right now there is no way to do this with an add project dialog. So the files get to my workspace, but they don’t show up as a project. Same goes for SVN stuff where I want to re-add the files as a new project without having to check the whole stinking repository out again. Plus, it would be nice if I wanted to add files first, then make projects. Is that so hard? I understand eclipse doesn’t want to muck around in a folder with no project data to make a new project, but really, is it so hard to make a non-project folder a project folder? And if eclipse isn’t meant to do this, GET RID OF THE ‘Create project from existing source’ option because it doesn’t work with many project types.

So here is a way I found that works swimmingly. I wonder if this came as an option with a plugin. If so, I am using PDT php, Aptana, Subclipse, and I think those are the main ones. If you don’t get this option in your menu, than who knows what plugin you may need. I’m just glad I got it to work for me.

SOLUTION: Screw the new project dialog. Do File->import then select the folder ‘Other’->Existing Folder as New Project. This works great for my goal of 1)having files in my workspace that are not a project in eclipse and then making that folder and all its files a new project.

bash: git-receive-pack: command not found, git-upload-pack

When doing a push to master I was getting

bash: git-upload-pack: command not found
bash: git-receive-pack: command not found

For me my server was not recognizing the git command. I had to add the server paths to my local git config

receivepack = /home3/<myusername>/local/git-1.6.4/git-receive-pack
uploadpack = /home3/<myusername>/local/git-1.6.4/git-upload-pack

where the config file is in the .git directory of my project on local. This line is under the entry for the remote I had set up called ‘origin’ (use the path on the server where the git install is located and make sure git-receive-pack is in there on the server).

BUT,I think the following is be the better solution. Editing the .bashrc worked like a charm. I added the following line to my .bashrc file (look in /etc or you home/ directory if on a shared server) and things worked swimmingly.

export PATH=”$PATH:/home3/<myusername>/local/git-1.6.4″

replace /home3/… with whatever the path to your git install may be.

I’m still not clear on why the path would be different for a bash ssh command, and a client sending a request over ssh to the server. It seems as if even though my server environment variable $PATH includes the path to the git install, the $PATH variables does not include that path if the git commands are invoked over a remote ssh request (like my eclipse working with git). But if I was logged in on a bash shell, the git commands worked great, with no ‘command not found’ errors. Make sure when you install git, that you understand how to make your server recognize the git executable commands, both from the bash and also from remote requests. I’m still unclear on the difference between 1) editing the $PATH environment variable to include your git directory 2) Editing the .bashrc with the export $PATH setting. 3) Making symbolic links from the bin folder to your git install.


make[2]: execvp: Permission denied

make[2]: execvp: true: Permission denied

You need to do chmod 755 true on the true script on your bin, For me I had followed the instructions at:

for installing git on bluehost. I had to make a script called ‘true’, and put it in my local bin to get git to compile.

make[2]: execvp: <YOUR FILE HERE>: Permission denied

These errors mean that your script does not have execute rights. You can ‘chmod 755 <YOUR FILE>’ and it should work.

Using PEAR classes with bluehost php – Edit your include_path

Getting an HTTP_Request class was pissing me off. So it seems like you can’t install PECL classes on your php install because of rights issues on a shared hosting environment.

BUT, you can get PEAR classes installed through the cPanel, using the PHP PEAR Packages link. I was adding the HTTP_Request package (HTTP_Request2 won’t install because there is no stable release as of yet).

But even after the install, the classes could not be found. Like when I did require_once(‘HTTP/Request.php’) I was getting the classic not found warning and error:

Warning: include(HTTP/Request.php) [function.include]: failed to open stream: No such file or directory
Warning: include() [function.include]: Failed opening ‘HTTP/Request.php’ for inclusion
Fatal error: Class ‘HTTP_Request’ not found

You have to edit the php.ini (or ini_set the include_path ) to include :/home/yourusername/php, or in my case the home directory is now home3 for some reason, with some weird aliasing allowing for home I think. The PEAR packages install to /home/yourusername/php, so this needs to be added to the include path.

If you still get:
PHP Fatal error:  main(): Failed opening required ‘PEAR.php’
Then your include_path may be missing :/usr/lib/php, this is the main (not your local user) php lib folder that, I think, has the main PEAR files (The ones that your local PEAR package installs like HTTP_Request will be calling). So when you install a PEAR package via the cPanel, it puts them in /home/yourusername/php, and those files will need to know about the main PEAR install in /usr/lib/php by having /usr/lib/php in the include path.

XML to HTML entities – Encoding XML document text for HTML

private function XMLtoHTMLEntities($string){
//get rid of any XML entity encoding that may have been applied (like in an RSS feed)
$unXMLEntify = str_replace ( array ( '&' , '"', '&apos;' , '<' , '>'), ->
array ( '&', '"', "'", '<', '>') , $string );
return htmlentities($unXMLEntify);

How to install the pdo myql drivers for php

First install pdo.

I already had php 5 with the pdo extension included in the build. But I needed the mysql driver for the php extension since it only came with 2 (sqlLite, sqlLite2).

To add the mysql driver for pdo in your php install, put ( – you’ll have to compile this) in your extensions directory and then enable that extension in php.ini. WTF, pretty simple but there are no web pages with instructions. And compiling in Mac OS X sucks because you need to install extra Developer tools and than run the command line compile commands.