Nginx-Proxying-to-Apache Install Guide
If your Accelerator was built using the new pkgsrc-based template (April 2008 and on), you do not need to built either of these packages (OpenSSL, PCRE, Nginx). You should already have Nginx built and ready at /opt/local/sbin/nginx. In fact, if you do follow this page, you’ll break the dependencies of Postfix and other packages on the PCRE library. You can build your own, but you’d need to use a different prefix than /opt/local, which is used by the new template layout.
Apache is a fantastic web server. It has been around a long time and has proven itself to be highly compatible, flexible and reliable. Apache’s performance is generally very good as well. However, in a resource-constrained environment such as an “S” or “M” accelerator, Apache does not necessarily provide optimal performance or resource utilization. This becomes especially evident in a high traffic site that makes use of dynamic content such as php, python/django, ruby/rails, etc.
One of the “best practice” approaches to reducing the strain on Apache is to let a leaner lighter web server take over the serving of the site’s static files (images, javascript, css, etc.), leaving the heavy lifting of serving the dynamic content to Apache. When Apache is relieved of the burden of serving up all the ancillary static content, its full power can be focused on the dynamic content. Memory consumption is also reduced when there is no need to fork multiple memory-hungry Apache processes just to serve up simple images or JavaScript files.
In this how-to, I will show you how I configured Nginx as a front-end web server to handle static content while proxying all other requests to Apache. Nginx is one of several possible choices for a front-end proxying server. Lighttpd is another popular choice. However, lighttpd has been widely reported to suffer some stability and memory-leakage problems when used in a proxying configuration. I have found nginx to be rock-solid in this scenario.
Some Solaris build tools reside in /usr/ccs/bin, which needs to be added to your path if it not there. I just tacked it onto the end:
$ nano -w ~/.bashrc export PATH=/usr/sbin:/usr/bin:/usr/sfw/bin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gnu:/opt/csw/gcc3/bin:/opt/csw/mysql5/bin:/opt/csw/postgresql/bin:/opt/csw/apache2/bin:/opt/csw/apache2/sbin:/usr/ccs/bin
Now refresh your shell so it sees the modified PATH variable:
I like to build local packages in /opt/local/src. This directory was not included in my accelerator so I created it:
$ sudo mkdir -p /opt/local/src $ sudo chgrp staff /opt/local/src $ sudo chmod 775 /opt/local/src
In order to build Nginx for Solaris, we must first satisfy a couple of dependencies, namely pcre ( Perl Regular Expression Library) and OpenSSL. (Although OpenSSL is not strictly needed, I like to include it for completeness.) All builds will be full 64-bit.
$ cd /opt/local/src/ $ wget http://internap.dl.sourceforge.net/sourceforge/pcre/pcre-7.1.tar.gz $ tar xzf pcre-7.1.tar.gz $ cd pcre-7.1 $ CFLAGS=»-m64 -O2 -g -Wall» CXXFLAGS=»-m64 -O2 -g -Wall» LDFLAGS=» -L/lib/64 -L/usr/sfw/lib/64 -R/usr/sfw/lib/64 -R/lib/64″ ./configure –prefix=/opt/local –enable-utf8 –enable-unicode-properties $ make $ make test $ sudo make install
Note : Putting the libpcre* file in /opt/local/lib will overwrite the existing version used by apache, postfix, and others. I installed this version in /opt/local/lib64. I added this lib to the nginx install instructions below.
Source: