Terry : Installing Nginx

Installing Nginx

Ubuntu

Install nginx and php-fpm on Ubuntu and Ubuntu Server

sudo apt-get install nginx php5 php5-dev php5-fpm php5-mysql mysql-server make

Install latest stable version from Ubuntu Nginx PPA

Use Ubuntu PPA (stable)

sudo add-apt-repository ppa:nginx/stable

NOTE: add-apt-repository is provided by the following packages

  • software-properties-common
  • python-software-properties

or manually add by using the following commands

sudo -s
nginx=stable # use nginx=development for latest development version
echo -e "deb http://ppa.launchpad.net/nginx/$nginx/ubuntu `lsb_release -sc ` main \ndeb-src http://ppa.launchpad.net/nginx/stable/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/nginx-$nginx-lucid.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update 
apt-get install nginx

OR

echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu `lsb_release -sc` main" | sudo tee /etc/apt/sources.list.d/nginx-ppa.list
echo "deb-src http://ppa.launchpad.net/nginx/stable/ubuntu `lsb_release -sc` main" | sudo tee -a /etc/apt/sources.list.d/nginx-ppa.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
apt-get install nginx

LNMP

sudo update-rc.d nginx enable
sudo update-rc.d php5-fpm enable
sudo service nginx start
sudo service php5-fpm start

Debian

/etc/apt/sources.list.d/nginx.list

/etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx

NOTE: get the codename by running

 lsb_release -sc

Red Hat Enterprise Linux and its derivatives (Oracle Linux)

Create /etc/yum.repos.d/nginx.repo

/etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1

Install as root

yum update && yum install nginx

Reference

http://wiki.nginx.org/Install

http://nginx.org/en/docs/