Powered by WordPress | Valid XHTML 1.1 and CSS 3
  • PHP error: Cannot modify header information – headers already sent

    For those of you new to PHP and those of you who haven’t run into this problem already, here are a few pointers about the Cannot modify header information – headers already sent error and some things that might work for you to fix them :)

    There are several reasons to modify the header values, for example if you want PHP to generate XML output, you would want to modify the header information.
    Often people stumble into this error when using the header() function in PHP.

    Let’s look at few ways to try and fix this error.

    First thing lets get some debugging output to help us

    <?php
    ini_set(‘display_errors’, true);
    ini_set(‘display_startup_errors’, true);
    error_reporting (E_ALL);
    ?>

    Check your PHP file for whitespaces and blank lines before the <?php tag and after the ?> tag. There should be no whitespaces or blank lines outsides those tags.
    Note! Dreamweaver used to addwhitespaces to .php files saved as UTF-8, but they are invisible in Dreamweaver.

    You can add this line to the very start of your script.

    <?php ob_start(); ?>

    You can add the following line to your php.ini file

    output_buffering = 4096

    Check your files encoding settings.

    These are the problems I’ve personally ran into with this error and hopefully this can help you if you are having the same problem.

    Tuesday, December 1st, 2009 at 17:58
    No comments
    Writer: kjarri
  • Monitoring with Munin

    Munin is a nice tool to monitor your Linux server.
    It can show you a whole lot of information in graphs, and everybody likes graphs! They look cool and sometimes they even give you some information!

    If you are running Ubuntu / Debian, it’s extremely simple to set up Munin and get it running.

    Let’s assume that we have a server called nerdrage.org and we want to monitor that.

    First we install Munin using apt-get

    sudo apt-get install munin munin-node

    With munin and munin-node installed, we would like to edit the configuration file which is in /etc/munin/munin.conf.
    From here we can set the output directory and we also want to set a server name.

    vi /etc/munin/munin.conf

    Here we want to change htmldir (this is where munin puts the fancy graphs) and we also want to change [server1.example.com] to your own server name (for example www.nerdrage.org).
    The rest of the settings we don’t have to worry about at this point.

    dbdir   /var/lib/munin
    htmldir /var/www/www.nerdrage.org/munin
    logdir  /var/log/munin
    rundir  /var/run/munin
    
    tmpldir /etc/munin/templates
    
    [server1.example.com]
        address 127.0.0.1
        use_node_name yes

    Then we create the output directory for munin

    sudo mkdir /var/www/www.nerdrage.org/munin

    And change the ownership so munin can write to the directory

    sudo chown munin:munin /var/www/www.nerdrage.org/munin

    And finally we restart the service

    sudo /etc/init.d/munin-node restart

    After a few minutes you can go to the address that you specified in the configuration file (in this case http://www.nerdrage.org/munin) and see some fancy graphs!

    Thursday, November 26th, 2009 at 13:59
    No comments
    Writer: kjarri
  • Mom’s birthday!

    Til hamingju með afmælið mamma!

    Wednesday, November 25th, 2009 at 14:13
    No comments
    Writer: kjarri
  • Crash

    Our server managed to crash, so I’m rebuilding the whole thing now.

    Most of the stuff is recoverable, but sadly the one thing that isn’t is the code I’ve been writing for the past 2 months. Purrhaps I’ll be a bit more careful next time, eh? :)

    Back to installing services! Ciao!

    Saturday, November 21st, 2009 at 14:03
    No comments
    Writer: kjarri
TOP