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
    </Directory>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php5-fpm.sock.example|fcgi://localhost"
    </FilesMatch>
</VirtualHost>"
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
pool="[example]
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:

1
2
3
4
5
6
7
8
9
10
11
12
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3100);
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
  process.exit();
});
% 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 http://127.0.0.1:4466/debug?port=5858 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.
http://www.sitepoint.com/enter-world-node-js/

Installing the latest NodeJS & MongoDB Combo

NodeJS

Requirements

These are needed for building and running.

sudo apt-get install build-essential python

Install

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager.

OR

Build & Install

download the latest NodeJS source code.

wget -N http://nodejs.org/dist/node-latest.tar.gz

Decompress and enter the directory.

tar -xvzf node-latest.tar.gz
cd node-v*

Configure the make file for my machine then build and install as a root user.

./configure
make
sudo make install

Test to make sure it was installed.

node -v
npm version

MongoDB

I should follow the instructions on the official MongoDB manual.

MongoDB Driver

see: http://docs.mongodb.org/ecosystem/drivers/.

« Older Entries