-
-
Save Kali-lightsaber/9921643c05e03948ca2e2c99dfafabac to your computer and use it in GitHub Desktop.
Ubuntu 16.04 に nginx-build を使って openresty + ngx_small_light + ngx_dynamic_upstream を入れる
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
#!/bin/bash | |
apt-get update -y | |
apt-get install -y libpcre2-dev imagemagick libimlib2-dev libgd-dev libmagickwand-dev libxml2-dev libxslt-dev libgeoip-dev libperl-dev curl git openssl libssl-dev | |
ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Wand-config /usr/bin/ | |
mkdir -p /usr/local/src/nginx/modules | |
cd /usr/local/src/nginx/modules | |
git clone https://github.com/cubicdaiya/ngx_dynamic_upstream | |
git clone https://github.com/cubicdaiya/ngx_small_light | |
cd ngx_small_light | |
./setup --with-imlib2 --with-gd | |
curl -sL https://github.com/cubicdaiya/nginx-build/releases/download/v0.9.8/nginx-build-linux-amd64-0.9.8.tar.gz | tar zx -C /usr/bin/ | |
cat <<'EOC' > /tmp/nginx.configure | |
./configure \ | |
--prefix=/opt/openresty/nginx \ | |
--with-cc-opt=-O2 \ | |
--with-ld-opt=-Wl,-rpath,/opt/openresty/luajit/lib \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--sbin-path=/usr/sbin/nginx \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--pid-path=/var/run/nginx.pid \ | |
--lock-path=/var/lock/subsys/nginx \ | |
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body \ | |
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy \ | |
--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-http_v2_module \ | |
--with-ipv6 \ | |
--with-http_ssl_module \ | |
--with-http_realip_module \ | |
--with-http_addition_module \ | |
--with-http_xslt_module \ | |
--with-http_image_filter_module \ | |
--with-http_geoip_module \ | |
--with-http_sub_module \ | |
--with-http_dav_module \ | |
--with-http_flv_module \ | |
--with-http_mp4_module \ | |
--with-http_gzip_static_module \ | |
--with-http_random_index_module \ | |
--with-http_secure_link_module \ | |
--with-http_degradation_module \ | |
--with-http_stub_status_module \ | |
--with-http_perl_module \ | |
--with-http_gunzip_module \ | |
--with-http_auth_request_module \ | |
--with-mail \ | |
--with-mail_ssl_module \ | |
--add-module=/usr/local/src/nginx/modules/ngx_small_light \ | |
--add-module=/usr/local/src/nginx/modules/ngx_dynamic_upstream \ | |
EOC | |
nginx-build -d /usr/local/src/nginx -openresty -c /tmp/nginx.configure -verbose | |
cd /usr/local/src/nginx/openresty/1.11.2.1/openresty-1.11.2.1 | |
make install | |
useradd -r -s /sbin/nologin nginx | |
mkdir -p /var/cache/nginx/fastcgi_temp /var/lib/nginx/tmp/{client_body,proxy} | |
chown -R nginx: /var/cache/nginx/fastcgi_temp /var/lib/nginx/tmp/{client_body,proxy} | |
# install opm | |
curl -L https://raw.githubusercontent.com/openresty/opm/master/bin/opm -o /opt/openresty/nginx/bin/opm | |
chmod +x /opt/openresty/nginx/bin/opm | |
# install luarocks | |
cd /usr/local/src/ | |
curl -L http://keplerproject.github.io/luarocks/releases/luarocks-2.4.1.tar.gz -O | |
tar zxf luarocks-2.4.1.tar.gz | |
cd luarocks-2.4.1/ | |
./configure --prefix=/opt/openresty/nginx/luajit --with-lua=/opt/openresty/nginx/luajit --lua-suffix=jit-2.1.0-beta2 --with-lua-include=/opt/openresty/nginx/luajit/include/luajit-2.1 | |
make build | |
make install | |
cat << 'EOC' > /lib/systemd/system/nginx.service | |
[Unit] | |
Description=A high performance web server and a reverse proxy server | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/run/nginx.pid | |
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' | |
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' | |
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload | |
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid | |
TimeoutStopSec=5 | |
KillMode=mixed | |
[Install] | |
WantedBy=multi-user.target | |
EOC | |
systemctl enable nginx.service | |
systemctl start nginx.service |
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
./configure \ | |
--prefix=/opt/openresty/nginx \ | |
--with-cc-opt=-O2 \ | |
--with-ld-opt=-Wl,-rpath,/opt/openresty/luajit/lib \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--sbin-path=/usr/sbin/nginx \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--pid-path=/var/run/nginx.pid \ | |
--lock-path=/var/lock/subsys/nginx \ | |
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body \ | |
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy \ | |
--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-http_v2_module \ | |
--with-ipv6 \ | |
--with-http_ssl_module \ | |
--with-http_realip_module \ | |
--with-http_addition_module \ | |
--with-http_xslt_module \ | |
--with-http_image_filter_module \ | |
--with-http_geoip_module \ | |
--with-http_sub_module \ | |
--with-http_dav_module \ | |
--with-http_flv_module \ | |
--with-http_mp4_module \ | |
--with-http_gzip_static_module \ | |
--with-http_random_index_module \ | |
--with-http_secure_link_module \ | |
--with-http_degradation_module \ | |
--with-http_stub_status_module \ | |
--with-http_perl_module \ | |
--with-http_gunzip_module \ | |
--with-http_auth_request_module \ | |
--with-mail \ | |
--with-mail_ssl_module \ | |
--add-module=/usr/local/src/nginx/modules/ngx_small_light \ | |
--add-module=/usr/local/src/nginx/modules/ngx_dynamic_upstream \ |
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
[Unit] | |
Description=A high performance web server and a reverse proxy server | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/run/nginx.pid | |
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' | |
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' | |
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload | |
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid | |
TimeoutStopSec=5 | |
KillMode=mixed | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment