Last active
December 30, 2017 14:32
-
-
Save hirokazumiyaji/0039b6e1a9e10c88a977 to your computer and use it in GitHub Desktop.
itamae nginx small light recipe
This file contains hidden or 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
execute "apt-get update" | |
execute "download libjpeg-turbo.deb" do | |
command "wget http://sourceforge.net/projects/libjpeg-turbo/files/#{node[:libjpegturbo][:version]}/libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb" | |
cwd "/tmp" | |
not_if "test -d /opt/libjpeg-turbo" | |
end | |
execute "install libjpeg-turbo" do | |
command "dpkg -i libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb" | |
cwd "/tmp" | |
not_if "test -d /opt/libjpeg-turbo" | |
end | |
file "/etc/ld.so.conf.d/libjpeg-turbo.conf" do | |
content "/opt/libjpeg-turbo/lib64/" | |
end | |
execute "apt-get build-dep -y imagemagick" | |
%w(libpcre3 libpcre3-dev libssl-dev libperl-dev libimlib2-dev libwebp-dev devscripts).each do |pkg| | |
package pkg do | |
action :install | |
end | |
end | |
execute "download image magick" do | |
command "wget https://launchpad.net/imagemagick/main/#{node[:imagemagick][:version]}/+download/ImageMagick-#{node[:imagemagick][:version]}.tar.gz" | |
cwd "/tmp" | |
end | |
execute "unarchive image magick" do | |
command "tar zxf ImageMagick-#{node[:imagemagick][:version]}.tar.gz" | |
cwd "/tmp" | |
end | |
execute "confugire image magick" do | |
command "./configure --prefix=/usr --sysconfdir=/etc --enable-shared --with-modules --disable-openmp --with-webp=yes LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include" | |
cwd "/tmp/ImageMagick-#{node[:imagemagick][:version]}" | |
end | |
execute "make image magick" do | |
command "make -j`nproc`" | |
cwd "/tmp/ImageMagick-#{node[:imagemagick][:version]}" | |
end | |
execute "make install image magick" do | |
command "make install" | |
cwd "/tmp/ImageMagick-#{node[:imagemagick][:version]}" | |
end | |
execute "download ngx_small_light" do | |
command "wget https://github.com/cubicdaiya/ngx_small_light/archive/v#{node[:smalllight][:version]}.tar.gz" | |
cwd "/tmp" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "unarchive ngx_small_light" do | |
command "tar zxf v#{node[:smalllight][:version]}.tar.gz" | |
cwd "/tmp" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "setup ngx_small_light" do | |
command "./setup --with-imlib2" | |
cwd "/tmp/ngx_small_light-#{node[:smalllight][:version]}" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "download nginx" do | |
command "wget http://nginx.org/download/nginx-#{node[:nginx][:version]}.tar.gz" | |
cwd "/tmp" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "unarchive nginx" do | |
command "tar zxf nginx-#{node[:nginx][:version]}.tar.gz" | |
cwd "/tmp" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "configure nginx" do | |
command "./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/opt/nginx/sbin/nginx --with-http_stub_status_module --with-http_perl_module --with-pcre --add-module=/tmp//tmp/ngx_small_light-#{node[:smalllight][:version]}" | |
cwd "/tmp/nginx-#{node[:nginx][:version]}" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "make nginx" do | |
command "make -j`nproc`" | |
cwd "/tmp/nginx-#{node[:nginx][:version]}" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
execute "make install nginx" do | |
command "make install" | |
cwd "/tmp/nginx-#{node[:nginx][:version]}" | |
not_if "test -f /opt/nginx/sbin/nginx" | |
end | |
%w(/etc/nginx /opt/nginx/perl/lib /var/run /etc/nginx/conf.d /var/www/nginx/cache /var/www/nginx/images /var/www/nginx/tmp).each do |d| | |
directory d do | |
action :create | |
end | |
end | |
template "/etc/init.d/nginx" do | |
source "templates/etc/init.d/nginx.erb" | |
mode "0711" | |
end | |
template "/lib/systemd/system/nginx.service" do | |
source "templates/lib/systemd/system/nginx.service.erb" | |
mode "0711" | |
end |
This file contains hidden or 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
nginx: | |
version: 1.9.9 | |
libjpegturbo: | |
version: 1.4.2 | |
imagemagick: | |
version: 6.9.2-10 | |
smalllight: | |
version: 0.6.13 |
This file contains hidden or 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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon | |
### END INIT INFO | |
PATH=/opt/bin:/opt/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/opt/nginx/sbin/nginx | |
NAME=nginx | |
DESC=nginx | |
test -x $DAEMON || exit 0 | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid \ | |
--exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
start-stop-daemon --stop --quiet --pidfile \ | |
/var/run/nginx.pid --exec $DAEMON | |
sleep 1 | |
start-stop-daemon --start --quiet --pidfile \ | |
/var/run/nginx.pid --exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration: " | |
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/nginx.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains hidden or 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
[Unit] | |
Description=The NGINX HTTP and reverse proxy server | |
After=syslog.target network.target remote-fs.target nss-lookup.target | |
[Service] | |
Type=forking | |
PIDFile=/var/run/nginx.pid | |
ExecStartPre=/opt/nginx/sbin/nginx -t | |
ExecStart=/opt/nginx/sbin/nginx | |
ExecReload=/bin/kill -s HUP $MAINPID | |
ExecStop=/bin/kill -s QUIT $MAINPID | |
PrivateTmp=true | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment