Install wget in Mac OS X Without Homebrew or MacPorts

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 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.

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 OS X

Moving ahead and assuming you have Xcode and the command line tools installed, launch Terminal and enter the following commands as shown.

Or to use an older version (prior versions of OS X)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 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:cd wget-1.15

Configure with the appropriate –with-ssl flag to prevent a “GNUTLS not available” error:./configure --with-ssl=openssl

Note if you still have an error in OS X 10.10+ and OS X 10.11+, use this variation of configure (from Martin in the comments):

On Sierra (10.12.3), the following has been shown to work on a clean install of the OS:

1. download openssl 0.9.8zg ( i won’t repeat the link; it’s been cited already). Note: the 0.9.8 zh package from various sources seems to be missing stuff, like the needed “include” directory. So don’t use that, even though openssl version commands on this OS indicate “zh” as the variant.

2. unpack the openssl bundle into a tree somewhere…i used /usr/local/openssl-0.9.8zg , though that might not be strictly kosher because it’s not an installed thing at that point

3. back where you unpacked wget, run the following, substituting the correct location of where you unpacked in step (2)

the reason for this approach is because the OS has the ‘binary install’ of openssl (in the standard /usr/lib directory) but doesn’t have sources (namely, the headers), at least not that I could find nor detectable by pkg-config. So the sources have to be downloaded separately and ‘config’ must be told explicitly where they are , via the OPENSSL_CFLAGS var.
The OPENSSL_LIBS var is necessary because using pkg-config (which is triggered when you use the –with-xxxxx flag to ‘config’) is kind of all-or-nothing; so even though the /usr/lib is the standard place that would be found by pkg-config, it needs to be made explicit because pkg-config won’t run for openssl here
(* I oversimplified that somewhat for sake of clarity)

Also as a warning: I’ve read guides that advocate copying the sources of openssl (downloaded and unpacked in my step (2) above) into system directories like /usr/include …or slightly less evil, symlinking. Don’t do this. If the OS ever upgrades openssl, it will have no way of knowing your headers are now “stale” and you could run into mystery compile errors down the line that may be very hard to track down

Perhaps even more dangerous is actually *building* and *installing* the openssl you downloaded… Really don’t do this!
You will essentially “upgrade” openssl in the system in a very transparent-to-the-OS way and while it probably will be Ok, it’s impossible to tell what the sideeffects to the OS and/or preexisting apps/binaries will be

I wish I had just scrolled to the bottom and installed brew first. All of these instructions will lead to headaches if you’re on 10.12. I just wanted to install wget, I didn’t want to waste my whole Saturday afternoon.

Setting the various flags suggested above does not change this. I assume that Apple has removed files now that openssl is deprecated. Probably the right thing to do would be to use Apple’s internal SSL rather than openssl.

Gotta say… I followed a million different leads on this comment page to no avail and then installed wget in a total of 5 seconds by installing brew (which also took 5 seconds). Just in case you’re looking for a hands-off approach to getting wget on your mac.

Thanks bliemli but I’m still not there yet and not skilled enough to troubleshoot. I’ve followed much of Gustavo’s instructions with the OPENSSL_LIBS & OPENSSL_CFLAGS changes from Jon and I used wget-1.17. The ./configure fails for me, I tried all 3 variants listed here:

All fail as follows:
.
.
checking for inet_ntoa… yes
checking for socket in -lsocket… no
checking for pkg-config… no
checking for LIBPSL… no
checking for library containing psl_builtin… no
configure: WARNING: *** libpsl was not found. Fallback to builtin cookie checking.
checking for ZLIB… no
checking for compress in -lz… yes
checking for dlopen in -ldl… yes
checking for libssl… no
configure: error: –with-ssl=openssl was given, but SSL is not available.

Unfortunately, the way the double quotes are presented there, and how they copy across into the terminal means that the environment variables are not set correctly. Just copy the lines above and edit the quotes to use the one on your keyboard and all should be well….

You are getting syntax errors because you’re injecting random characters into your paths and syntax, who knows why you are doing that, I can’t answer that for you, but that is why you’re seeing “not a valid identifier” and “no such file or directory” – you have bungled the path and the syntax.

