Community Blogs

WebServices Wars: Creating a basic webservice using Eclipse, php and apache

Here I am,
That's a lot of time since my last blog, well, I was quite busy with something else (still have my private life ok ?) but now I'm back again with WebServices, PHP, Eclipse, Apache.

A lot of folks are asking me about some sort of short howto/sample/easy doc for dealing with webservices and php, there's a lot of information spread all around the web so I've decided to collect information from my projects and write down some notes for a quickstart howto with webservices and php.

Now if you like to write down everything from scratch you can surely do but if you're working on a big project you're surely already using an IDE of some sort.

I've tried a lot of different commercial and open source IDEs and after a lot of evaluation I've choosen Eclipse because it's mature, stable (quite), reliable, studied for big enterprise class projects ...and I've a fast and huge pc with a ton of ram on it.

Eclipse is reliable, well known and supported, one of its major drawbacks are about system resources, it eats a lot of ram but if you've a recently updated PC with a good linux distro and a good amount of ram you can surely use it and you'll never go away from it. PHP folks will surely install PDT ( PHP Development Toos Project for Eclipse, it's now a mature plugin for eclipse, reliable and suited for php professional development.

I don't wanna bother you about details on configuring eclipse/pdt/apache/php and so on (maybe another blog argument ?) I'll assume you've this configuration :

  • Eclipse and PDT up and running in your workstation, don't care about operating system but of course if you're using linux it's better :-) (gentoo linux like me even better). But I really don't care, just need Eclipse up and running
  • Web Tools Platform plugin for Eclipse, not really required but useful, it provides: web page editor inside Eclipse, WSDL editor, HTML Validators. WSDL editor is very important if you wish to create webservices with a GUI interface, if you're mastering xml/soap/rpc files and you want to write them on your own you're free to do this.
  • A webserver with php extension installed, Apache2 and PHP5 are used in this sample but every webserver suitable for php is good (here again, apache2 and php5 are better than everything else)
  • Common PHP knowledge and some Object Oriented programming skills, here used for these samples
  • Basic SOAP and WebServices knowledge, at least you need to know what they can do and what is this technology for, later you'll better understand soap after reading samples

This blog is just an intro and a "bill list of materials" before getting started


This is an intro, next article will be the first "hands on" with eclipse and WSDL creation
As usual feel free to ask and write down some comments when needed, hope it helps

Next, featuring: Episode 1: WebServices Wars: "The Phantom Menace": Creating the WebService WSDL file

Andrea Benini (Ben)



8 Ways to Fix Slow Email (Part 1)

Email Server Distance MapIn two earlier articles, we discussed ways to make your website load faster. Another issue many users face is the sometimes painfully slow speed of email. "What do you mean, you haven't gotten it yet? I sent that email over an hour ago?" Does this sound familiar? There are several steps that must take place between your hitting the "send" button and the recipient viewing your message. A delay in your email's journey can occur at one or more of these steps.

Part 1 of this article will address ways to optimize the speed of your network connection, in addition to the website-specific tips we focused upon in "9 Tips to Make Your Website Load Much Faster." These suggestions may increase the speed at which you can send and receive email, as well as improving the performance of your web pages and other file transfers.

1. Problem: Delays caused by the distance between you and your web server.

Solution: As with your website, you can remove one potential cause of slow email by selecting a web hosting provider that has a data center near you. This is the single most important thing you can do to increase your email speed.

While you can't control how long it will take your email to reach your recipient once it leaves your email server, or how long a message from another person will take to reach your email server, you can minimize the time it takes incoming emails to get from your server to your mailbox, and vice versa for outgoing emails.

For example, let's say Tony Traceroute, an employee in your Newark office, wants to send a large file - a CAD diagram of his new widget design - by intraoffice email to Patty Ping, who works just down the hall from Tony. If your company's server is located in Los Angeles, then when Tony hits the send button, his email will travel all the way to sunny California, through whatever routers and packet switches it encounters along the way, then all the way back to Delaware - an odyssey of some 5,000 miles - before it arrives in Patty's inbox! It might have been faster if Tony had just printed out the diagram and walked down the hall to drop it off!

The bottom line: if you rely heavily on email in your business, choosing a web hosting company with a nearby data center may save you a considerable amount of time and money.

2. Problem: Overuse of server capacity on shared servers. Every user on a shared server is allocated a certain amount of bandwidth and other server resources. When a user goes over this limit, it can slow down the other accounts on the server.

Solution: Make sure your web hosting company has policies in place to manage excessive usage by individual clients on its shared servers. Some hosting providers automatically suspend accounts that use excessive resources. While this works, the best way for a web hosting company to handle these accounts is to migrate them to a separate server where they can't negatively impact the performance of other shared accounts. If you're on a shared server, ask your web hosting company how they handle such accounts.

In addition, talk to your web hosting company to make sure that they aggressively combat spammers and other system abusers who are likely to consume system resources and slow down your website and email.

Rerouting Data3. Problem: Your email may encounter a bottleneck if there is an issue with the bandwidth provider that your web hosting company uses. Most large web hosting companies have partnerships with multiple major bandwidth providers to ensure this does not happen. Smaller hosts may not be able to afford these partnerships, leaving you susceptible to a slowdown.

Solution: Find out what types of ISP partnerships your web hosting company has. You can run a simple trace route test to see what partnerships your hosting company has with bandwidth providers. Look for major communications companies (Tier 1 or highly reputable Tier 2 providers) such as MCI-Verizon, AT&T, Mzima, Level(3), Global Crossing, etc.

Ideally, your web hosting company should have a variety of bandwidth partners. That way, your web host will be able to reroute email data quickly if one of the bandwidth providers goes down. If your web host does not have major partnerships, it may be in your best interest to look for a web hosting company that does.

Speedtest Results4. Problem: Connection problem on your end - If you're using "home-grade" equipment, and you think your connection may be slow, try running a speed test at a site such as Sometimes modems and routers will go out of sync after being powered on for weeks or months at a time. This is especially true if you are using a modem and wireless router combination.

Solution: Try refreshing your connection. Simply power down both your modem and your router. Then turn the modem back on, wait a few minutes, and turn the router on (the order of these steps is very important).

If this doesn't increase your connection speed, notify your cable or DSL provider. They will test your connection speed, and they may be able to optimize your connection from their operations center.


• Be sure that you are located as close as possible to your web hosting company's data center.
• Ask your provider about their excess usage policies if you are hosted on a shared server.
• Make sure your web host has partnerships with the top bandwidth providers.
• Conduct basic tests with your internet provider and on your own home router/wireless setup.


Part 2 of this article will focus on optimization techniques that are specific to email. We'll look at issues that can slow email such as spam, misconfigured spam filters, bloated emails, and reverse DNS lookup - and what you can do to address these problems.


Qwiki : Order IP Addresses in MySQL

Recently I came across unexpected results when trying to order a table by stored IP Addresses.

mysql> select ip from table order by ip desc;

The results looked like this:


| | | | | | | | | | ...

| | | | | | | | | | ...

Here's the quick fix ...

Read more... Comment (0)

Disable/Enable ping response on a Linux machine

Few days ago I was dealing with SYSCTL (man sysctl) utility and I was looking for a certain kernel parameter, I wish to set it on the fly and I've found other useful information too.

sysctl is used to modify kernel parameters at runtime, one of these parameter could be ping daemon response, if you want to disable ping reply on your network you just simply need to issue something like:

~# sysctl -w net.ipv4.icmp_echo_ignore_all=1
net.ipv4.icmp_echo_ignore_all = 1
(root access required)

Now try to ping your machine, no replies at all, look nice isn't it ?
To  re-enable ping reply just issue:

~# sysctl -w net.ipv4.icmp_echo_ignore_all=0
net.ipv4.icmp_echo_ignore_all = 0
(root access required)

-w flag is used if you want to change some settings, take a look at kernel flags you can set at runtime (linux sources)



File transfer with Netcat

There's a basic usage for netcat helping you to transfer data/files across hosts without ssh or ftp services

Here's what I usually do on server (example IP:

nc -l -p 6666 | uncompress -c | tar xvfp -

Basically I open TCP port 6666 (or whatever you want) on server and listen for raw compressed data


On my client I need to issue a command like this

tar cpf - /my/cool/dir | compress -c | nc -w 3 6666

Where /my/cool/dir is what I want to transfer, is the destination host (server) and 6666 is the previously opened TCP port; you can even set a timeout (in seconds) for connection, suggested if you're in a busy network


Data on this stream are compressed so faster downloads are possible, this kind of trick is useful when you need to transfer data on the fly or when you don't have ssh shell host, scp or ftp server; I use it heavily expecially on embedded devices or dumb machines


Hope it helps


Andrea Ben Benini


Shared Samba Printer for PDF/PS Storage

As many of you already know I'm experiencing some sort of hylafax/samba integration for a mixed Windows environment, this blog is for creating a PDF/PostScript printer easily, no matter of what you do with the printer; when you print on it you'll produce a Postscript/PDF document

A samba server installation up and running

Create a PostScript/PDF document from a spool so every Windows user in your net can generate documents without client side software installation (Exception for the windows printer driver)

If you want to create your PDF files and customize them each time (custom passwd protection, comments, tags) you'd probably use PDFCreator, it has a windows installation and a lot of funny options to deal with. If you're searching for a dumb massive pdf generation for average windows users (lazy users without knowledge and time) you'd better stay here to see my config.

I'm using it for a Windows network where users just need to use a document management and storage system, they simply want to archive files on storage array in PDF format, no matter for file input (DOC, XLS, EMails, ...). This is particularly useful in big environments and when input file may vary, here's a nice Windows spooler usage

After installing samba and integrating it in your network (Workgroup, Domain, Active Directory, ... need some help or need a new blog for it ?) just add a section to your /etc/samba/smb.conf (or wherever your samba config file is) like this one:

# for windows clients
comment = my cool samba printer
public = yes
print command = ( ps2pdf "%s" "/my/storage/dir/`date +"%Y-%m-%d.%H-%M.pdf"`" > /dev/null; rm "%s" ) &
printable = yes
writable = no
path = /var/spool/samba
use client driver = yes

This config was taken from a running server, exception for the print command line, in my case I've a custom script making other things, in this sample when a file is received it will be converted from PS (input) to PDF (output) and temp PS file is then deleted.

PDF in the example will have this name /my/storage/dir/YYYY-MM-DD.HH-MM.pdf
change it to whatever you want


Now the big question is: what should I have to install on the windows side ?
Here's the easiest part of the trick.
Install a "Apple LaserWriter 12-640 PS" printer, common alternatives are:
"Apple LaserWriter 12-600 PS"
"HP Laserjet 4/4M PS"

I strongly suggest you to install Apple Laserwriter printer family, these are already supported and driver already available in Windows XP, You don't even need to supply Windows install CD

Vista users may choose HP Laserjet (no cd required, already installed), Laserwriter drivers are not there

These printers are PostScript printers so each file you send to them will be translated to postscript language (thanks to Windows Printer Spooler).


I use this system to store files in a common and unique format (PDF) in a mixed environments when different types of files exists and problems are raised when you only need to read a simple document

Hope it helps
Glad to read your comments


Andrea Ben Benini


Find a string in files (using grep easily)

Here's a quick command for a quite common problem:

Is there a way to find a text string inside a bunch of files in a dir ?

Sure it is, here's one :

grep 'MyCoolString' /my/preferred/directory/*

Searches "MyCoolString" inside the specified path and willcard, or if you prefer to ignore case take a look at:

grep -i 'mycoolstring' /my/preferred/directory/*

Easy isn't it ?

Obviously this is not the only method but it's my preferred one, easy syntax, easy to remember, glad to see your comments or alternative methods for this task

Hope it helps




Xen VM migration on SLES 10

This how-to describes the process for migrating a SLES Xen virtual machine from one physical host to another. In this scenario, the new VM will be hosted on shared storage mounted via NFS. This scenario may also work for Physical to Virtual (P2V) migration.


1. Shut down source vm on Dom0, mount the hard drives.

xm shutdown vm1

# list the drives to find which one is the root

fdisk -l /dev/sda

# Gain access to the old virtual hard drive: create the mapping under /dev/mapper

kpartx -a /dev/sda3
mount -o loop /dev/mapper/sda3p2 /mnt/temp

2. Create a new hard drive image file (60GB) on the new location using dd:

dd if=/dev/zero of=/mnt/vm2/disk0-new.img bs=1M count=1 seek=60000

# Make the file system
/sbin/mkreiserfs -q -f disk0-new.img

# Make the swapfile
dd if=/dev/zero of=/var/lib/xen/images/vm2/vm2-8g.swap bs=1k count=8392930

mkswap vm2-8g.swap # it is large because of oracle reqs

# Mount the new filesystem

mount -o loop /mnt/vm2/disk0-new.img /mnt/img

3. Create new virtual machine minimal install with SLES 10 SP2 on new Xen host, pointing to new hard drive files. Use Yast's "Create a Virtual Machine."

4. rsync the file system from /dev/mapper/sda3p2 to /mnt/img

### exclude_file.txt

$ rsync -rlpogt --progress --exclude-from="exclude_file.txt" /dev/mapper/sda3p2/ /mnt/img/

5. Correct entries in files in the newly replaced /etc for the new vm configuration: /etc/fstab (now /dev/xvda1 instead of hda2 for /, /dev/xvdb1 for swap instead of hda1), /etc/passwd, /etc/group, /etc/sysconfig/network/ifcfg_eth..  Kept the new vm's mac address and updated the IP for vm2 in the config file /etc/xen/vm/vm2.

6. Start up the new virtual machine. Don't forget to do an 'xm delete vm1' on the old system once you are sure it is no longer needed.

Hylafax, send a fax from the command line

In these days I'm stressing hylafax a lot, I think it's a nice and powerful program, stable, complete and reliable. When my job will be completed I'll publish some thoughts about it.

Server part is so stable and secure, client part, expecially for Windows clients have some lacks, there're a lot of win client all around but every software I've tried has some lacks so as a lot of you I've decided to write my own.

Few of them have everything I need, except the license and price, I mean I think it's right to charge for your work but while talking about an high ranking opensource software I was thinking it has good opensource clients as well.

No matter I'm deploying a base installation with a lot of different clients so I think I'll buy some commercial clients suitable for my needs (I was really impressed about HylaFSP client) but by the way I think I'll deploy even few clients maded by me, I'm in an Active Directory network and few considerations and limitations about existing open source clients made me take the decision of writing some clients on my own.

Now let's start with the basics, you've started reading this article for getting information about sending faxes from command line, don't you ?

While deploying my new client I've read about how to send something from command line, this solution will be integrated in my new client. First you need to install command line hylafax-client, check out your favorite distro, most of them have a package called "hylafax-client" (Gentoo, Debian based and others), if don't have it take a log at a command called sendfax, your distro should have it somewhere.

here's the command:

sendfax -f " This e-mail address is being protected from spambots. You need JavaScript enabled to view it " -R -r "Fax Subject" -c "Coverpage comments" -x "Your recipient" -d "Recipient@1234567890"

First you need to create your example document in PostScript format, if you've installed hylafax you'll have ps2xx utilities (ps2pdf, ps2ascii, ps2txt, pdf2ps, ...), use them to convert from your current format to Postscript if you don't have a PS ready document (dummy example: pdf2ps input.pdf

then modify parameters according to your email address if you want to receive notification about the job status (failed, success), fax subject, coverpage comments if you've it and so on, obviously change 1234567890 with your destination fax number.

Pretty easy, isn't it ?

That's why I'm writing my own windows and linux wrapper, backend sendfax program is so easy to use so I just need few changes for adapting my AD integration


Let me know your thoughts




ssh, scp without password to remote host (Look Ma, no Password !)

Here I'm, back again on SSH stuff, as you can see from my previous posts (search blogger name = "ben") OpenSSL and SSH stuff is very interesting and useful for me, so I wrote down a lot of notes on them, this time I'll show you how to connect to an SSH host without password input.

Yeah, I know, there're a lot of folks all around explaining you how to do that but I promise to make it easy 'n' dirty, without hassling you too much, just the basic steps for connecting to your remote host and make it working.

What would you do with this tutorial ? for example:

  • you can ssh to your remote host without requiring a password, this is safe and secure (it uses SSH public/private keys) until you keep your private keys for yourself. A quite recurring task if you've a lot of machines to manage
  • Copy files from an host to another, not only as utility but even for basic administration task, if you manage a network you know what I mean
  • Grant someone access to certain hosts for his job (be careful ok ?)
  • Use all the other SSL suite across hosts, this is not only for ssh or scp, all SSL suite is involved, look at my articles on SSH port forwarding for example, there are a lot of them (blogger: ben)
  • Impress your boss or whatever you'd like

Ok, let's get started

Let's assume you've two hosts:
mylocal - the host from where you want to connect
myremote - the host where you want to connect to


1) From mylocal create an ssh rsa key pair for host validation, here's how: 

mylocal:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx user@mylocal
The key's randomart image is:
+--[ RSA 2048]----+

2) Now you need to copy the public key to your remote host, do NOT copy the private key, obviously use scp to do this

mylocal:~# scp ~/.ssh/ myremote:~
Password: 100% 391 0.4KB/s 00:00

so now you've your public key copied fine, let's connect to remote host now


3) Connect to your remote machine (myremote)

mylocal:~# ssh root@myremote (root or your remote username)
Last login: Wed May xx xx:xx:xx xxxx 2009 from mylocal on ssh
myremote ~ #

4) Check out .ssh stuff, if .ssh dir doesn't exist you need to create it

myremote ~ # ls -la ~/.ssh
ls: cannot access /root/.ssh: No such file or directory
If you get something like this you need to create the dir, so:
myremote ~ # mkdir .ssh
myremote ~ # chmod 700 .ssh

5) Now copy your ssh public key into authorized keys file and delete it when finished, so:

myremote ~ # cat ~/ >> .ssh/authorized_keys
myremote ~ # chmod 600 .ssh/authorized_keys
myremote ~ # rm
NOTE: If you've a Debian remote host you MUST use this instead:
myremote ~ # cat ~/ >> .ssh/authorized_keys2
myremote ~ # chmod 600 .ssh/authorized_keys2
myremote ~ # rm
First row is used for all major distros (Gentoo in my real example), Debian users must use the second one, check your ssh man page for details on your setup (first is the most common case)

Ok let's go back to our local host and try to make something to see what happens:

mylocal:~# scp example.file root@myremote:/tmp/
example.file 100% 169 0.2KB/s 00:00
mylocal:~# ssh root@myremote
Last login: Wed May xx xx:xx:xx xxxx 2009 from mylocal on ssh
myremote ~ # ls -la /tmp/example.file
total 1
-rwxr-xr-x 1 root root 169 May xx xx:xx example.file
Did you see it ? I'll hope so.
As you can see you can copy or connect to host without supplying passwds

Note (read)

Sometimes additional configurations are requested on remote ssh daemon, this may vary from your distro setup and basic security configuration, if final test failed you'll probably have PublicAuthentication or RSA disabled.
In this case you need to change them, don't worry it doesn't affect or lower your current security, tipically this change is done by editing /etc/ssh/sshd_config file, you need root access for it.
sshd_config path may vary between different distro even it's the most common name

To get the correct configuration, see that the following attributes are set (not commented or set to "no") in your sshd_config file

RSAAuthentication    yes
PubkeyAuthentication yes

If you change sshd_config file with these values you need to restart ssh daemon (something like: /etc/init.d/sshd restart)


Hope it helps someone
Let me know if you need help or further suggestions
Andrea Benini Ben



I still say: I love the Suse linux enterprise server software. It is easy to use and has a great integration with Wind##s server product. So till the moment where we can enjoy a 100% Linux enviroment an excellent choice.
Page 8 of 10

Upcoming Linux Foundation Courses

  1. LFD312 Developing Applications For Linux
    05 Jan » 09 Jan - Virtual
  2. LFS220 Linux System Administration
    05 Jan » 08 Jan - Virtual
  3. LFD331 Developing Linux Device Drivers
    12 Jan » 16 Jan - Virtual

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board