Skip to content

Instantly share code, notes, and snippets.

@risyasin
risyasin / node-ubuntu-upstart-service.md
Created March 6, 2016 22:50 — forked from willrstern/node-ubuntu-upstart-service.md
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@risyasin
risyasin / BIND9-dynamic-update-rfc-2316.md
Last active March 2, 2016 15:16
BIND9 Dynamic update via key with remote ipupdate (RFC 2316)

BIND9

d=/etc/bind/mykeys; mkdir -p $d; cd $d

dnssec-keygen -a hmac-md5 -b 128 -n HOST sub.mydomain.com

cat K*.private | awk '$1 ~ /^ *Key/' | cut -d ' ' -f2-

Copy key (it's base64 encoded 128bit hmac-md5) so should end with an "="

nano /etc/bind/named.conf.options

@risyasin
risyasin / apache2-fcgid-php56.fcgi
Last active March 2, 2016 15:17
Apache2 php5.6 fcgid
#!/bin/bash
PHPRC=/opt/local/php56/etc
export PHPRC
umask 022
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=99999
export PHP_FCGI_MAX_REQUESTS
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /opt/local/php56/bin/php-cgi
@risyasin
risyasin / apache2-ext-filter-watermark.md
Last active March 2, 2016 15:15
Apache2 mod_ext_filter watermark

Install imagick first!

sudo apt-get install imagick

Enable Apache2 mod_ext_filter

sudo a2enmod ext_filter

Check it:

@risyasin
risyasin / 1-systemd-nodejs-app-service.md
Last active March 2, 2016 15:21
Systemd service for Node.js app

Copy this myapp.service file under /etc/systemd/system

Enable service (starts at boot time) systemctl enable myapp.service

Start service immediately systemctl start myapp.service

Display logs of service (stdout) journalctl -u myapp.service

@risyasin
risyasin / install-nodejs.sh
Last active February 11, 2016 22:03
Ubuntu Server install Node.js proper way
#!/usr/bin/env bash
NODEJS_VERSION=5.6.0
# aria2 is a really nice tool. promise, you won't regret
apt-get install -y aria2
echo "Installing Node.js v${NODEJS_VERSION} to /opt/nodejs"
cd /opt/
## cleanup
#!/usr/bin/env bash
set -e
SRC_ROOT=/usr/src
NSRC_ROOT=/usr/src/nginx
NPS_VERSION=1.13.35.1
NGINX_VERSION=1.12.2
NODEJS_VERSION=8.9.4
## not installing now, uncomment webmin install below
@risyasin
risyasin / ubuntu-php7-install.sh
Last active January 30, 2016 00:20
PHP7 on Ubuntu 15.04 and 15.10 with php-fpm systemd
# mkdir /usr/src/php7
# cd /usr/src/php7
# aria2c https://gist.githubusercontent.com/risyasin/8b42849ff4b5786292d3/raw/eae0e67737bcb2f4eed6d72c24a6d560dd7161de/ubuntu-php7-install.sh
## php7 compile requirements
apt-get install -y git build-essential autoconf automake pkg-config libtool
apt-get install -y re2c
apt-get install -y bison
apt-get install -y openssl
apt-get install -y libssl-dev
@risyasin
risyasin / Makefile
Created January 12, 2016 12:33 — forked from kvz/Makefile
The only Makefile for Node.js projects you'll ever need - https://twitter.com/kvz/status/685853830425231361
# Licensed under MIT.
# Copyright (2016) by Kevin van Zonneveld https://twitter.com/kvz
#
# This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
# It functions as a wrapper around the actual listed in `package.json`
# So instead of typing:
#
# $ npm script build:assets
#
# you could just as well type:
@risyasin
risyasin / nginx.service
Created January 2, 2016 21:21
Nginx service for systemd
[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=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID