Set up of an OpenSuse 11.1 container on Virtuozzo 4.6

Problem:
Set up of an OpenSuse container on Virtuozzo 4.6 is broken…


Solution:

When trying to install the container the usual way, you get these error messages:
mkdir suse
cd suse
wget http://downloads.swsoft.com/cgi-bin/getfile.pl/suse/11.1/x86_64/suse-11.1-x86_64-ez-4.0.0-6.swsoft.noarch.rpm
rpm -ihv *
vzpkg create cache suse-11.1-x86_64
Creation OS template cache for suse-11.1-x86_64 template
Error: URL $SUSE_SERVER/download/suse-11.1 contents undefined variable
You can define this variable in /etc/vztt/url.map.
See Virtuozzo Installation Guide for more details.

So we set in /etc/vztt/url.map the variable
$SUSE_SERVER http://download.opensuse.org

But we still get an error:
Creation OS template cache for suse-11.1-x86_64 template
Loading "rpm2vzrpm" plugin
Cleaning up xml metadata
0 metadata files removed
Loading "rpm2vzrpm" plugin
Making cache files for all metadata files.
This may take a while depending on the speed of this computer
Setting up repositories
http://download.opensuse.org/distribution/11.1/repo/oss/suse/repodata/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Cannot open/read repomd.xml file for repository: base0
failure: repodata/repomd.xml from base0: [Errno 256] No more mirrors to try.
Error: failure: repodata/repomd.xml from base0: [Errno 256] No more mirrors to try.
Error: /usr/share/vzyum/bin/yum failed, exitcode=1

We go to
cd /vz/template/suse/11.1/x86_64/config/os/default/

and edit the repositories file:
$SUSE_SERVER/distribution/11.1/repo/oss/suse/

and try another vzpkg create cache suse-11.1-x86_64:
yes, better luck this time:
...
Finished.
OS template suse-11.1-x86_64 cache was created

Virtuozzo 4.6 does not create VE 1 at installation time

Problem:
After installing the latest Virtuozzo Software (V 4.6) there is no VE 1 and the hardware node cannot be accessed by PMC or similiar tools.


Solution:

From V4.6 on you need to install PVA (Parallels Virtual Automation) additonally for having a VE1.
So you first install Virtuozzo:

./vzinstall-linux-i386.bin install

Then you need to supply a valid license:

echo "BLABLA-YOUR-LICENSE" | vzlicload -i

Finally you can try to install PVA:

./pva-setup-deploy.x86_64

which gave following error:

Dependency check failed:
libapr-1.so.0()(64bit) is needed by httpd-2.2.3-6.el5.centos.1.x86_64
libaprutil-1.so.0()(64bit) is needed by httpd-2.2.3-6.el5.centos.1.x86_64

(I am running OS Centos 5.6)
Tried my luck with

yum install httpd

and again with

./pva-setup-deploy.x86_64 install

and this time everything went smoothly.

Find spamming website on shared server

Problem:
Your shared server is misused for spamming using some php script. Since there are hundreds of websites or domains on your server it is not easy to find out which domain or which script the culprit is.


Solution:
Write a wrapper script:

Find the active sendmail “path” in php.ini:

grep sendmail_path /etc/php.ini

This is usually something like:

sendmail_path = /usr/sbin/sendmail -t -i

Write a new shell script /usr/local/sbin/sendmail_php.sh:

#!/bin/bash
logger php_mail: dir=${PWD}
/usr/sbin/sendmail -t -i $*

Change /etc/php.ini accordingly:

sendmail_path = /usr/local/sbin/sendmail_php.sh

Restart your webserver.

Now when some php form is using mail() you will see following entry in your server logs:

May 3 11:29:58 www42 logger: php_mail: dir=/var/www/vhosts/example.com/httpdocs/guestbook

Copy column in sql

Problem:
Copy the content of one column of a sql table into another column.


Solution:

both columns in same table:

update table1 set column2 = column1

both columns in different tables:

update table2 set column2 = (select column1 from table1)

How to test if mod_rewrite is enabled and working

Problem:
Many CMS and Blogs need mod_rewrite. However the usual user is not able to debug the problem if the pre-configured .htaccess is not working as expected.


Solution:
Write a simple .htaccess to find out if mod_rewrite is even working for your root webdirectory: Create a file .htaccess with followig content:

RewriteEngine On
RewriteRule ^i1.html$ /i2.html

Create two more testfiles:
echo "1" >i1.html
echo "2" >i2.html

If you fire up your browser with
http://yourdomain/i1.html
and you see “1” mod_rewrite is not working. If you see “2” then mod_rewrite is working fine and you do not have to bugger your hoster to check if mod_rewrite ist doing its job 😉