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 80 Or the good old nmap: nmap -sS -O -p80   In a Bash script you can simple do it this way: #!/bin/bash test=$(nc -z -v -w1 80 2>&1) if [[ $test == […]

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 wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list echo "deb-src wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list Add the key: wget -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 wheezy-php55 all" >> /etc/apt/sources.list.d/dotdeb.list echo "deb-src wheezy-php55 all" >> /etc/apt/sources.list.d/dotdeb.list Add the key: wget -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' => [‘’],  }; # 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 Nginx with PHP5-FPM on Debian

Install PHP5-FPM as described here. Install Nginx: apt-get install nginx Check for the correct path to the socket used by php5-fpm in /etc/php5/fpm/pool.d/www.conf (to be used in the nginx configuration): listen = /var/run/php5-fpm.sock Create a virtual host in /etc/nginx/sites-available/: server { listen 80; root /var/www; index index.php index.html index.htm; server_name YOUR_SERVER_NAME; location / { try_files $uri $uri/ […]

Installing php5-fpm on Debian

First of all, we get the server key: cd /tmp wget cat dotdeb.gpg | apt-key add – Then add the repository: echo "deb wheezy all" >> /etc/apt/sources.list echo "deb-src wheezy all" >> /etc/apt/sources.list Change wheezy to the current debian release name Then install php5-fpm: apt-get update apt-get install php5 php5-fpm php-pear php5-common […]