Programming in PHP for command line

By Bogdan Tkachenko on February 6, 2011


Ubuntu provides utilities for virtual hosts and modules switch-in\switch-off with apache2 packet. Anyway creating configs for virtual hosts takes additional time. I wanted to improve this shortcoming. I could of course create automatical sub-domains for Apache but I decided to write a script that creates configs of virtual hosts for Apache, and when necessary, it adds the host name into the /etc/hosts file. I’m not very strong in writing scripts in bash, so I decided to use PHP (that I know quite well) for my simple task. This article offers you two interesting things: we will learn the in\output operations for command line in PHP, and write a script that will little bit ease our life.

  • Pages:
  • 1