Install wget in Mac OS X Without Homebrew or MacPorts
Want to have wget on Mac without Homebrew or MacPorts for whatever reason? You can do that by building wget from source at the command line.
The command line tool wget lets you retrieve a group of files from FTP and HTTP protocols, it’s a very useful utility for web developers and powerusers to have around because it lets you do things like perform quick and dirty site backups and even mirror websites locally.
This approach is going to build and install wget in Mac OS X from source, this means you’ll need Xcode (App Store link), or at least and the Unix command line dev tools installed on the Mac, but it has the benefit of eliminating the need of a package manager like Homebrew or MacPorts. Honestly, using Homebrew is much easier and is probably better for most users, but admittedly it’s not for everyone.
For those who don’t have the Command Line Tools package either with or without Xcode installed yet, it’s fairly simple: Open Terminal and type ‘xcode-select –install’, or you can do it from Xcode by opening XCode, then go “Preferences” and to the downloads section, and choose “Install Command Line Tools”, or you can get it from the Apple Developer Site as described here. Because the package has to download from Apple, it may take a while depending on your internet connection. Command Line Tools installs a C compiler, GCC, and many other helpful utilities that are commonly used in the unix world.
How to Install wget in Mac OS X
Moving ahead and assuming you have Xcode and the command line tools installed, launch Terminal and enter the following commands as shown.
First, use curl to download the latest wget source:
curl -O http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
You can check always check for the latest wget version through at ftp.gnu.org/gnu/wget/ here.
Using curl to download the latest wget source for El Capitan, Yosemite, etc:
curl -O http://ftp.gnu.org/gnu/wget/wget-1.16.3.tar.xz
Or to use an older version (prior versions of Mac OS X, including Mavericks, Mountain Lion, etc)
curl -O http://ftp.gnu.org/gnu/wget/wget-1.13.4.tar.gz
(sidenote: a new version of wget may be available, version 1.16.3 (wget-1.16.3.tar.gz) has been confirmed to work in MacOS Mojave, High Sierra, OS X El Capitan and OS X Yosemite, 1.15 is confirmed compatible with OS X Mavericks, while 1.13.4 has been confirmed compatible with OS X Mountain Lion. You can pick whichever one you want from the http://ftp.gnu.org/gnu/wget/ directory if you want a different version)
Next we use tar to uncompress the files you just downloaded:
tar -xzf wget-1.15.tar.gz
Use cd to change to the directory:
Configure with the appropriate –with-ssl flag to prevent a “GNUTLS not available” error:
Note if you still have an error in Mac OS X 10.10+ , Mac OS X 10.11+, macOS Sierra, Mojave, and later, use this variation of configure (from Martin in the comments):
./configure --with-ssl=openssl --with-libssl-prefix=/usr/local/ssl
Build the source:
Install wget, it ends up in /usr/local/bin/:
sudo make install
Confirm everything worked by running wget:
Clean up by removing wget source files when finished:
cd .. && rm -rf wget*
You’re all set, enjoy wget in Mac OS X.
The latest version of wget should configure, make, and install fine in Mac OS X El Capitan and Yosemite as well.
For most Mac users, they’ll likely want to simply install Homebrew first and then get wget, simply because Homebrew makes command line package management incredibly easy and there’s no manual building and compiling of source code necessary.