PHP / Perl / Rb / Py

Useful articles based on languages like PHP, Perl, Ruby or Python.


Testing if a server port is actually open

There are actually a whole lot of possibilities to do that, the most simple one probably to use a simple telnet: telnet example.net 80 Or the good old nmap: nmap -sS -O -p80 example.net In a Bash script you can simple do it this way: #!/bin/bash test=$(nc -z -v -w1 example.net 80 2>&1) if [[ $test == Connection*succeeded* […]


Installing PHP7-FPM with Apache2 Worker on Ubuntu

First add some prerequesites and add the PHP7 repository: apt-get update apt-get install software-properties-common python-software-properties LC_ALL=en_US.UTF-8  add-apt-repository ppa:ondrej/php-7.0 Then install the actual PHP packages (remove those form the list that you do not need): apt-get install php7.0-fpm php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-mysql php7.0-phpdbg php7.0-dbg php7.0-gd php7.0-imap php7.0-ldap php7.0-pgsql php7.0-pspell php7.0-recode php7.0-snmp php7.0-tidy php7.0-dev php7.0-intl php7.0-gd php7.0-curl Then […]


Install PHP 5.6 on Debian Wheezy

To install PHP 5.6 on Wheezy, you can add this repo: echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list Add the key: wget http://www.dotdeb.org/dotdeb.gpg -O- |apt-key add – And install PHP: apt-get update apt-get install php5-cli php5-fpm ….. (or whatever package you might need)  


Install PHP 5.5 on Debian Wheezy

To install PHP 5.5 on Wheezy, you can add this repo: echo "deb http://packages.dotdeb.org wheezy-php55 all" >> /etc/apt/sources.list.d/dotdeb.list echo "deb-src http://packages.dotdeb.org wheezy-php55 all" >> /etc/apt/sources.list.d/dotdeb.list Add the key: wget http://www.dotdeb.org/dotdeb.gpg -O- |apt-key add – And install PHP: apt-get update apt-get install php5-cli php5-fpm ….. (or whatever package you might need)  


Using Memcached with Perl

First of all, install the Memcached for Perl: perl -MCPAN -e shell install Cache::Memcached Here is an example script: #!/usr/bin/perl use Cache::Memcached; my $cache =  new Cache::Memcached {     'servers' => [‘127.0.0.1:11211’],  }; # Save (set) something in your cache: $cache->set("test", "test123"); # Get the value from Memcached my $value = $cache->get("test");   


Invalid byte sequence in US-ASCII when installing Ruby Bundler

You can fix the error by installing locales-all, on Debian by doing: apt-get install locales-all And then adding this to your GemFile: if RUBY_VERSION =~ /1.9/ Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 end You might also want to try to export the variables: export LANG="en_US.UTF-8" export LC_ALL="en_US.UTF-8" Either one of the 2 solutions will solve […]


Installing Ruby 1.9.3 on Debian using RVM

First of all, check if there's a Ruby package installed on your Debian and remove it, as it may conflict later on: apt-get remove ruby ruby1.8  Now some prerequesites for Debian: apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion locales-all […]


Installing Ruby 1.9.3 on Debian Squeeze

This is a quick way to install Ruby 1.9.3 on Debian. The default version on Squeeze is 1.9.1, but on depending on what you would like to do, you may need a more recent version. Download the dsc file: wget http://deb.bearstech.com/squeeze/ruby-1.9.3/ruby1.9.1_1.9.3.0-1.dsc Download the following archives: wget http://deb.bearstech.com/squeeze/ruby-1.9.3/ruby1.9.1_1.9.3.0.orig.tar.gz wget http://deb.bearstech.com/squeeze/ruby-1.9.3/ruby1.9.1_1.9.3.0-1.debian.tar.gz For the package to be built, […]