Jaime Frutos Morales's blog


How to configure mod_deflate for Apache on Ubuntu 10.10

Filed under: SysAdmin, Ubuntu — acidborg @ 12:51

Description: mod_deflate is an Apache module which “provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.” (from its web). This means that you save some bandwidth in exchange for some CPU cycles compressing the data your Apache server sends.

Installation: If you have Apache installed, you don’t need additional packages, because this module belongs to the package “apache2.2-common“.


  1. Enable the mod_deflate module: sudo a2enmod deflate
  2. Edit /etc/apache2/mods-enabled/deflate.conf with the following content:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/ecmascript application/rss+xml text/x-js
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  3. Restart Apache: sudo /etc/init.d/apache2 restart

NOTE: There are some old versions of some browsers which don’t support this kind of compression, although it’s included in RFC 2616 (HTTP/1.1). http-compression.com has more info about it.


How to upgrade from Ubuntu 10.04 (Lucid) to Ubuntu 10.10 (Maverick)

Filed under: Linux, Ubuntu — acidborg @ 11:47

The upgrade is similar to the previous ones:

  1. Replace “lucid” for “maverick” in /etc/apt/sources.list : sudo sed -i 's/lucid/maverick/g' /etc/apt/sources.list
  2. Upgrade your system: sudo apt-get update && sudo apt-get -y dist-upgrade
  3. Reboot: sudo shutdown -r now


How to synchonize your Ubuntu 10.04 desktop with a NTP server

Filed under: SysAdmin, Ubuntu — acidborg @ 12:21

Description: On my previous post, I explained how to install and configure a NTP server on your local network. Now I’m going to explain how to synchronize an Ubuntu 10.04 computer with your local NTP server.

Installation: apt-get install ntpdate


  1. Create the file /etc/cron.d/ntpdate.cron with the following content (modifying “your-ntp-server” with the name or IP address of your NTP server):
    15 */1 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null
  2. This will synchronize your computer’s clock with the NTP server every hour. If you want to increase the synchronization period, increase the “/1”. For example: Use 15 */6 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null to synchronize your computer’s clock every 6 hours.
  3. Set the proper owner and permissions for the created file: chmod 600 /etc/cron.d/ntpdate.cron && chown root:root /etc/cron.d/ntpdate.cron


How to install and configure a NTP server for your network on Ubuntu Server 10.04

Filed under: SysAdmin, Ubuntu — acidborg @ 13:29

Description: The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over a network. It is very useful if you want all the computers on your network to share the same time because file accesses, logs, tasks, etc will be synchronized. I’m going to explain how to install a NTP server on your network so that the rest of computers can synchronize with it.

Installation: apt-get install ntp


  1. Go to www.pool.ntp.org, select your continent on the Active servers list and your country (or the nearest one) on the next list.
  2. You will be given a list of public NTP servers to synchronize your server with. For example, if you live in Spain, you will be given the following list of NTP servers: server 2.es.pool.ntp.org , server 0.europe.pool.ntp.org , server 2.europe.pool.ntp.org .
  3. Edit your /etc/ntp.conf file using the list of servers you were given:
    server 1.es.pool.ntp.org
    server 0.europe.pool.ntp.org
    server 2.europe.pool.ntp.org
    restrict -4 default kod notrap nomodify nopeer noquery
    restrict mask nomodify notrap noquery
    driftfile /var/lib/ntp/ntp.drift
  4. Change the line “restrict mask nomodify notrap noquery” with your subnet IP and netmask.
  5. Restart your NTP server: /etc/init.d/ntp restart

Some seconds later, your NTP server will begin to synchronize with the external time servers. It may take a couple of minutes to get your computer’s clock synchronized, so please be patient. You can check your NTP server’s stats and status with the following command: ntpq -p .

NOTE: your NTP server must be reachable on port 123 (UDP) from the remote time servers, so make sure your firewall allows it.

On my next post, I will explain how to synchronize your GNU/Linux computers with the NTP server you have just installed.