I was able to successfully compile wget 1.16.3 on 10.11. You need to tell wget to use openssl via parameter –with-ssl=openssl and set the OPENSSL_LIBS and OPENSSL_CFLAGS environment variables, or the script will complain about not being able to find pkg-config. I found the appropriate values for the env vars in /usr/lib/pkgconfig/libssl.pc. Setting the parameter –with-libssl-prefix=/usr didn’t work, it couldn’t find the libraries nonetheless.

Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic .
Please send bug reports and questions to .

“checking for OPENSSL… no
configure: error: in `/Users/end/Downloads/Sources/wget-1.16.3′:
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.”

Copy and paste my previous example did not work because the ./configure options needs to start with two dashes “–with…” instead of one “-with…”
I don’t know if the OSXDaily comments get changed during the publishing….
It should look like this ( without quotes ):
“./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/ssl”

Your instructions for getting wget worked perfectly for me until I got to the step:
Build the source:
make
At that point, after entering “make” and pressing enter, I got the following:
-bash: make: command not found
Please advise, thanks!

I’ve used unix on occasion since 1882, uh, I mean 1982. Though I have not bothered to commit all 1,782 unix commands to memory; hence my unfamiliarity with make. I hear that memorizing unix commands and their synatax is a known, sure, drug-free cure for insomnia… I have no difficulty sleeeeping…

everything was fine until i typed “wget –help”, the return message was, “-bash: wget: command not found”. Any idea what i could be doing wrong guys? I installed x-code, macports, and command line tools already.

I used to do the whole download, tar zxvf, configure, make, make install process and it’s simply not worth it. Not when it’s easier to copy and paste the Homebrew installation script to the Terminal once and then simply issue “brew install wget” and suddenly, you have wget installed and working. You are bound to find other items missing from OS X that can be installed with Homebrew.

Plus you can easily update what you’ve installed with brew when new releases or security issues are fixed. The only downside to Homebrew is that it doesn’t seem to work well with multiple local user accounts. The /usr/local folders get owned by one user. So if you do switch user accounts you’ll need to “su – admin” where admin is the account you installed brew with. Regular users can run the programs installed by brew but they can’t install other brew recipes nor update brew itself. Some users have assigned an admin group to /usr/local so any administrator level user can work with brew commands.

Homebrew is an easier to use system than Macports and both are package managers. Redhat and Debian pretty much invented the concept of package management where users could pull packages from a repository and the installation would be heavily automated. Windows Update didn’t exist at the time and I think only Netware had something even remotely close. Nowadays you can setup a virtual farm of developer workstations and automate the entire process of generating new virtual machines and configuring their software via puppet scripts and yes driving brew commands via puppet as well. This ensures all the workstations are consistent in their configurations and software versions, etc. Doing things by hand is tedious and error prone.

So if you are one guy with one computer that you own and manage yourself, sure, go right ahead and manually download, configure, compile, and install each and every single Unix/Linux application. I remember having to do this to install Netscape or the Gimp. Examining ./configure –help to ensure I was passing the right parameters and options, etc. Struggling with dependencies between applications using different versions of the same libraries. Creating symbolic links from newer library versions to an older library version required by a single application. It’s just plain painful, especially if you have to do that to 300+ computers on a regular basis. So if it’s good enough for the SysAdmins it’s good enough for anyone! After all, SysAdmins are lazy and didn’t we buy Mac’s to make things easier? Wasn’t that the point? Otherwise, I might as well be running a Slackware Linux distro from 1992!

Do yourselves a favor and use a package manager such as Macports or Homebrew and avoid manually downloading, compiling and installing software. But if for some reason you have to do it, change the default path via the .configure.sh from /usr/local to /opt/local which isn’t used that much and keeps the individual manual installations away from the automated ones.

This website and third-party tools use cookies for functional, analytical, and advertising purposes. By continuing to browse the site, closing this banner, scrolling this webpage, or clicking a link, you agree to these cookies. You can review our privacy policy for additional information.I AcceptPrivacy Policy