ScaleScaleScaleScale

Tips / Nginx


How to Install Nginx on Ubuntu

Ubuntu already comes with a Nginx version, in particular an old version of Nginx. So, you have two ways to install Nginx on Ubuntu, you use the default system repositories or you can add Nginx Ubuntu/Debian repo. On this tutorial we will explore both options.

Install Nginx using Ubuntu default repo

sudo apt-get install nginx

Start Nginx

sudo service nginx start

Confirm Nginx Has Started

ps -aux | grep nginx

Output should show something like this:

root@server:~# ps -aux | grep nginx
root      1481  0.0  0.0  31124   980 ?        Ss   Jan17   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx     1484  0.0  0.1  31468  1884 ?        S    Jan17   0:00 nginx: worker process

The result: Nginx 1.1.19 is up and running fine.

But let’s see how to install the latest version of Nginx.

Install Latest Nginx version on Ubuntu

Download signing key  from Nginx.org:

wget http://nginx.org/keys/nginx_signing.key

Apply the key to your apt repos

sudo apt-key add nginx_signing.key

Add the Precise repo

deb http://nginx.org/packages/ubuntu/ precise nginx
deb-src http://nginx.org/packages/ubuntu/ precise nginx

Update repo and Install Nginx:

apt-get update
apt-get install nginx

Start the service:

service nginx start

The result:

root@server:~# nginx -V
nginx version: nginx/1.4.4
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-p
ath=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/va
r/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/p
roxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
 --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_real
ip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-ht
tp_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_s
ecure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy
_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-
security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed' --with-ipv6

That’s all, at this point you should have Nginx properly installed on Ubuntu Linux.

Popular search terms:

  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1839 PSt2fq9d4kFQiFIXOrKbgfaHY3KIfniwezsVYlpt8FknitwY-02vrBLn0kWb-3fD 6540250e5307ad6511695e90974237801f67f3ae&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
profile

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking