First of all, you don’t need the CPATH or LIBRARY_PATH environment variables to run lame. They’re only needed when compiling software.
Second of all, you don’t need /usr/local/lib in LD_LIBRARY_PATH. Normal system library paths like that are always searched, regardless of the value of the variable.
Third, the working directory for processes run by PHP is usually going to be the directory of the PHP script, not your home directory. If in doubt, use an absolute path.
Finally, the best way to set environment variables for a single command like this is using the “env” utility. Try something like:
shell_exec(‘env TMPDIR=$HOME/tmp PATH=$HOME/lame/bin:$PATH LD_LIBRARY_PATH=$HOME/lame/lib lame -b128 /home/you/mysite.com/music/somemusic.mp3 /home/you/mysite.com/music/somemusic.wav’);
NB: ffmpeg is already installed on the server, and may be easier to use, e.g.
shell_exec(‘ffmpeg -ab 128k -i /path/to/input.wav /path/to/output.mp3’);