• Home
  • The Song
  • The Avatar
  • The Cat
  • Contact the Cat

Gyp the Cat dot Com

Installing Nginx (LEMP) on Ubuntu 11.10
internet

Installing Nginx (LEMP) on Ubuntu 11.10

I’ve been using Apache for a number of years, and recently had to get Nginx working on Ubuntu for a client.  There is a good number of tutorials out there, but none I could find apply to any of the more recent versions of Ubuntu.

We will assume you have a fresh, clean install of Ubuntu 11.10.  Each of the commands below goes on it’s own line and press enter afterwards.

Firstly we need to logon to our server using SSH.

ssh [email protected]

Not lets install the MySQL server.

apt-get install mysql-server mysql-client

Now lets install all that wonderful PHP.

apt-get install php5-cgi php5-cli php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-gd

Now as the server we’ll install Nginx.

apt-get install nginx

We need to edit some of the options, we’ll create the following file first to help with our configuration.

nano /etc/init.d/php-fastcgi

Now populate it with the following:

#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=5
PHP_FCGI_MAX_REQUESTS=500

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS=”- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND”
RETVAL=0

start() {
echo -n “Starting PHP FastCGI: ”
start-stop-daemon –quiet –start –background –chuid “$USER” –exec /usr/bin/env — $PHP_CGI_ARGS
RETVAL=$?
echo “$PHP_CGI_NAME.”
}
stop() {
echo -n “Stopping PHP FastCGI: ”
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo “$PHP_CGI_NAME.”
}

case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: php-fastcgi {start|stop|restart}”
exit 1
;;
esac
exit $RETVAL

Now lets make sure that Nginx is ready to run that nice PHP.

Open up the default Nginx site.

nano /etc/nginx/sites-enabled/default

Find the line that reads:

index index.html index.htm;

And make it look like:

index index.php index.html index.htm;

Make sure the following lines ARE NOT commented out:

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

Now somewhere at the top within the server{ } section, put the following, but feel free to change the maximum upload size to something of your choosing.

client_max_body_size 20M;

Now lets make sure PHP is ok with files that big.

nano /etc/php5/cli/php.ini

And update the following line to:

upload_max_filesize = 20M

Now the same for the other ini file.

nano /etc/php5/cgi/php.ini

upload_max_filesize = 20M

Now lets make our FastCGI executable:

chmod +x /etc/init.d/php-fastcgi

Give FastCGI a gentle kick:

/etc/init.d/php-fastcgi start

Now lets make sure it starts when/if the server reboots:

update-rc.d php-fastcgi defaults

And finally lets start up Nginx:

/etc/init.d/nginx start

All done, you can now upload your site to /usr/share/nginx/www which is the default path for Nginx on Ubuntu.

Related

Written by gyp - April 29, 2012 - 3912 Views
Tags | internet, linux, nginx

You Might Also Like

How to fix Mail Loops Back to Myself

October 13, 2010

MX Records, FQDNs, Host Names and Dots

November 2, 2010

How Secure is Your Password? Rainbow Tables Online

August 3, 2011

3 Comments

  • How to Install Wordpress with SSH and Nginx | Gyp the Cat dot Com May 1, 2012 at 3:16 pm

    […] happy too.  We’ll assume you’re using Ubuntu 11.10 for this How To and running a LEMP server, although tailoring for Apache should be easy enough too using this […]

    Reply
  • Setting up Nginx with Cloudflare | Gyp the Cat dot Com September 19, 2013 at 9:16 pm

    […] will assume you already have a working LEMP server […]

    Reply
  • Installing LEMP on Ubuntu 14.04 with Nginx and NAXSI | Gyp the Cat dot Com June 20, 2015 at 10:18 pm

    […] after my last tutorial about getting a LEMP server on Ubuntu 11.10 I’m very happy to announce that the process is now a heck of a lot easier on 14.04!  As a matter […]

    Reply
  • Please Post Your Comments & Reviews
    Cancel reply

    Your email address will not be published. Required fields are marked *

    Previous Post
    Next Post

    Latest Posts

    • How to Convert CSV to Parquet Easily with Python on Linux Shell
    • Kusto Geolocation IP Lookup
    • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
    • HTTP to HTTPS Redirect on Azure CDN
    • Strongswan IPSec (Including Cryptomap) to Microsoft Azure Virtual Network Gateway
    • Black Ops 3 NAT Type Strict & PS4 NAT Type 3 with pfSense Fixed!
    • Sorry for the lack of posts
    • How to Block Internet Access with Group Policy (GPO)
    • Enforcing Microsoft Office 365 and Azure Tennancy with McAfee Web Gateway (MWG)
    • Scanning Subnet for Issuing Certificate Authority with OpenSSL

    Top Posts & Pages

    • How to Block Internet Access with Group Policy (GPO)
      How to Block Internet Access with Group Policy (GPO)
    • How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
      How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
    • Kusto Geolocation IP Lookup
      Kusto Geolocation IP Lookup
    • Tinyproxy A Quick and Easy Proxy Server on Ubuntu
      Tinyproxy A Quick and Easy Proxy Server on Ubuntu
    • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
      Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
    • How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
      How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
    • How to Add Different Disclaimers using alterMIME and Postfix based on Domain
      How to Add Different Disclaimers using alterMIME and Postfix based on Domain
    • Blocking Countries on Nginx without the GeoIP Module
      Blocking Countries on Nginx without the GeoIP Module
    • How to Enable Squid Anonymous Stealth Mode
      How to Enable Squid Anonymous Stealth Mode
    • Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan
      Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan

    Tags

    apache2 azure azure log analytics blops business centos cheating cissp cloudflare cryptography dns game google gyp internet iphone ipsec isc linux mac marketing microsoft mw2 mx mysql nginx pfsense postfix proxy ps3 qualification radius revision security seo smtp socks squid ssh strongswan tinyproxy ubuntu windows 2012 wordpress xdecrypt.com
    Gyp the Cat dot Com

    Some rights retained Gyp the Cat Dot Com