Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

How to create a VPN connection from (L)ubuntu to your work computer

If you want to connect to a Windows VPN connection from a Ubuntu/Debian/Lubuntu client, create a new VPN connection and use the following options:
  1. Check the box "Use point-to-point MPPE"
  2. Disable eap
  3. Always ask password

How-to: Setup apache for a multi user shared hosting environment

Basic setup of a multi user hosting environment on Ubuntu or Debian.

This is a very simple, minimal and safe setup which allows users to have their own web sites hosted in a central web server. The main advantage of this method is that it is very secure.

The main features of this setup are the following:
  • Each user has his own home directory
  • Each user can have one or more websites hosted
  • Web server does not need extra configuration regarding users, groups etc.
  • Users are owners of their website(s) and can connect and modify their sites at will.
  • Users can only view the web directories that they own.
  • Simple and fast setup

Step-by-step installation of Lubuntu 12.04 on a new SSD/hard disk

How-to and troubleshooting installation of Lubuntu from USB

For some reason I cannot understand, when installing Lubuntu from a USB on a brand new unformatted disk, either SSD or normal hard disk, the boot loader (grub2) will be installed on USB instead of the hard disk/SSD. Of course this is a problem, since you will always have to plug-in the same USB in order to boot your system!

How-to: Execute any linux script using mail

The following guide will show you how to execute a php or any other command line program by sending mail to a specific mail address.

This can be used for many applications. For example say that we want to create a new trouble ticket to our organisation's central ticket/issue management system.

The first step is to create and test the script.
<?php
/*
 * newticket.php
 */
error_reporting(E_ALL);

$user="root";
$password="XXX";
$database="tests";

echo "Connecting...\n";

mysql_connect("localhost",$user,$password);
mysql_select_db($database) or die( "Unable to select database");
$dt = date("F j, Y, g:i a s");
$query="insert ticket (description) values (\"$dt\")";
mysql_query($query) or die(mysql_error());
mysql_close();
?>

This scripts assumes that you have the table ticket created in a mysql database called tests:
CREATE TABLE IF NOT EXISTS `ticket` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `description` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
)

If you place it for example in /var/www then you can test the php script from the command line using:
php -q /var/www/newticket.php

If everything is OK, this script will insert one row in table ticket with its field description set as the current datetime.

Now, if you don't already have one, you need to install a mail server. In this example I used postfix. So for debian/ubuntu just type:
sudo aptitude install postfix

Postfix doesn't allow by default mail aliases to execute commands. In order to enable this you have to configure postfix for this by adding the following lines of the file main.cf which is located at /etc/postfix. Edit the file with:
sudo vi /etc/postfix/main.cf

And then add the attributes allow_mail_to_commands and allow_mail_to_files:
allow_mail_to_commands = alias,forward,include
allow_mail_to_files = alias,forward,include

Then we need to edit the /etc/aliases in order to add the mail alias that will execute the script we just created:

# See man 5 aliases for format
postmaster:    root
newticket: "| php -q /var/www/newticket.php" 

Now we have to refresh the aliases used by sendmail by executing the command (rebuilds the data base for the mail aliases file.
sudo newaliases

Finally test the alias just created by running the sendmail like this:
user@host:/var/www$ sendmail newticket
.

Don't forget the "." which marks the end of the message body and tells sendmail to actually send the mail.
Now check your database. If everything went fine, you should have a new row inserted in your ticket table.
If not, then you have to do some troubleshooting by running the mailq program to check your mail queue.