How to Install Nginx on FreeBSD 9.x

by
Share this Article: Facebook0Google+9Twitter8LinkedIn0Reddit0StumbleUpon0

nginx (pronounced “engine x”) is an open-source web server and a reverse proxy server for HTTP, SMTP, POP3, and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS, Solaris, AIX, HP-UX, and Microsoft Windows.

My test server details:

root@FreBSD-Unixmen:/root # uname -a
 FreeBSD FreBSD-Unixmen 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
 root@FreBSD-Unixmen:/root # date
 Wed May 15 00:09:41 CEST 2013
 root@FreBSD-Unixmen:/root
root@FreBSD-Unixmen:/root # ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
 options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
 ether 08:00:27:6a:0d:00
 inet 192.168.1.117 netmask 0xffffff00 broadcast 192.168.1.255
 nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
 media: Ethernet autoselect (1000baseT <full-duplex>)
 status: active

Install Nginx

Install from the port tree:

cd /usr/ports/www/nginx
make install clean; rehash

bsd-2013-05-16_234206

 

 

 

 

Please select the below options:

[X] HTTP_MODULE Enable HTTP module
[X] HTTP_ADDITION_MODULE Enable http_addition module
[X] HTTP_CACHE_MODULE Enable http_cache module 
[X] HTTP_GEOIP_MODULE Enable http_geoip
 module
[X] HTTP_GZIP_STATIC_MODULE Enable http_gzip_static module
[X] HTTP_IMAGE_FILTER_MODULE Enable http_image_filter module 
[x] HTTP_PERL_MODULE Enable http_perl module 
[X] HTTP_REALIP_MODULE Enable http_realip module
[X] HTTP_REWRITE_MODULE Enable http_rewrite module 
[X] HTTP_STATUS_MODULE Enable http_stub_status module

The config file is:

/usr/local/etc/nginx/nginx.conf

Turn on Nginx Webserver

Type the following command to turn on Nginx server:

echo 'nginx_enable="YES"' >> /etc/rc.conf

The other way to install Nginx is from the Packages Manager:

root@FreBSD-Unixmen:/root # pkg_add -r nginx
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/Latest/nginx.tbz... Done.
pkg_add: package 'nginx-1.2.4,1' or its older version already installed

Restart nginx:

root@FreBSD-Unixmen:/root # /usr/local/etc/rc.d/nginx restart
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
nginx not running? (check /var/run/nginx.pid).
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.

Now open when you are ready! Open the web browser and navigate to www.domain.com of  http://IP

nginx-

 

 

For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Share this Article: Facebook0Google+9Twitter8LinkedIn0Reddit0StumbleUpon0