DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Compile & Install Nginx Web Server

06.18.2008
| 11822 views |
  • submit to reddit
        Requirement on Mac OS X: <a href="http://developer.apple.com/tools/xcode/index.html">Xcode</a>

# See:
# - http://en.wikipedia.org/wiki/Nginx
# - http://wiki.codemongers.com/NginxGettingStarted
# - http://wiki.codemongers.com/NginxInstallOptions
# - http://wiki.codemongers.com/NginxCommandLine
# - http://wiki.codemongers.com/NginxConfiguration

export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"

mkdir -p ~/Desktop/Nginx
cd ~/Desktop/Nginx

curl -L -O http://sysoev.ru/nginx/nginx-0.7.2.tar.gz
tar -xzf nginx-0.7.2.tar.gz

curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz
tar -xzf pcre-7.7.tar.gz

cd ~/Desktop/Nginx/nginx-0.7.2
./configure --help
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7
make
sudo make install


which nginx
otool -L /usr/local/sbin/nginx
open /usr/local/nginx
open -e /usr/local/nginx/conf/nginx.conf

nginx -v
nginx -V
sudo nginx   # start server
sudo nginx -t

open http://localhost:80
open http://localhost:80/50x.html

sudo nano /usr/local/nginx/conf/nginx.conf   # editing ... server {  listen  8080; ... 

# reload configuration
sudo kill -HUP `cat /usr/local/nginx/logs/nginx.pid`  

# stop server
sudo kill -15 $(ps -auxxx | egrep "[n]ginx.*master" | awk '{ print $2 }') 2>/dev/null