20th, March 2015: Solar Eclipse Experiment :)


camera obscura

Colleague and me we instantly built a camera obscura experiment for the Solar Eclipse 2015.

Install latest Apache 2.4.X with PHP-FPM on Ubuntu 14.04

Here I go with the latest apache 2.4.10 and PHP-FPM through mod_proxy_fcgi apache module. The following steps provide unix socket connection and allow reverse-proxy to be set via explicit handler.

# personally basic stuff
locale-gen de_DE.UTF-8
apt-get install -y build-essential curl libmcrypt4 mc nano htop
wget -nv -O /root/.bash_aliases https://raw.githubusercontent.com/joergpatz/vagrantbox/master/bash_aliases
# Install Apache packages from a PPA by Ondřej Surý's.
add-apt-repository -y ppa:ondrej/apache2
apt-get update
apt-get -y install apache2
# Apache settings
a2enmod rewrite
a2dissite 000-default
# virtual host example.com.conf
vhost="<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    <Directory \"/var/www/example.com\">
        Options FollowSymLinks MultiViews
        Order allow,deny
        Allow from all
        Require all granted
        AllowOverride None
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php5-fpm.sock.example|fcgi://localhost"
echo "$vhost" | tee /etc/apache2/sites-available/example.com.conf
# Install PHP
apt-get install php5 php5-fpm php5-cli php5-gd php5-intl php5-curl php5-mcrypt php5-pear
php5enmod mcrypt
# fpm pool example.conf
chdir = /
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock.example
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 100
;pm = dynamic
;pm.max_children = 5
;pm.start_servers = 2
;pm.min_spare_servers = 1
;pm.max_spare_servers = 3"
echo "$pool" | tee /etc/php5/fpm/pool.d/example.conf
# enable Apache mod_proxy and vhost
a2enmod -m proxy_fcgi
a2dismod autoindex
a2ensite example.com
# restart
service php5-fpm restart
service apache2 restart

Enter the World of Node.js

My very very first goal was to write a simple web server that responds with “Hello World” for every request.

So I create a javascript file named app.js:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
console.log('Server running on port 3100.');
process.on('SIGINT', function() {
  console.log("\nGracefully shutting down from SIGINT (Ctrl-C)");
  // some other closing procedures go here
% node app.js

Debugging from Vagrant

with a pleasant graphical interface: Node Inspector (“npm install -g node-inspector”) is a debugger interface for node.js using the WebKit Developer Tools.

For debugging from host machine I have to setup port forwarding in the Vagrantfile, e.g. port 4466:

config.vm.network "forwarded_port", guest: 4466, host: 4466 # node-inspector

Then spin up the vagrant box and ssh to it:

% vagrant up
% vagrant ssh

cd to the project dir and start the node-inspector

% node-inspector --web-port 4466

The above command return the following: “Visit to start debugging.”

Start the node application with the debug flag in a new terminal window.

% node --debug app.js

Ready to debug via the V8 JavaScript Engine which is used in the Chrome and Chromium browsers.

A better-written article can be found on sitepoint.

« Older Entries