How to install and configure Apt-Cacher NG on Ubuntu Server 10.04

Filed under: Linux, SysAdmin, Ubuntu — acidborg @ 13:34

Description: Apt-Cacher NG is a caching proxy specialized for package files from GNU/Linux distributors, primarily for Debian and Debian based distributions (like Ubuntu). This means that if you have many Debian/Ubuntu machines on your network, you just have to download the deb packages (new software, updates, distro upgrades, etc) from the internet once and the rest of the Debian/Ubuntu machines get them from Apt-Cacher NG cache, saving time and internet bandwidth. To install it, follow these simple steps:


  1. Installation: apt-get install apt-cacher-ng
  2. Configuration: Edit /etc/apt-cacher-ng/acng.conf with the following content:
    CacheDir: /var/cache/apt-cacher-ng
    LogDir: /var/log/apt-cacher-ng
    Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
    Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
    PidFile: /var/run/apt-cacher-ng/pid
    ExTreshold: 4
  3. Restart Apt-Cacher NG: /etc/init.d/apt-cacher-ng restart
  4. Create on the rest of the Debian/Ubuntu machines on the network the file /etc/apt/apt.conf.d/02proxy with the following content:
    Acquire::http { Proxy "http://your-apt-cacher-ng-server:3142"; };

Next time any of your machines needs a deb package, it will ask Apt-Cacher NG for it. If this package was asked previously by any of the other machines, Apt-Cacher will have a copy and will deliver it. Otherwise, it will fetch it from the internet repositories, keep a local copy and deliver it.


How to upgrade from Ubuntu 9.10 (Karmic) to Ubuntu 10.04 (Lucid)

Filed under: Ubuntu — acidborg @ 20:03

This post is a modified “déjà vu” of a previous one.

  1. Replace “karmic” for “lucid” in /etc/apt/sources.list : sudo sed -i 's/karmic/lucid/g' /etc/apt/sources.list
  2. Upgrade your system: sudo apt-get update && sudo apt-get -y dist-upgrade
  3. Reboot: sudo shutdown -r now


How to install and use Fabric on Ubuntu 9.10

Filed under: Python, SysAdmin, Ubuntu — acidborg @ 10:59

From its web: “Fabric is a Python library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. More specifically, Fabric is:

  • A tool that lets you execute arbitrary Python functions via the command line;
  • A library of subroutines (built on top of a lower-level library) to make executing shell commands over SSH easy and Pythonic.

Naturally, most users combine these two things, using Fabric to write and execute Python functions, or tasks, to automate interactions with remote servers.


  1. Download the package from here
  2. Install it: sudo dpkg -i fabric*.deb


  1. Follow this short tutorial to learn the basics.
  2. Create a file called fabfile.py
  3. Fill it with your customized functions. For Example:
    from fabric.api import env, run, sudo
    env.hosts = ['ubuntu1', 'ubuntu2', 'ubuntu3']
    def upgrade_hosts():
    sudo('apt-get update && apt-get dist-upgrade ')
  4. Run fabric: fab upgrade_hosts

I find Fabric very useful and time-saving when maintaining similar servers, because you can design a task and run it automatically on all the servers.


How to disable IPv6 on Ubuntu Server 9.10

Filed under: SysAdmin, Ubuntu — acidborg @ 17:21

IPv6 support can be disabled on Ubuntu Server 9.10 following these simple steps:

  1. Edit /etc/default/grub :
  2. Update GRUB: update-grub2 (or update-grub if you don’t use GRUB 2)
  3. After the next reboot, IPv6 support will be disabled.


How to configure a network bridge in Debian / Ubuntu

Filed under: Linux, SysAdmin, Ubuntu — acidborg @ 12:23

Description: Following yesterday’s post, today I’m going to explain how to do the same in a Debian / Ubuntu system.


Install the packages needed: apt-get install bridge-utils


  • Edit /etc/network/interfaces and replace your eth1 config with this:

    auto eth1
    iface eth1 inet manual

    auto br0
    iface br0 inet static
    bridge_ports eth1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

  • Restart your network interfaces: /etc/init.d/networking restart


