These are my notes for installing Nginx on Ubuntu Hardy 8.04 Server with SSL support. This was pieced this together from many different sources, thanks everyone for their help.
Install prerequisites:
aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev build-essential
Download, configure, and install Nginx:
mkdir ~/sources cd ~/sources wget http://sysoev.ru/nginx/nginx-0.6.31.tar.gz tar -zxvf nginx-0.6.31.tar.gz cd nginx-0.6.31/ ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module make make install
Installation complete, lets start it up:
/usr/local/sbin/nginx
Visit http://example.com and you should see the “Welcome to Nginx” page. Congrats! Now lets stop it:
kill `cat /usr/local/nginx/logs/nginx.pid`
Now we’ll create an INIT script so we can start/stop/restart it just like Apache, save this as /etc/init.d/nginx
#! /bin/sh ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/sbin/nginx NAME=nginx DESC=nginx test -x $DAEMON || exit 0 # Include nginx defaults if available if [ -f /etc/default/nginx ] ; then . /etc/default/nginx fi set -e case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --pidfile \ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON sleep 1 start-stop-daemon --start --quiet --pidfile \ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; reload) echo -n "Reloading $DESC configuration: " start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 exit 1 ;; esac exit 0
Give it some permissions:
chmod +x /etc/init.d/nginx
Make Nginx startup on system boot:
/usr/sbin/update-rc.d -f nginx defaults
Setup rotation of the nginx logs:
/etc/logrotate.d/nginx
/usr/local/nginx/logs/*.log { daily missingok rotate 30 compress delaycompress notifempty create 640 root adm sharedscripts postrotate [ ! -f /usr/local/nginx/logs/nginx.pid ] || kill -USR1 `cat /usr/local/nginx/logs/nginx.pid` endscript }
Now you can start,stop, & restart nginx like so:
/etc/init.d/nginx start /etc/init.d/nginx stop /etc/init.d/nginx restart
0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment