Blogs

List partitions by UUID

UUID mounts in fstab is very useful if you have external usb hdd that is often connected and disconnected.

To find out the UUID of a disk drive, you can use the simple `ls` command as below:

ls -l /dev/disk/by-uuid

Additionally below commands can also be used:

# blkid
# vol_id /dev/sda1
# tune2fs -l /dev/sda1

cannot create temporary file - (13) Permission denied

This is dues to bug in the default installation of qmail in handling local mails... such as mails to root@localhost where the qmail-local binary is not set with the right owner and permissions, as such mails are not able to be written to the spool located at "/usr/local/psa/handlers/spool".

The error in "/usr/local/psa/var/log/maillog" looks like below:

qmail-local-handlers[......]: cannot create temporary file - (13) Permission denied

To resolve, change the owner and permission of /var/qmail/bin/qmail-local to reflect the same as qmail-remote.

cd /var/qmail/bin
chown mhandlers-user:popuser qmail-local
chmod g+s,g-r,o-r qmail-local

Restart qmail:

/etc/init.d/qmail restart

Bulk update DNS TTL for all Plesk domains

This is useful when migrating servers and you want to reduce the DNS time to live for all domains.

Change the TTL on all domains to 5 mins (300 seconds) in the psa database.

# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa
mysql> UPDATE `dns_zone` SET `ttl` = '300', `ttl_unit` = '60' WHERE `id` >1;
mysql> quit

Then update the zone files via:

# mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from domains' | awk '{print "/usr/local/psa/admin/sbin/dnsmng update " $1 }' | sh

Verify with:

$ dig @nameserver domain.tld soa

Upgrade CentOS 5.3 to 5.4

Below is a clean method of updating, instead of doing a straight `yum update` which I have often done in the past and broken OS.

yum clean all
yum update glibc\*
yum update yum\* rpm\* python\*
yum clean all
yum update
shutdown -r now

Unable to open pty: No such file or directory

Udev is a dependency of xorg and other development packages that breaks OpenVZ containers if installed or upgraded.

Re-create the missing devices after an upgrade via:

vzctl exec {VEID} /sbin/MAKEDEV tty
vzctl exec {VEID} /sbin/MAKEDEV pty

For a permanent fix, edit /etc/rc.sysinit to disable udev and auto-repair the devices:

#/sbin/start_udev
/sbin/MAKEDEV tty
/sbin/MAKEDEV pty

My.Cnf File Issue on Linux Dedicated Server Running CentOS

Dear Anyone.

Hello i came across this website doing a search for My.Cnf tweeks or configurations for the SQL_Max_Connections and i was wondering some things. I have a Linux CentOS system with 2.5 gigs of Ram, Running Apache. and PHP. what would be the "proper" My.cnf file settings for a Music Website i keep getting a max connection overload on the network.

Matthew Nalett
New Music Promote
http://www.newmusicpromote.com

Here is my current My.Cnf settings.
Any Suggestions on how to optimize this for a Music Network?


[mysqld]
set-variable=local-infile=0

Munin stats for apache and lighttpd

Get status of apache (80) and lighttpd (81) on different ports:

This is done at the nodes.

  1. Enable apache server-status in httpd.conf :
    <Location /server-status> 
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
  2. Enable lighttpd server-status in lighttpd.conf :
    $HTTP["remoteip"] == "127.0.0.1" {
    status.status-url          = "/server-status"
    }
  3. Create /etc/munin/plugin-conf.d/apache:
    [apache*]
    env ports="80 81" 

    * Test with:

    ports="80 83" /etc/munin/plugins/apache_processes

lighttpd idle process will be a straight line as total of busy and idle process is always the same when drawn as STACK, . To change this to LINE1:

At the host, edit "/etc/munin/munin.conf" and add the below line to the corresponding host:

apache_processes.idle81.draw LINE1

Lighttpd client side optimization

  1. Edit conf file: /etc/lighttpd/lighttpd.conf
  2. Enable mod_expire and mod_compress.
  3. Expire static files set for 3 days:
    $HTTP["url"] =~ "\.(js|css|gif|jpg|png|ico|txt|swf|html|htm)$" { expire.url = ( "" => "access 3 days" ) }
  4. Compress mime types:
    compress.cache-dir         = "/var/cache/lighttpd/compress/"
    compress.filetype          = ("text/plain", "text/html", "text/css", "text/xml", "text/javascript")
  5. Cleanup the compressed cache via daily cron script:
    #!/bin/bash
    # lighttpd_cache_clean
    # Clean cache stored at /var/cache/lighttpd/compress
    # Place in /etc/cron.daily

    # Cache dir path
    CROOT="/var/cache/lighttpd/compress"

    #Deleting files older than 3 days
    HOURS=72

    # Lighttpd user and group
    LUSER="lighttpd"
    LGROUP="lighttpd"

    # start cleaning
    /usr/sbin/tmpwatch --mtime ${HOURS} ${CROOT}

    # if directory missing just recreate it
    if [ ! -d $CROOT ]
    then
            mkdir -p $CROOT
            chown ${LUSER}:${LGROUP} ${CROOT}
    fi

    exit 0
  6. Create the cache directory and update permissions:
    mkdir -p /var/cache/lighttpd/compress
    chown lighttpd:lighttpd /var/cache/lighttpd/compress
  7. Restart lighttpd.

Create pdf of manual pages

Below command will convert and create a pdf of a manual page.

man -t man | ps2pdf - > man.pdf

unable to include potential exec

Recent upgrade to Apache-2.2.3 secured down on executables not able to be included within a SSI include call and was getting "unable to include potential exec" in the apache error log file.

Apparently .shtml files were being used as includes via SSI. Changing the included files to .html resolved the issue.

Below was the command issued from the document root to quickly rename all the embedded leftmenu.shtml to leftmenu.html:

cp -a leftmenu.shtml leftmenu.html
find -L -name "*.shtml" -type f -printf "\"%p\"\n" | xargs perl -pi -e 's/leftmenu\.shtml/leftmenu\.html/g'

Syndicate content
Comment