How to install and configure Trac using Apache and a Subversion backend in Ubuntu 9.10

Filed under: SysAdmin, Ubuntu — acidborg @ 13:34

Description: “Trac is an enhanced wiki and issue tracking system for software development projects. Trac uses a minimalistic approach to web-based software project management. Our mission is to help developers write great software while staying out of the way. Trac should impose as little as possible on a team’s established development process and policies. It provides an interface to Subversion (or other version control systems), an integrated Wiki and convenient reporting facilities. Trac allows wiki markup in issue descriptions and commit messages, creating links and seamless references between bugs, tasks, changesets, files and wiki pages. A timeline shows all current and past project events in order, making the acquisition of an overview of the project and tracking progress very easy. The roadmap shows the road ahead, listing the upcoming milestones“.


  • Install Trac and Subversion: apt-get install trac subversion apache2 libapache2-mod-python
  • Create a directory for the Subversion repository: mkdir svn-trac
  • Create the Subversion repository: svnadmin create svn-trac
  • Create the Trac environment: trac-admin trac initenv
  • Something like this will be shown:

    Creating a new Trac environment at /home/acidborg/trac

    Trac will first ask a few questions about your environment in order to initialize and prepare the project database.

    Please enter the name of your project. This name will be used in page titles and descriptions.

    Project Name [My Project]> My Trac

    Please specify the connection string for the database to use. By default, a local SQLite database is created in the environment directory. It is also possible to use an already existing PostgreSQL database (check the Trac documentation for the exact
    connection string syntax).

    Database connection string [sqlite:db/trac.db]> sqlite:db/trac.db

    Please specify the type of version control system, By default, it will be svn.

    If you don't want to use Trac with version control integration, choose the default here and don't specify a repository directory in the next question.

    Repository type [svn]> svn

    Please specify the absolute path to the version control repository, or leave it blank to use Trac without a repository. You can also set the repository location later.

    Path to repository [/path/to/repos]> /home/acidborg/svn-trac

    Creating and Initializing Project
    Installing default wiki pages
    Project environment for 'My Trac' created.

    You may now configure the environment by editing the file:


    If you'd like to take this new project environment for a test drive,
    try running the Trac standalone web server `tracd`: tracd --port 8000 /home/acidborg/trac

    Then point your browser to http://localhost:8000/trac.
    There you can also browse the documentation for your installed
    version of Trac, including information on further setup (such as
    deploying Trac to a real web server).

    The latest documentation can also always be found on the project
    website: http://trac.edgewall.org


Configuration (using the Apache web server):

  • Give the ownership of svn-trac and trac to the Apache user and group: chown -R www-data:www-data svn-trac trac
  • Give the proper rights on svn-trac and trac to the apache user and group: chmod -R 770 svn-trac trac
  • Create the configuration file to run Trac on Apache ( /etc/apache2/conf.d/trac ) with the following content (replace [ and ] for angle brackets):

    [Location /trac]
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonInterpreter main
    PythonOption TracEnv /home/acidborg/trac
    PythonOption TracUriRoot /trac
    SetEnv PYTHON_EGG_CACHE /tmp
    [Location /trac/login]
    AuthType Basic
    AuthName "TRAC User Authentication"
    AuthUserFile /etc/.trac.htpasswd
    Require valid-user

  • Create a user for Trac (acidborg in this case): htpasswd -c /etc/.trac.htpasswd acidborg
  • Give the proper permissions to that file: chmod 640 /etc/.trac.htpasswd && chown root:www-data /etc/.trac.htpasswd
  • Restart Apache: apache2ctl restart
  • Give the new user writing permission in the Trac environment: trac-admin /home/acidborg/trac permission add acidborg authenticated

You can configure the look & feel and many other preferences of your Trac editing the file trac.ini in your Trac environment (/home/acidborg/trac/conf/trac.ini in this example).

Older Posts »

Create a free website or blog at WordPress.com.