How To Installing Lighttpd With PHP5 And MySQL Support On CentOS

Lighttpd is a secure, fast, standards-compliant web server designed for speed-critical environments. This tutorial shows how you can install Lighttpd on a CentOS 5.0 server with PHP5 support (through FastCGI) and MySQL support.
1 Preliminary Note

In this tutorial I use the hostname with the IP address These settings might differ for you, so you have to replace them where appropriate.

2 Installing MySQL 5.0

First we install MySQL 5.0 like this:

yum install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Create a password for the MySQL user root (replace yourrootsqlpassword with the password you want to use):

mysqladmin -u root password yourrootsqlpassword

Then check with

netstat -tap | grep mysql

on which addresses MySQL is listening. If the output looks like this:

tcp 0 0 localhost.localdo:mysql *:* LISTEN 2713/mysqld

which means MySQL is listening on localhost.localdomain only, then you’re safe with the password you set before. But if the output looks like this:

tcp 0 0 *:mysql *:* LISTEN 2713/mysqld

you should set a MySQL password for your hostname, too, because otherwise anybody can access your database and modify data:

mysqladmin -h -u root password yourrootsqlpassword

3 Installing Lighttpd

Lighttpd is not available from the official CentOS 5.0 repositories, but from the RPMforge repositories (see for instructions). We install the RPMforge package for RHEL 5 which works for CentOS 5.0 as well:

rpm -Uhv

Afterwards, we can install Lighttpd like this:

yum install lighttpd

Then we create the system startup links for Lighttpd (so that Lighttpd starts automatically whenever the system boots) and start it:

chkconfig –levels 235 lighttpd on
/etc/init.d/lighttpd start

Now direct your browser to, and you should see the Lighttpd placeholder page:

Lighttpd’s default document root is /srv/www/lighttpd on CentOS 5.0, and the configuration file is /etc/lighttpd/lighttpd.conf.

4 Installing PHP5

We can make PHP5 work in Lighttpd through FastCGI. Therefore we install the packages lighttpd-fastcgi and php-cli:

yum install lighttpd-fastcgi php-cli

5 Configuring Lighttpd And PHP5

To enable PHP5 in Lighttpd, we must modify two files, /etc/php.ini and /etc/lighttpd/lighttpd.conf. First we open /etc/php.ini and add the line cgi.fix_pathinfo = 1 right at the end of the file:

vi /etc/php.ini
cgi.fix_pathinfo = 1
Then we open /etc/lighttpd/lighttpd.conf and uncomment “mod_fastcgi”, in the server.modules stanza:

vi /etc/lighttpd/lighttpd.conf
server.modules = (
# “mod_rewrite”,
# “mod_redirect”,
# “mod_alias”,
# “mod_cml”,
# “mod_trigger_b4_dl”,
# “mod_auth”,
# “mod_status”,
# “mod_setenv”,
# “mod_proxy”,
# “mod_simple_vhost”,
# “mod_evhost”,
# “mod_userdir”,
# “mod_cgi”,
# “mod_compress”,
# “mod_ssi”,
# “mod_usertrack”,
# “mod_expire”,
# “mod_secdownload”,
# “mod_rrdtool”,
“mod_accesslog” )
and then , further down the file, there’s a fastcgi.server stanza which we uncomment as well – make sure you use /usr/bin/php-cgi instead of /usr/local/bin/php in the “bin-path” line::
#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( “.php” =>
( “localhost” =>
“socket” => “/tmp/php-fastcgi.socket”,
“bin-path” => “/usr/bin/php-cgi”
Then we restart Lighttpd:

/etc/init.d/lighttpd restart
6 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /srv/www/lighttpd. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /srv/www/lighttpd/info.php
Now we call that file in a browser (e.g.

As you see, PHP5 is working, and it’s working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don’t have MySQL support in PHP5 yet.
7 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:
yum search php

Pick the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Now restart Lighttpd:

/etc/init.d/lighttpd restart

Now reload in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module.



Leave a comment

How to Set Up a TFTP Server on Linux

Good post over on the often forgotten TFTP can be a life saver.

Most users are familiar with FTP, but if you want to kickstart Red Hat installs, PXE boot systems, auto-provision VoIP phones or unbrick a Linux-based router, you want aTrivial File Transfer Protocol (TFTP) server. Setting one up on Linux is easy, and a perfect project to take on over the weekend.

TFTP (RFC 1350) is very low-overhead variant of the more familiar FTP that you are probably already used to interacting with. It is optimized for transferring files over a local network to small devices that may not even have permanent storage. In the old days, that originally meant thin clients booting over the network. Today there are still network services that depend on TFTP (most notably the Linux Terminal Server Project and Red Hat’s Kickstart remote-installation system) but it has taken on a second important role in VoIP, as the preferred way to “auto-provision” many IP telephones and analog telephone adapters (ATAs), distributing configuration files at boot time in a manner similar to DHCP. In addition to that, if you accidentally brick your Linux-based router while installing DD-WRT, TFTP may be your only path to restoring it. Fortunately, even though the protocol might not get the same public respect as FTP, Linux supports it just fine.

TFTP uses UDP as its transport protocol, on the reserved port 69. Like FTP, it can be used in either ASCII or binary mode, but unlike FTP it has no directory-listing or navigation features, because it was not primarily designed for interactive client use. Instead, TFTP clients typically boot up and request a specific file. If a listening server has the file, it acknowledges the request and begins transferring it.

This is a very simple process, which is what makes TFTP popular for thin client setups like Preboot eXecution Environment (PXE) and for embedded devices without built-in or USB-attachable storage. But it also includes no authentication step or access control methods, which makes man-in-the-middle attacks a very real security issue when dealing with VoIP deployments that require a support server to be running constantly.

An attacker that compromises the TFTP server can send rogue configuration files that do anything from register phones with different Session Initiation Protocol (SIP) gateways to perform denial-of-service by setting bad configuration parameters. Attacking a PXE system is a little more difficult, since the setup also includes DHCP, but it is certainly possible to upload a bad bootimage to thin clients.

On the other hand, if you just need to unbrick your router or flash a device with new firmware over TFTP, you do not need to run a TFTP server constantly. If you are really paranoid, you can just disconnect the WAN connection during the process. Since the two use cases are so different, the best choice for a static TFTP server probably is not the choice you would want just for an isolated job. We will consider each in turn.

Setting up static TFTP

For administrating a netboot or VoIP deployment, there are two main Linux TFTP server projects to choose from: tftpd-hpa and atftpd. The former is a port of OpenBSD’s TFTP daemon, though the Linux version has diverged over the course of several releases. Atftpd (which stands for Advanced TFTPd) is native to Linux. Both include support for several newer TFTP revision options, such as negotiable transfer block sizes and negotiable time-outs.

Your distribution may package one or the other, or both. If you are faced with a choice, the main differences between the two are in their security features and support for multicast TFTP.

Atftpd provides only host-level security using the libwrap TCP wrapper library. You can add TFTP clients by host name or address to /etc/hosts.allow or use exclusion rules in /etc/hosts.deny. Tftpd-hpa, on the other hand, respects rules in both hosts.allow and hosts.deny, but also implements several other security features. By default, it can only serve files that are publicly readable (i.e., o+r), and will only allow files to be uploaded by clients if the filename in question already exists and is publicly writable. Finally, starting the daemon with the -s option performs a chroot to the TFTP file directory to prevent an attacker from accessing anything else on the server.

Only atftpd, however, supports multicast TFTP, both the version specified in RFC 2090and the slightly-different version that is part of the PXE specification. Thus, if you need to support PXE thin clients, atftpd is the better choice, but for all others, including VoIP provisioning, the added security features of tftpd-hpa are worth having.

Both servers can be started either by inetd or as standalone daemons, and store a configuration file in /etc/default/.

The tftpd-hpa server’s file is /etc/default/tftpd-hpa. By default it includes the line RUN_DAEMON="no", which allows it to be started and managed by inetd. Change this value to “yes” to start the server as a daemon instead. The OPTIONS= line lists a quoted series of run-time configuration flags, the most important of which is -s /path/to/tftp/directory.

Atftpd’s configuration is found in /etc/default/atftpd. By default, it includesUSE_INETD=true to indicate inetd management; change this to false to run atftpd as a daemon. Aftpd requires that you specify the TFTP directory as the final argument, after all of the command-line switches, so you would simply append /var/tftpd to the end of its OPTIONS line.

Next, make sure that you create the TFTP directory you intend to use (say,/var/tftp/), and give it the proper ownership and permissions. Both daemons run as user nobody by default, so run chown -R nobody /var/tftp to set the ownership correctly, and chmod -R 777 /var/tftp to assign the correct permissions. Then, start the daemon: either execute /etc/init.d/atftpd restart or /etc/init.d/tftpd-hpa restart. Both services uses the standard Linux syslog utility, with run-time verbosity control so you can monitor their behavior.

For advanced usage, each of the servers also provides a way to serve alternate contents when it receives a specific file request, based on regular-expression matching and replacement. This can be useful when a device is hard-coded to request a specific firmware image, but you need to flash it with a newer replacement. But the two servers differ in their implementations. Atftpd uses Perl-Compatible Regular Expressions (PCREs), and allows for simple pattern/replacement pairs based on filename. Tftpd-hpa uses POSIX regular expression syntax, which is not as flexible, but it allows file remapping rules to be based on client IP address in addition to matching filenames alone.

The Simpler Case: TFTPing a Single File

If all you need to do is make one file available over TFTP for a short period of time, including restoring the factory firmware to a bricked router or uploading an update to your Cisco IP phone, you do not need to install and configure a full service like either of those discussed above. While it would be nice if Linksys and Cisco provided a simple command-line or GUI TFTP application for these occasions, neither do.

There is at least one robust, painless-to-use standalone TFTP app for Linux, though:tftpgui. Written in Python, tftpgui is meant to run as a user-initiated interactive application. The author documents its use with a variety of Cisco equipment, and it has also been tested with Vonage, Sipura, Linksys, and Grandstream hardware.

Currently, no distributions package tftpgui, so you will need to grab the latest tarball from the project’s downloads page. You can unpack its contents anywhere; it does not need to be compiled and installed to be used. In order to run on the default port of 69, you must launch the GUI as root, so execute sudo python ./ & to get started.

There are four buttons at the top: Start and Stop enable and disable the server, Exit closes the GUI, and Setup allows you to specify configuration rules. You must select a TFTP directory holding the files you need to move, and you can specify a log directory and change the UDP port on which the server listens.

The one security feature tftpgui includes is the ability to restrict incoming TFTP requests to a specific subnet, so if you must run the application in a hostile environment, you can at least try to isolate yourself to a vacant subnet before starting. You can also enter the remote clients IP address and specify a subnet mask of 32, even though purists may call that cheating.

After you apply any configuration settings and press Start in the main window, the main canvas will report any TFTP requests and return codes. You can then restart the remote device and watch its TFTP request hit the server, or if you are attempting to de-brick a router, follow whatever steps the instructions tell you to do.

Tftpgui does not support any of the extended protocol options like filename replacement or multicasting, but if you were stuck without a simple way to serve up a replacement firmware image or provisioning file, it may fit the bill.

In some ways, TFTP is a relic from the 1980s. As embedded devices get smarter and memory gets cheaper, more and more OEM products that used to use TFTP alone as their update mechanism are starting to include embedded HTTP stacks. That certainly makes it easier to troubleshoot, since most Linux boxes have Apache or another web server already installed. Still, when you find yourself trapped with a device that speaks only an unfamiliar protocol, it is reassuring to see that on Linux machines, old RFCs never die.


Leave a comment

How to Access Your Windows PC from Linux

Although the monopoly of the desktop market is still dominated by Microsoft Windows, Linux has long since established itself as the most viable option for server based computing environments. Therefore, most of the network systems nowadays, regardless the number of hosts that are always connected through one or more Linux servers. Due to this multi-infrastructural settings present in network environments, sharing files between Linux machines and Windows powered machines is a common scenario which will be very useful for us to have the know-how.

Samba server is the method using which you can enable a Linux box to share files over a network with a Windows box and vice-versa. Samba provides file and print services to SMB/CIFS clients whom are running on Windows, Linux/ UNIX flavors, Mac OS and a wide variety of operating systems.

Accessing files residing on a Windows PC from Linux can be achieved in two ways.

  • Using SAMBA client via command line
  • Using GUI tools
Access Windows PC from LinuxSoufce: 

Using SAMBA Client via Command Line

In your Windows box, assume you have a central shared folder. Whatever files that would be put into this folder can be shared with any other remote machine Linux or Windows over a network. For explanation purposes, let us name your Windows box as WIN-PC and your share folder as WIN-SHARE.

Step 1

In order for your Linux box to identify WIN-SHARE folder, it should be mounted on Linux. The mount point is a directory at the location, /mnt/win. Type the following commands on the terminal.

# mkdir -p /mnt/win
# mount -t smbfs -o username=<username>,password=<password> //WIN-PC/WIN-SHARE /mnt/win
# cd /mnt/win
# ls -l

You need to replace <username>,<password> with your login name and the password of your windows machine.

Step 2

The above command will mount //WIN-PC/WIN-SHARE only for one time use. For the mounting to happen every time Linux system reboots, add the following line in /etc/fstab:

  • Open a terminal
  • Type:

# vi /etc/fstab

  • On the editor add the line:

//WIN-PC/share /mnt/win smbfs auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0

Step 3

Create the password file at /etc/sambapasswords:

  • Open a terminal
  • Type:

vi /etc/sambapasswords

  • On the editor add these lines:

username = <windows login name>

password = <windows login password>

Step 4

Secure sambapasswords file so that only the root can access it.

  • Open a terminal
  • Type:

# chown 0.0 /etc/sambapasswords

# chmod 600 /etc/sambapasswords

And that is it! You have just learned the tech-savvy method of accessing files residing on a Windows box from a Linux box. Next, we take a look as to how we can do this without any complicated syntaxes and just by a few clicks.

Using GUI Tools

  • Create a folder on your Windows machine → right click → select Properties → click on sharing tab → turn on sharing.
  • Give a name for the shared folder (e.g. WIN-SHARE) in the box provided
  • Find the IP address of your PC :
  • Open the command prompt
  • type “ipconfig”
  • Note down the displayed IP address somewhere. (e.g.
  • In your Linux box press ALT + F2 to open the Run dialog.
  • In the text box type the IP address and the shared folder name of your windows machine with the prefix


  • When you press run button in Run dialog, Linux will automatically connect to the Windows machine, access the specified folder and display the content on your Linux box.
  • If your Windows machine is password protected you may need to provide the password upon connecting.
  • You may also view the shared files if you go to Places → Networks. This will display all the Windows network shared folders your Linux machine is currently connected to.

, , ,

Leave a comment

12 Tips to Speed Up Windows 7

1. Uninstall Bloatware

Uninstall bloatware that came with your laptop or PC.
Or even apps you installed but no longer want. Head to Control Panel | Programs | Uninstall a program and take the hatchet to anything, such as unwanted games, that you’ll never need. Many programs will load processes at boot time and take up valuable RAM and CPU cycles. While you’re in here, you can also click “Turn Windows Features On or Off” and scan the list to see if there’s anything you don’t use.

1. Uninstall Bloatware

2. Limit Startup Processes

Limit startup processes.
In the Start button’s search box, type MSCONFIG, then head to the Startup tab. You’ll likely see a slew of apps, mostly for system support, but you’ll be able to identify some that clearly aren’t necessary. There’s absolutely no need to have GoogleUpdate or even QuickTime running all the time, for example. Don’t delete those that support your hardware or security, but anything blatantly nonproductive can go. You may have to check the program names online with a site like to see what they are—they may even be malware. If you want to get more granular, run Microsoft’s Autoruns utility.

2. Limit Startup Processes

3. Add More RAM

Add more RAM.
Windows 7 isn’t has much of a hog as Vista, but if you’re moving from XP, the memory requirements are greater. Here’s a great article to show you how to add RAM

4. Turn Off Search Indexing

Turn off search indexing.
In Vista I, would only do this if I saw the search indexing icon in the system tray and noticed a performance lag, but that notification isn’t present in Windows 7. Of course, if you do a lot of searching, this won’t appeal to you, as some searches will be slower. To turn off indexing, open the Indexing Options Control Panel window (if you just type “index” in the Start button search box, you’ll see that choice at the top of the start menu), click “Modify” and remove locations being indexed and file types, too. If you want to leave search indexing on, but find that it occasionally slows you down, you can stop its process when you need extra speed. Right-click on Computer either in the Start menu or on the desktop, choose Manage. Then double-click Services and Applications, then Services. Find Windows Search, and double click on that. From this properties dialog, you can choose a Startup type of Manual or Disabled to have the process silent by default.

4. Turn Off Search Indexing

5. Defrag

Defragment your hard drive.
Your disk stores data in chunks wherever there’s space on disk, regardless of whether the space is contiguous for one file. Defragging tidies everything up and blocks a program’s bits together so that the reader heads don’t have to shuttle back and forth to read a whole executable or data file. While this is less of a problem with today’s huge hard drives and copius RAM, a slow system can still benefit from defragmenting the disk. Windows 7 comes with a built-in defragger that runs automatically at scheduled intervals. Mine was set by default to run Wednesdays at 1:00 AM, when my PC is usually turned off; so it never got defragged. If you’re in a similar boat, you can either change the scheduled defrag, or defrag on demand. Just type “defrag” in the Windows Start Menu search bar, and click on “Disk Defragmenter.” The version of the utility is improved in Windows 7, and shows more information about what’s happening on your disk than Vista did. The Windows 7 engineering team posted a very in-depth, informative article on the Engineering
5. Defrag

6. Change Power Settings

Change power settings to maximum performance.
Of course, this isn’t a good choice if you want to save electricity, but it could boost your computing. Head to Control Panel / System and Security / Power Options. From here, click on the left-panel choice “Create a power option” and choose “High Performance.
6. Change Power Settings

7. Clean Up Your Disk

Clean up Your Disk.
From the Start menu, choose All Programs, Accessories, System Tools, and Disk Cleanup. This finds unwanted junk and files such as temporary, offline Web pages, and installer files on your PC and offers to delete them all at once. You may even find that your Recycle Bin is bulging at the seams: Mine had 1.47GB I didn’t know was there! This will generally only have a noticeable affect on speed if your machine is getting close to full, however.
7. Clean Up Your Disk

8. Check for Viruses & Spyware

Check for Viruses and Spyware.
You can run the built in Windows Defender or a third-party app. You could start with our Editors’ Choice, Spyware Doctor with AntiVirus 2010. If you don’t want to pay, though, there are plenty of free antimalware options.

9. Performance Troubleshooter

Use the Performance Troubleshooter.
In Control Panel’s search box, type “troubleshooting” and under System and Security, you’ll see the choice “Check for performance issues.” Run the troubleshooter and it may find the root cause of your slowdown.

10. Turn Off Desktop Gadgets

Turn off Desktop Gadgets.
Now we come to the tips that require shutting down some of the operating system’s bling. Windows 7 ditched the actual visual sidebar of Vista, but there’s still a sidebar process running. Turn it off by typing “gadgets” in the start menu search bar, choosing “View list of running gadgets” and select each in turn and click Remove to shut any gadgets you can live without.

11. Don’t Use a Beautiful Desktop Background

Don’t use a beautiful desktop background.
This will free up extra RAM and therefore boost speed slightly. Right-click on the desktop and choose Personalize, then Desktop Background at the bottom of the resulting dialog window. Set it to a solid color.

12. Turn Off Aero Eeffects

Turn off Aero effects.
Head to the Control Panel’s Performance Information and Tools section, and choose Adjust Visual Effects. Here you’ll find a long list of effects, but simply choosing “Adjust for best performance” will turn everything off. You’ll feel like you stepped back into a decade ago.
12. Turn Off Aero Eeffects
By Vijay Nayani

Leave a comment

Top 10 Most Frequently Asked Questions on Domain Name Registration

Here are the top ten most frequently asked questions regarding on Internet domain name registration:

Q1. Which characters are allowed in Internet domain names?

A: For normal ASCII domain names, the letters a-z, the numbers 0-9, and one special character, the hyphen or dash “-”. Note that domains cannot start or end with a hyphen. For the new tested IDNs (Internationalized Domain Names), the full range of Unicode characters are available. This allows nearly all of the languages on the planet to be represented within domain names, including Thai, Arabic, Lao, Hebrew, French, German etc.

Q2. How many characters can a Internet domain name have?

A: Generic domains (gTLDs) can have 63 characters in the second level, plus the top level domain, .com, .net etc.

Q3. How long can I register a Internet domain name for?

A: In most cases, you are allowed to register a Internet domain name for period of one to ten years. Longer periods are not currently allowed by the registry.

Q4. How long do Internet domain registrations take to make & process?

A: Typically ten minutes or so. Once you have chosen the name and paid the fee, most registration systems will register your name in near real-time.

Q5. Do I “own” a domain name I register?

A: Not really, it is more like a rental agreement. But importantly, you have the exclusive right to renew the agreement with the registry at the end of the initial registration period, so effectively you can keep the name as long as you want.

Q6. Why does my Internet domain name still show as unregistered in a WHOIS tool?

A: WHOIS tools are meant to show the nameserver / contact information for domain names held by a particular ICANN registrar. They are typical not updated in real-time and thus are not good indicators of current domain registration status.

Q7. How will I know if a Internet domain registration attempt has been successful?

A: WHOIS tool takes anything up to 48 hrs to be updated so can’t be relied on. A better indicator is whether you receive a confirmation e-mail from the domain registrar. You could also try registering the name again. By doing so, the registrar will do a “live” availability check on the name, which will indicate to you whether the name has been registered or not. This is not the same as a WHOIS look-up.

Q8. How long do domain names take to be active after registration?

A: Approximately 24 – 48 hrs, though because nameservers work as a distributed network, it can take up to 72 hrs or more before your domain name is accessible to all Internet users worldwide.

Q9. Can I register a Internet domain for later use?

A: There is no problem in registering domain names first, and using them later on. In fact, it is estimated that among 80% to 90% of all domain names are “idle”.

Q10. Can I get a refund if I make a mistake & register the wrong name?

A: Nearly all domain registrars operate a strict no refund policy. This is because they are charged a non-refundable fee by the registry to perform the registration.

By Vijay Nayani

Leave a comment

How to Limit The CPU Usage of Any Process in Linux

cpulimit-mainHave you ever experienced the situation where you open one particular application (such as Firefox) and it brings the whole system to a standstill? If you are running a web server, the last thing that you want to see is to have an application crashes the whole system and bring all the websites down.

Cpulimit is an application for Linux that can limit the CPU usage of a process. It is useful if you want to restrict a particular application from taking up too much CPU resources and thereby crashing the system. This can also be useful when you need to run several intensive programs simultaneously.

Note: cpulimit should work for all Linux distro. In this tutorial, we will be using Ubuntu for illustration.


In Ubuntu, you can install

cpulimit via the Ubuntu Software Center, click here to install, or type the following command in terminal:

1 sudo apt-get install cpulimit


To restrict a process, use the command

1 sudo cpulimit -p PID -l CPU%

The PID is the process ID of the running application and CPU% is the percentage (0-100, number only) of CPU resources allowed for the app. You can obtain the PID from System -> Administration -> System Monitor .


From the screenshot above, you can see that the Swiftfox application (a variant of Firefox) takes up 68% of the CPU resources before the CPU limit is set. Let’s see what happen when we limit the CPU usage to 20%.



The % CPU instantly drop below 20% and never did it cross the 20% mark again.

Extending cpulimit – Automating the whole process

Cpulimit is useful when you encounter an application that take up lot of CPU resources, or need to carry out batch job. In addition, you can also set it up to monitor the system for any misbehaving application. This is especially useful in a server setup.

abcuser from Ubuntu Forum has come up with a great script that automates the monitoring of your system and restricts any process that exceed a preset CPU limit. The script also allows you to set blacklist/whitelist for specific applications.

Before we start, make sure you have cpulimit and gawk installed.

1 sudo apt-get install cpulimit gawk

Download the scripts here. Extract the tar file to your Home folder. You should have two files inside the cpulimit folder: and cpulimit.

Open the file in your text editor (gEdit) and change the following:


CPU_LIMIT: This is the maximum CPU resources available to each application. The default value is 20%.

DAEMON_INTERVAL: This is the interval for the script to check the system. The default is set to 3 seconds.

BLACK_PROCESS_LIST: This contain the list of items that specifically want to monitor. You can use the “|” delimiter to include multiple processes. For example, “mysql|firefox|gedit“.

WHITE_PROCESSES_LIST: This contain the list of items that you DON’T WANT to monitor. You can use the “|” delimiter to include multiple processes. For example, “mysql|firefox|gedit“.

Note: One or both of the variables BLACK_PROCESSES_LIST and WHITE_PROCESSES_LIST has to be empty. You can’t have a blacklist and a whitelist at the same time.

Setting up

Copy the file to the /usr/bin/ folder

1 sudo cp ~/cpulimit/ /usr/bin
2 sudo chmod 700 /usr/bin/

Copy the cpulimit file to /etc/init.d/folder, set the necessary permission and make it run during statup.

1 sudo cp ~/cpulimit/cpulimit /etc/init.d/
2 sudo chown root:root /etc/init.d/cpulimit
3 sudo chmod +x /etc/init.d/cpulimit
4 sudo update-rc.d cpulimit defaults

Now, reboot your system. The cpulimit daemon should start automatically.

You can open a terminal and type:

1 sudo service cpulimit status

to check if the cpulimit daemon is running. If it is not running, start it with the command

1 sudo service cpulimit start

Alternatively, stop it with:

1 sudo service cpulimit stop


To uninstall, here’s what you need to do:

1. Stop cpulimit daemon

1 sudo service cpulimit stop # Stop cpulimit daemon and all cpulimited processes

2. Remove daemon from boot-up procedure

1 sudo update-rc.d -f cpulimit remove # Remove symbolic links

3. Delete boot-up procedure

1 sudo rm /etc/init.d/cpulimit # Delete cpulimit boot-up script

4. Delete cpulimit daemon

1 sudo rm /usr/bin/ # Delete cpulimit daemon script

5. Uninstall cpulimit program

1 sudo apt-get remove cpulimit

Optionally, uninstall gawk program

1 sudo apt-get remove gawk

For more info, refer to the Ubuntu Forum for more detail.

Code credit: abcuser from Ubuntu Forum

Leave a comment

HowTo Run ASP.NET on Linux With Apache Web Server (Mono + Mod_Mono)

Mono is an open source project led by Novell (formerly by Ximian) to create an Ecma standard compliant, .NET-compatible set of tools, including among others a C# compiler and a Common Language Runtime. Mono can be run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems. With Apache mod_mono we can run ASP.NET with C# on Linux machine. Mono is not just an ASP.NET interpreter, it also build a windows form and run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems. But for now i just want to show you how to run an ASP.NET application on Linux machine.

Ok, get let’s start. Follow these steps (for ubuntu):
1. You need to install several library for mono. Type this command:

# sudo apt-get install mono-xsp2 mono-apache-server2 libapache2-mod-mono mono-gmcs mono-utils

2. After it finish you need to edit your mod_mono.conf. The easiest way to run Asp.Net application is using
 AutoHosting configuration as example below:
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx
DirectoryIndex index.aspx
MonoAutoApplication enabled
MonoServerPath "/usr/bin/mod-mono-server2"

You can read more about AutoHosting here or manual hosting configuration here, for ubuntu user please refer to this documentation.
3. Save the file and restart your apache.
4. Now let’s start write the first Asp.Net application. You can copy the text below:
Filename: hello.aspx

<%@ Page language="c#" src="hello.aspx.cs"
Inherits="HelloApp.HelloPage" AutoEventWireup="true" %>
	<title>First Mono ASP.NET Application</title>
	<form  runat="server">
	  Enter your name: <asp:TextBox id="name" runat="server" />
	  <asp:Button id="greet" Text="Greet" onClick="OnGreetClick" runat="server"/>
	<br /><strong><asp:Label id="message" runat="server">Hello, World!

Filename: hello.aspx.cs

using System;
using System.Web.UI.WebControls;
namespace HelloApp
public class HelloPage : System.Web.UI.Page
protected Label message;
protected Button greet;
protected TextBox name;
public void OnGreetClick(Object sender, EventArgs e)
message.Text = "Hello, " + name.Text;

5. Ok now save file to your web server. Mine is at the /var/www/firstaspnet/

6. And you will see your first Asp.Net application run on Linux OS.

If you like this post, please leave me a comment. Have a nice day.

Article by Vijay Nayani

1 Comment

%d bloggers like this: