Running wget from php page on OS X

Ki Kim's picture

My php page had a line like,

<?php
  shell_exec
('wget <a href="http://www.example.com/path/to/something'">http://www.example.com/path/to/something'</a>);
?>

The actual parameters of wget command were more complicated. There were two things I had to resolve. wget command does not come with OS X by default, so you needed to install it first. One of easy ways to install wget is through homebrew, which I already had. I simply ran,

$ brew install wget

Ron explained how to install homebrew.

But then I figured that apache running the php page could not find wget command, which is located in /usr/local/bin/wget. I use MAMP and I had to tell MAMP where to look for wget. I opened up text file, /Applications/MAMP/Library/bin/envvars and added the following line in it,

export PATH=$PATH:/usr/local/bin

Stop and start Apache Server of MAMP and the problem was solved.

Category: 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
To prevent automated spam submissions leave this field empty.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.