Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

Language: German English

Fix Ubuntu 11.10 Oneiric Ocelot dbus Problem

After uprade to Ubuntu 11.10 Oneiric Ocelot i get the following message during the system boot:

Waiting for network configuration

It takes a long time and leads to a black screen.

You can see the following message sometimes, too.

Unable to connect to the system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: Connection refused

The quick fix was to delete zu dbus files in “/var/run/dbus/”

rm /var/run/dbus/*

and reboot the system.

But you will get the same problem again after the next reboot.

A stable solution is to move the “/var/run” and “/var/lock” directories.

First move all contents from “/var/run” into “/run” and from “/var/lock” into “/run/lock”.

mv /var/run/* /run/
mv /var/lock/* /run/lock/

Note: If you have installed VMWare you have to unmount “vmblock-fuse”. Before moving the content.

umount /var/run/vmblock-fuse

Now delete “/var/run” and “/var/lock”:

rmdir /var/run
rmdir /var/lock

and replace them with symlinks to the new destination:

ln -s /run /var/run
ln -s /run/lock /var/lock

Now reboot your system.

Links:

* https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/811441

* https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/856810

* http://forum.ubuntuusers.de/topic/nach-upgrade-problem-mit-dem-networkmanager/#post-3473007

Comments: 14 | Read Comments | Write a Comment |

Convert PDF to Image

Using “convert” from “imagemagick” to convert a PDF to Image.

Example:

convert -geometry 1024x768 -density 200 -colorspace RGB input.pdf output.jpg

Or use a other geometry, quality and no color:

convert -geometry 2048x1536 -density 400 -colorspace gray input.pdf output.jpg

Links:

* http://www.imagemagick.org/script/convert.php

Comments: 0 | Read Comments | Write a Comment |

System Administrator Appreciation Day – 2011

To all other system adminstrators “HAPPY SYSADMIN DAY !”

http://www.sysadminday.com

and, of course


Sources:
http://www.userfriendly.org
http://xkcd.org

Comments: 0 | Read Comments | Write a Comment |

Install Sun Java with Puppet on Ubuntu

Sun wants you to agree to its license before installing the JRE/JDK. For an unattended install you need a preseed file.
You get the content of this file with “debconf-get-selections | grep sun-” on a system where you have already installed the required packages.

Create a file “/etc/puppet/files/sun-java6.preseed” with the following example content:

sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre sun-java6-jre/stopthread boolean true
sun-java6-jre sun-java6-jre/jcepolicy note
sun-java6-bin shared/error-sun-dlj-v1-1 error
sun-java6-jdk shared/error-sun-dlj-v1-1 error
sun-java6-jre shared/error-sun-dlj-v1-1 error
sun-java6-bin shared/present-sun-dlj-v1-1 note
sun-java6-jdk shared/present-sun-dlj-v1-1 note
sun-java6-jre shared/present-sun-dlj-v1-1 note

I use this APT-Module to add the Ubuntu partner repository. (Required for Sun-Packages)

apt::source { "partner":
    location => "http://archive.canonical.com/ubuntu",
    release => "${lsbdistcodename}",
    repos => "partner",
    include_src => false,
}

Now you can install the sun package:

file { "/var/cache/debconf/sun-java6.preseed":
    source => "puppet://$server/filesserver/sun-java6.preseed",
    ensure => present
}
package { "sun-java6-jdk":
    ensure  => installed,
    responsefile => "/var/cache/debconf/sun-java6.preseed",
    require => [ Apt::Source["partner"], File["/var/cache/debconf/sun-java6.preseed"] ],
}

Note: I use sun-java6-jdk but you can install sun-java5-jre in the same way.

Comments: 4 | Read Comments | Write a Comment |

Install latest Broadcom bnx2 linux driver

Install new broadcom driver on Ubuntu or Debian:

1. Download Linux driver

http://www.broadcom.com/support/ethernet_nic/downloaddrivers.php

2. Unpack

unzip linux-6.2.23.zip
cd Server/Linux/Driver
tar vfx netxtreme2-6.2.23.tar.gz
cd netxtreme2-6.2.23

3. Install build tools and install the driver

sudo aptitude install build-essential linux-headers
make
sudo make install

4. Test

before installation:

$ ethtool -i eth0
driver: bnx2
version: 2.0.2
firmware-version: 4.6.1 ipms 1.6.0
bus-info: 0000:05:00.0

after installation:

$ ethtool -i eth0
driver: bnx2
version: 2.0.23b
firmware-version: bc 4.6.1 ipms 1.6.0
bus-info: 0000:05:00.0
Comments: 0 | Read Comments | Write a Comment |

Install VMware Tools on Debian Squeeze

1. Install required packages

aptitude install autoconf automake binutils cpp gcc linux-headers-$(uname -r) make psmisc

2. Mount VMware Tools

mkdir /tmp/vmtools
mount /dev/cdrom /tmp/vmtools

3. Unzip the tools

tar -C /tmp -vfx /tmp/vmtools/VMwareTools*.tar.gz

4. Run install script

cd /tmp/vmware-tools-distrib
./vmware-install.pl

Note: You can also use the “open-vm-tools” instead of installing the VMware Tools.

aptitude install open-vm-tools

You need to add “contrib” to your sources.list !

Comments: 0 | Read Comments | Write a Comment |

Nginx as reverse proxy cache for wordpress and apache

1. Install Nginx

* Install from PPA
* Install using self build packages

2. General Nginx Settings

Edit “/etc/nginx/nginx.conf” and modify or insert the following settings:

[...]
http {
  [...]
  # Gzip Settings
  gzip on;
  gzip_disable "msie6";
  gzip_buffers 32 8k;
  gzip_comp_level   6;
  gzip_http_version 1.0;
  gzip_min_length   0;
  gzip_types        text/html text/css image/x-icon application/x-javascript application/javascript text/javascript application/atom+xml application/xml ;

  # Proxy Settings
  proxy_temp_path /var/lib/nginx/proxy;
  proxy_connect_timeout 30;
  proxy_read_timeout 120;
  proxy_send_timeout 120;
  proxy_cache_key "$scheme://$host$request_uri";
  [...]
}
[...]

3. Create Site

Create “/etc/nginx/sites-available/www.mogilowski.net” with following content:

Note: Replace “www.mogilowski.net” with your site and replace “mogfilecache” with a unique name for the filecache for this site.

proxy_cache_path  /var/lib/nginx/cache  levels=1:2   keys_zone=mogfilecache:180m  max_size=500m;

server {
        proxy_cache_valid 200 3h;

        listen 80;

        server_name www.mogilowski.net;

        access_log /var/log/nginx/mogilowski.proxied.log;
        error_log /var/log/nginx/mogilowski.proxied.log crit;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
            # If logged in, don't cache.
            if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
                set $do_not_cache 1;
            }
            proxy_cache_key "$scheme://$host$request_uri $do_not_cache";
            proxy_cache mogfilecache;
            proxy_pass http://127.0.0.1:81;
        }

        location ~* wp\-.*\.php|wp\-admin {
            proxy_pass http://127.0.0.1:81;
        }

	location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
            proxy_cache_valid 200 6h;
            expires max;
            proxy_cache mogfilecache;
            proxy_pass http://127.0.0.1:81;
        }

        location ~* \/[^\/]+\/(feed|\.xml)\/? {
            if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
                set $do_not_cache 1;
            }
            proxy_cache_key "$scheme://$host$request_uri $do_not_cache";
            proxy_cache_valid 200 1h;
            proxy_cache mogfilecache;
            proxy_pass http://127.0.0.1:81;
        }

        # No access to .htaccess files.
        location ~ /\.ht {
            deny  all;
        }

}

Note: In this example configuration the apache webserver runs on port 81 on the localhost. But it can also be a different machine on the internet. Just use “http://YOUR_APACHE_SERVER:80″ instead.

4. Enable site

ln -s /etc/nginx/sites-available/www.mogilowski.net /etc/nginx/sites-enabled/www.mogilowski.net

Note: Please remove the default site from sites-enabled.

5. Purge Cache (optional)

If you have build your own nginx package with the “proxy_cache_purge” module, you can add this to your server config. (http://labs.frickle.com/nginx_ngx_cache_purge/)

server {
    [...]
    location ~ /purge(/.*) {
                allow                   127.0.0.1;
                deny                    all;
                proxy_cache_purge       mogfilecache   "$scheme://$host$request_uri";
        }
    [...]
}

You can use this together with this plugin: http://wordpress.org/extend/plugins/nginx-proxy-cache-purge

6. Links

* http://wp-performance.com/2010/10/nginx-reverse-proxy-cache-wordpress-apache/
* http://wiki.nginx.org/Wordpress
* http://wordpress.org/extend/plugins/nginx-proxy-cache-integrator/
* http://www.djm.org.uk/wordpress-nginx-reverse-proxy-caching-setup/
* http://zachbrowne.com/2011/how-to-build-the-fastest-wordpress-website-with-apache-ngnix-reverse-proxy-php-cgi-google-pagespeed/

Comments: 3 | Read Comments | Write a Comment |

Install nginx on debian squeeze from PPA

You find currently nginx version 0.7.67-3 in Debian Squeeze. If you want the latest version you have to build your own paket or you can use one from the ubuntu ppa.

This installs the latest stable relase of nginx webserver (current 1.0.1) on Debian Squeeze.

echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main" > /etc/apt/sources.list.d/nginx-stable-lucid.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
aptitude update
aptitude install nginx

But if you need some third party modules, you have to build your own packages.

Comments: 1 | Read Comments | Write a Comment |

Building a nginx debian package with third party modules

I created this manual on Debian Squeeze (amd64) with the latest version of nginx (stable) an one third party module as example.
If you want to build your own package, check for the latest versions of the modules and nginx and modify the version numbers in this manual.

1. Install build debian tools and depending packages

aptitude install build-essential dpkg-dev debhelper autotools-dev libgeoip-dev libssl-dev libpcre3-dev zlib1g-dev

2. Download latest nginx and unpack the tarball

wget http://nginx.org/download/nginx-1.0.2.tar.gz
tar xvzf nginx-1.0.2.tar.gz

3. Download additional modules

I use the nginx purge module in this example. Download the module

wget http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz

and create a “module” directory if it not exists and untar the module to this directory:

mkdir nginx-1.0.2/modules
tar vfx ngx_cache_purge-1.3.tar.gz -C nginx-1.0.2/modules/

4. Get latest debian package

apt-get source nginx

You get a directory with the latest nginx source (nginx-0.7.67). We only need the “debian” folder.

5. Copy the debian folder to the new nginx folder

cp -r nginx-0.7.67/debian/ nginx-1.0.2
rm nginx-1.0.2/debian/patches/*

Don’t forget to remove the old patches !

Edit “nginx-1.0.2/debian/changelog” and prepend:

nginx (1.0.2-1) unstable; urgency=low

  * added purge proxy module

 -- Sebastian Mogilowski   Sat, 14 May 2011 13:00:00 +0100

Note: Replace my name with your own name :-)

Add the module to the build rules edit “nginx-1.0.2/debian/rules” and add:

--add-module=$(CURDIR)/modules/ngx_cache_purge-1.3 \

to the “./configure” setting.

Example:

./configure --conf-path=/etc/nginx/nginx.conf \
            --error-log-path=/var/log/nginx/error.log \
            --http-client-body-temp-path=/var/lib/nginx/body \
            --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
            --http-log-path=/var/log/nginx/access.log \
            --http-proxy-temp-path=/var/lib/nginx/proxy \
            --lock-path=/var/lock/nginx.lock \
            --pid-path=/var/run/nginx.pid \
            --with-debug \
            --with-http_dav_module \
            --with-http_flv_module \
            --with-http_geoip_module \
            --with-http_gzip_static_module \
            --with-http_realip_module \
            --with-http_stub_status_module \
            --with-http_ssl_module \
            --with-http_sub_module \
            --with-ipv6 \
            --with-mail \
            --with-mail_ssl_module \
            --add-module=$(CURDIR)/modules/ngx_cache_purge-1.3 \
            $(CONFIGURE_OPTS)

6. Build the package

cd nginx-1.0.2
dpkg-buildpackage -b

7. Install

dpkg -i nginx_1.0.2-1_amd64.deb
Comments: 3 | Read Comments | Write a Comment |

Nagios 3 with Nginx on Ubuntu Server

1. Install Nagios 3

aptitude install nagios3

2. Test Nagios Installation

Open “http://SERVER/nagios3/” in your browser. Login with user “nagiosadmin” and the passwort you have entered during the installation.

3. Switch from Apache to Nginx

Nagios has dependencies to the Apache webserver. So Apache was installed with Nagios. Now we replace it with Nginx.

3.1 Install Nginx and libfcgi (Perl)
aptitude install nginx libfcgi-perl
3.2 Configrate Fastcgi

Download fastcgi-wrapper and init scripts: perl-fastcgi (1.64 kB)

wget http://www.mogilowski.net/wp-content/uploads/perl-fastcgi.tar.gz
tar vfx perl-fastcgi.tar.gz
mv fcgi/fastcgi-wrapper /usr/bin/fastcgi-wrapper.pl
mv fcgi/perl-fastcgi /etc/init.d/perl-fastcgi
rmdir fcgi
chmod +x /usr/bin/fastcgi-wrapper.pl
chmod +x /etc/init.d/perl-fastcgi
update-rc.d perl-fastcgi defaults
/etc/init.d/perl-fastcgi start
3.3. Configurate Nginx
vim /etc/nginx/sites-available/nagios
server {
	listen   80;
	server_name  servername.com;

	access_log  /var/log/nginx/access.log;

	auth_basic            "Restricted Nagios Area!";
  	auth_basic_user_file  /etc/nagios3/htpasswd.users;	

	location / {
		root /usr/share/nagios3/htdocs;
		index index.html;

		rewrite ^/nagios3/(.*)$ /$1 break;
	}

	location /nagios3/stylesheets {
                alias /etc/nagios3/stylesheets;
        }

	location ~ \.cgi$ {
		root /usr/lib/cgi-bin/nagios3;
		include /etc/nginx/fastcgi_params;

		rewrite ^/cgi-bin/nagios3/(.*)$ /$1;

		fastcgi_pass 127.0.0.1:8999;
		fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name;
		fastcgi_param AUTH_USER       $remote_user;
		fastcgi_param REMOTE_USER     $remote_user;
	}

}
ln -s /etc/nginx/sites-available/nagios /etc/nginx/sites-enabled/nagios
/etc/init.d/nginx restart
3.4 Remove Apache

Now you can remove all apache pakets. Exept “apache2-utils” this paket is required by nagios3.

4. Test with Nginx

Open “http://SERVER/nagios3/” in your browser. Login with user “nagiosadmin” and the passwort you have entered during the installation.

5. Links

* http://inode.co.nz/running-nagios3-under-nginx-fastcgi

* http://library.linode.com/web-servers/nginx/perl-fastcgi/ubuntu-10.04-lucid

* http://wiki.linuxwall.info/doku.php/fr:ressources:dossiers:supervision:nagios3

* http://wiki.nginx.org/Main

* http://www.nagios.org

Comments: 0 | Read Comments | Write a Comment |

Previous Posts Next posts