Saturday, August 4, 2012

Building nginx from source on mac osx lion

Issues faced while trying to install nginx from source on mac osx lion.

After downloading the latest stable nginx source files I started
to build nginx as instructed on the site .

./configure --conf-path=/etc/nginx --with-http_ssl_module

The first configuration option specifies the location of the nginx.conf file and the second one
ensures that nginx is build with https support for web servers.
There is a wide choice of configuration options that can be found here

The configure stage went through well , however when I tried to do a "make" ,
I ended up with the following error :


objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
objs/ngx_modules.o \
-lpcre -lssl -lcrypto -lz
Undefined symbols for architecture x86_64:
"_pcre_free_study", referenced from:
_ngx_pcre_free_studies in ngx_regex.o
ld: symbol(s) not found for architecture x86_64

 "
A bit of search led me to this.
Reason as mentioned in the solution :

"The Mac OS X have /usr/lib/libpcre.0.dylib in base system and strange system search paths, so installing PCRE into /usr/local/ won't work - the pcre.h will be used from /usr/local/include, but libpcre.0.dylib will be used from /usr/lib (not /usr/local/lib).

So I uninstalled/removed the existing pcre ( I deleted the pcre libs and header files in the /usr/local/include and usr/local/lib folders) and installed pcre using macports .

Reinstalling leads to the pcre files getting installed in /opt/local folders.

Run the configuration step again , otherwise your old Makefile will still point to
the /usr/local for pcre .

After a successful ./configure , do make and then make install .

And you can find your nginx executable in /usr/local/nginx/sbin ( which is the default
location for you nginx executable unless you configure it differently ).

In my case as I configured my conf path differently , I also had the nginx.conf inside 
/etc/nginx/ folder .

You can of course start nginx pointing it to a different configuration file ( with the -c option ).

In the next posts I will try to document my experiment running nginx , in particular how caching
works.






No comments:

Post a Comment