Nginx

From GeilThings

Jump to: navigation, search
Nginx
General
Version 1.4.2
Stable 1.4.2
Function Web Server
Files
Config File /etc/nginx/nginx.conf
Log File /var/log/nginx/*
Scripts
Version Script nginx -v
Start service nginx start
Stop service nginx stop


Contents

General

  • Start: service nginx start
  • Stop: service nginx stop
  • Version: nginx -v
  • ps aux | grep nginx
    • root ... nginx: master process nginx
    • nginx ... nginx: worker process

Installing Nginx

  • As indicated in http://wiki.nginx.org/Install, using the official yum repository.
  • Also, disable Nginx in the EPEL repository /etc/yum.repos.d/epel.repo (add line: exclude=nginx*).
yum install nginx

Update Nginx

  • Started with 1.0.12.
######### START OF EDIT #########
 
APPNAME=nginx
# If I want to backup, set it to TRUE.
ISBACKUP=TRUE
# BACKUPROOTDIR is only relevant if ISBACKUP=TRUE
BACKUPROOTDIR=/home/backup
DATE=`date +%Y-%m-%d`
 
######### END OF EDIT #########
 
# Check version.
RAWVERSIONSCRIPT=`curl -sd "action=ask&query=[[$APPNAME]]|%3FVersion_Script&format=json" http://www.geilthings.com/api.php` 
DIRTYVERSIONSCRIPT=`echo "$RAWVERSIONSCRIPT" | grep -Po '^.*?\K(?<=Version Script\":\[\").*?(?=\")'`
# Forward slahes will be preceded by Back slashes
CLEANVERSIONSCRIPT=$(echo "$DIRTYVERSIONSCRIPT" |  sed -e 's/\\//g')
RAWOLDVERSION=`$CLEANVERSIONSCRIPT 2>&1`
OLDVERSION=${RAWOLDVERSION:21}
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[$APPNAME]]|%3FStable&format=json" http://www.geilthings.com/api.php`  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
if [[ ${OLDVERSION} != ${NEWVERSION} ]]; then
  echo ${APPNAME}: installed: ${OLDVERSION}, actual: ${NEWVERSION}
  echo "You could update ${APPNAME} to ${NEWVERSION}"
  echo "Would you like to install ${APPNAME} ${NEWVERSION} y/n?"
  read item
  if [[ "$item" == "y" || "$item" == "Y" ]]; then
    echo "Installing ${APPNAME} ${NEWVERSION}. Follow instructions."
  else
    echo "Exit"
  fi
else
  echo "You don't need to update ${APPNAME}; it is uptodate (${NEWVERSION})"
fi
 
# Backup configuration files.
if [[ ${ISBACKUP} == "TRUE" ]]; then
  BACKUPDIR=${BACKUPROOTDIR}/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
   # Create backup directory if it does not exist.
  if [ ! -d "${BACKUPDIR}" ]; then
    mkdir -m 755 -p ${BACKUPDIR}
  fi
  echo ${BACKUPDIR}
  # Backup configuration files.
  cp -rp /etc/nginx/* $BACKUPDIR
fi
 
# Stop the server before updating.
service nginx stop
 
yum update nginx
y
RAWNEWVERSION=`nginx -v 2>&1`
NEWVERSION=${RAWNEWVERSION:21}
# Check.
echo "$APPNAME old version: $OLDVERSION, new version: $NEWVERSION."
 
# Make configuration changes in /etc/ngnix/*, e.g. rename/remove default.conf
# ...
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.$NEWVERSION
 
service nginx start
 
ps aux | grep nginx
 
# Test applications.
# ...

Versions

Software name Version number Version date
Nginx 1.2.6
1.2.7
1.2.8
1.4.0
1.4.1
1.4.2
14 December 2012
12 February 2013
4 April 2013
27 April 2013
18 May 2013
28 July 2013

Comments

blog comments powered by Disqus