Created
September 25, 2018 15:17
-
-
Save simcap/2507031214d4a22809a6dc0cd0c8a1a6 to your computer and use it in GitHub Desktop.
Ansible nginx from source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- vars --- | |
nginx_version: 1.14.0 | |
nginx_default_dir: "/usr/local/nginx" | |
nginx_binary_url: "http://nginx.org/download/nginx-{{ nginx_version }}.tar.gz" | |
open_ssl_package: "openssl-1.0.2p" | |
open_ssl_url: "http://www.openssl.org/source/{{ open_ssl_package }}.tar.gz" | |
zlib_package: "zlib-1.2.11" | |
zlib_url: "http://zlib.net/{{ zlib_package }}.tar.gz" | |
pcre_package: "pcre-8.42" | |
pcre_url: "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/{{ pcre_package }}.tar.gz" | |
--- vars --- | |
- name: Install build essential | |
apt: name=build-essential state=latest update_cache=yes | |
become: yes | |
# Installing NGINX from source with latest stable and secure packages. | |
# See https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources | |
# PCRE | |
- name: Download {{ pcre_package }} | |
unarchive: | |
src: "{{ pcre_url }}" | |
dest: /tmp | |
remote_src: yes | |
- command: "{{ item }} chdir=/tmp/{{ pcre_package }}" | |
with_items: | |
- ./configure | |
- make | |
- sudo make install | |
# ZLIB | |
- name: Download {{ zlib_package }} | |
unarchive: | |
src: "{{ zlib_url }}" | |
dest: /tmp | |
remote_src: yes | |
- command: "{{ item }} chdir=/tmp/{{ zlib_package }}" | |
with_items: | |
- ./configure | |
- make | |
- sudo make install | |
# OpenSSL | |
- name: Download {{ open_ssl_package }} | |
unarchive: | |
src: "{{ open_ssl_url }}" | |
dest: /tmp | |
remote_src: yes | |
- command: "{{ item }} chdir=/tmp/{{ open_ssl_package }}" | |
with_items: | |
- ./config | |
- make | |
- sudo make install | |
# NGINX | |
- name: Download nginx {{ nginx_version }} | |
unarchive: | |
src: "{{ nginx_binary_url }}" | |
dest: /tmp | |
remote_src: yes | |
- command: ./configure --with-http_stub_status_module --with-http_ssl_module --with-openssl=/tmp/{{ open_ssl_package }} --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-pcre=/tmp/pcre-8.42 --with-zlib=/tmp/zlib-1.2.11 --with-stream | |
args: | |
chdir: /tmp/nginx-{{ nginx_version }} | |
- command: "{{ item }} chdir=/tmp/nginx-{{ nginx_version }}" | |
with_items: | |
- make | |
- sudo make install | |
- name: Copy nginx conf (doing back up of original conf) | |
copy: src=nginx.conf dest={{ nginx_default_dir }} backup=yes | |
become: yes | |
- name: Create symlik to nginx | |
file: state=link src=/usr/local/nginx/sbin/nginx dest=/usr/bin/nginx | |
become: yes | |
- name: Start nginx | |
command: sudo /usr/bin/nginx | |
become: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment