gplessis/dotdeb-nginx

Upgrading from Nginx 1.7.7 to Nginx 1.10.1 Stable

Closed this issue · 10 comments

Hello @gplessis

I'm running out of ideas that how to upgrade from nginx 1.7.7 to latest stable.
Here's the issue I'm facing from past few weeks.
Tried alot ways and ran out of ideas and tries.

I had a wheezy server and I successfully upgraded to jessie and also upgraded few other packages to latest and tested they are working fine.
And now i want to upgrade nginx to latest stable on jessie.
Can anyone of please, list out the ways to do it without replacing the old cnf files.

Waiting for responses,

Thanks
Teja

Hi,

Starting from a Debian-only sources.list, please follow these instructions to add Dotdeb as a potential repository for Nginx.

Even if the upgrade process will not change your configuration files without any notice, make a backup of your /etc/nginx/ directory before any further move.

Then, depending on which flavor of Nginx you want (nginx-light, nginx-full, nginx-extras), you should be able to upgrade it to the latest stable version by executing:

apt-get install nginx # << replace by the picked flavor

Important note when upgrading : please make sure that you have the following line at the beginning of your /etc/nginx/nginx.conf file :

include /etc/nginx/modules-enabled/*.conf;

That should be it.

Hi again,

I've added dotdeb line to my sources.list file and here's my file below

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

deb http://mirrors.kernel.org/debian jessie main
deb-src http://mirrors.kernel.org/debian jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://mirrors.kernel.org/debian jessie-updates main
deb-src http://mirrors.kernel.org/debian jessie-updates main ]

Then I ran $ sudo apt-get update
After it ran successfully, ran below command to upgrade my nginx...

vagrant@development:/etc/nginx$ sudo apt-get install nginx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nginx : Depends: nginx-full (>= 1.10.2-2~dotdeb+8.2) but it is not going to be installed or
                  nginx-light (>= 1.10.2-2~dotdeb+8.2) but it is not going to be installed or
                  nginx-extras (>= 1.10.2-2~dotdeb+8.2) but 1.6.2-5+deb8u4 is to be installed
E: Unable to correct problems, you have held broken packages.

Also, I've added the line in my /etc/nginx/nginx.conf file, that you posted in previous comment by @gplessis

What is the output of this command on your machine? dpkg -l '*nginx*'| grep '^.i'

dpkg -l 'nginx' | grep '^.i'
hi nginx 1.7.7-2~wheezy amd64 high performance web server

Sorry for the late reply @gplessis ...
The above was the nginx package installed in my case.
Wanted to update my nginx to latest stable 1.10.1.
Help me out...

Thanks!
Teja

Could you please try apt-get install nginx-full ?

As mentioned by @rockyluke , installing explicitely nginx-fullcould help. If APT still complains about dependency, please try to use a package manager such as aptitude or dselect to get more details about the problematic dependency.

@ttalla14 any feedback?

Hi again @gplessis ...
I figured out by removing and installing from source build through Nginx successfully...
Here is my playbook for nginx upgrade....

  • name: check if nginx installed
    shell: dpkg --get-selections | grep "nginx"
    register: nginxNotInstalled
    changed_when: False
    ignore_errors: True

  • name: Backup /etc/nginx
    shell: tar cf {{ nginxbackup }}/nginx.tar /etc/nginx /var/log/nginx /etc/init.d/nginx
    register: nginxbackup

  • name: Stopping nginx service if installed
    service: name=nginx state=stopped
    register: nginx_stopped
    when: nginxbackup or nginxNotInstalled | success

  • name: remove nginx
    shell: apt-get remove -y nginx && apt-get purge -y nginx
    when: nginx_stopped | success

  • name: autoremove nginx
    shell: apt-get autoremove -y nginx && apt-get -y clean

  • name: install nginx requirements
    apt: >
    name={{ item }} state=installed update_cache=yes cache_valid_time=86400
    with_items:

    • liblua5.1-0
    • libluajit-5.1-dev
  • name: APT | update
    apt: update_cache=yes force=yes

  • name: getting nginx-1.10.2 from nginx source and it /opt
    get_url: >
    url=http://nginx.org/download/nginx-1.10.2.tar.gz
    dest=/opt/
    owner=root group=root mode=0600

  • name: getting headers-more-nginx-module
    get_url: >
    url=https://github.com/openresty/headers-more-nginx-module/archive/v0.32.tar.gz
    dest=/opt/
    owner=root group=root mode=0660

  • name: getting lua-nginx-module from openresty source github repo...
    get_url: >
    url=https://github.com/openresty/lua-nginx-module/archive/v0.10.7.tar.gz
    dest=/opt/
    owner=root group=root mode=0600

  • name: extracting the downloaded libraries and source modules into /opt/nginx
    unarchive: >
    src=/opt/{{ item }}
    dest=/opt/
    remote_src=True
    with_items:

    • nginx-1.10.2.tar.gz
    • headers-more-nginx-module-0.32.tar.gz
    • lua-nginx-module-0.10.7.tar.gz
  • name: ./configure --with-modules
    shell: >
    cd /opt/nginx-1.10.2 && ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_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-file-aio --with-threads --with-ipv6 --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --add-module=/opt/headers-more-nginx-module-0.32 --add-module=/opt/lua-nginx-module-0.10.7

  • name: make, ./configure --with-modules and make installing nginx
    shell: cd /opt/nginx-1.10.2 && make && make install

  • name: syncing previously installed nginx conf to original
    shell: cd / && rm -rf /etc/nginx && tar xf {{nginxbackup}}/nginx.tar && mkdir -p /var/cache/nginx/fastcgi-cache/

  • name: changing module spdy to http2 on .conf's
    shell: sed -i 's/spdy/http2/g' /etc/nginx/sites-available/{{ item }}
    with_items:

    • xxxx.conf
    • xxxx.conf
  • name: start nginx through /etc/init.d/nginx.sh
    shell: /etc/init.d/nginx restart

  • name: Starting nginx service if installed
    service: name=nginx state=started
    register: nginx_started

So it worked great and need to check it on my stage environment...
Thanks for the responses...