How to Restart new Plesk

Posted by HostsVault | Posted in How-To's | Posted on 13-01-2009-05-2008

0

In older versions you just needed :

 service PSA restart ALL 

To restart Plesk, but in the latest version things has gone a little bit different now you should run this:

On Linux like OS

/etc/rc.d/init.d/psa stopall
/etc/rc.d/init.d/psa start
 

On FreeBSD

/usr/local/psa/rc.d/init.d/psa stopall
/usr/local/psa/rc.d/init.d/psa start
 
VN:F [1.9.3_1094]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

How to reduce Disk/partition IO (access time)

Posted by HostsVault | Posted in How-To's | Posted on 10-01-2009-05-2008

1

Linux has a special mount option for file systems called noatime. If this option is set for a file system in /etc/fstab, then reading accesses will no longer cause the atime information (last access time – don’t mix this up with the last modified time – if a file is changed, the modification date will still be set) that is associated with a file to be updated (in reverse this means that if noatime is not set, each read access will also result in a write operation). Therefore, using noatime can lead to significant performance gains.

Using noatime

In this example we will set noatime for the root file system “/”

vi /etc/fstab

and add noatime to the options of the / file system, e.g. like this:

proc /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/sd0 /boot ext3 defaults 0 0
/dev/sd1 none swap sw 0 0
/dev/sd2 / ext3 defaults,noatime 0 0

You don't have to reboot the system for the changes to take effect (and that's the beauty of Linux), just issue this command to apply the changes:

mount -o remount /

To check its active:

mount

You should see :

/dev/sd2 on / type ext3 (rw,noatime)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sd0 on /boot type ext3 (rw)

A Quick Note For OpenVZ VMs

OpenVZ containers (virtual machines) don't have an /etc/fstab file because the partitioning is controlled from the host system. To set noatime for a VM, you can run :

vzctl set veid --noatime yes --save

on the host system and restart the VM (replace veid with the ID of the container; for example, if the container has the ID 101, run

vzctl set 101 --noatime yes --save

and restart the container:

vzctl restart 101
VN:F [1.9.3_1094]
Rating: 8.0/10 (3 votes cast)
VN:F [1.9.3_1094]
Rating: -1 (from 1 vote)

Howto Repair Mysql Tables (*.MYI)

Posted by HostsVault | Posted in How-To's | Posted on 31-12-2008-05-2008

2

Stage 1: Checking your tables

Run myisamchk *.MYI or myisamchk -e *.MYI if you have more time. Use the -s (silent) option to suppress unnecessary information. If the mysqld server is stopped, you should use the –update-state option to tell myisamchk to mark the table as “checked.” You have to repair only those tables for which myisamchk announces an error. For such tables, proceed to Stage 2. If you get unexpected errors when checking (such as out of memory errors), or if myisamchk crashes, go to Stage 3.

Stage 2: Easy safe repair

First, try myisamchk -r -q tbl_name (-r -q means “quick recovery mode”). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed. Start repairing the next table. Otherwise, use the following procedure:

1. Make a backup of the data file before continuing. 2. Use myisamchk -r tbl_name (-r means “recovery mode”). This removes incorrect rows and deleted rows from the data file and reconstructs the index file. 3. If the preceding step fails, use myisamchk –safe-recover tbl_name. Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower).

Note: If you want a repair operation to go much faster, you should set the values of the sort_buffer_size and key_buffer_size variables each to about 25% of your available memory when running myisamchk. If you get unexpected errors when repairing (such as out of memory errors), or if myisamchk crashes, go to Stage 3.

Stage 3: Difficult repair

You should reach this stage only if the first 16KB block in the index file is destroyed or contains incorrect information, or if the index file is missing. In this case, it is necessary to create a new index file. Do so as follows:

1. Move the data file to a safe place. 2. Use the table description file to create new (empty) data and index files:

mysql db_name
SET AUTOCOMMIT=1;
TRUNCATE TABLE tbl_name;
quit

3. Copy the old data file back onto the newly created data file. (Do not just move the old file back onto the new file. You want to retain a copy in case something goes wrong.)

Go back to Stage 2. myisamchk -r -q should work. (This should not be an endless loop.) You can also use the REPAIR TABLE tbl_name USE_FRM SQL statement, which performs the whole procedure automatically. There is also no possibility of unwanted interaction between a utility and the server, because the server does all the work when you use REPAIR TABLE. See Section 12.5.2.6, “REPAIR TABLE Syntax”.

Stage 4: Very difficult repair

You should reach this stage only if the .frm description file has also crashed. That should never happen, because the description file is not changed after the table is created:

1. Restore the description file from a backup and go back to Stage 3. You can also restore the index file and go back to Stage 2. In the latter case, you should start with myisamchk -r.

2. If you do not have a backup but know exactly how the table was created, create a copy of the table in another database. Remove the new data file, and then move the .frm description and .MYI index files from the other database to your crashed database. This gives you new description and index files, but leaves the .MYD data file alone. Go back to Stage 2 and attempt to reconstruct the index file.

I tried to simplify the various commands for the most greater part of the cases. On most systems MySQL databases resides in /var/lib/mysql soYou can run this command safely inside [/var/lib/mysql :


root@server[/var/lib/mysql]# find -name ‘*.MYI’ -exec myisamchk -r {} \;
VN:F [1.9.3_1094]
Rating: 6.5/10 (2 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Howto Install ffmpeg and ffmpeg-php

Posted by HostsVault | Posted in How-To's | Posted on 31-12-2008-05-2008

0

Here is the steps to install ffmpeg and ffmpeg-php and other needed codecs.

cd /usr/src/
mkdir ffmpeg
cd ffmpeg/
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
bunzip2 essential-20061022.tar.bz2
tar xvf essential-20061022.tar
tar zxvf flvtool2_1.0.5_rc6.tgz
tar zxvf lame-3.97.tar.gz
bunzip2 ffmpeg-php-0.5.0.tbz2
tar xvf ffmpeg-php-0.5.0.tar
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
mkdir /usr/local/lib/codecs/
mv essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
yum install -y subversion
yum install -y ruby
yum install -y ncurses-devel
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd lame-3.97
./configure
make
make install
cd ..
cd libogg-1.1.3
./configure
make
make install
cd ..
cd libvorbis-1.1.2
./configure
make
make install
cd ..
cd flvtool2_1.0.5_rc6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd ..
cd mplayer/
./configure
make
make install
cd ..
cd ffmpeg
mkdir /home/tmp
export TMPDIR=/home/tmp
./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
echo '#define HAVE_LRINTF 1' >> config.h
make
make install
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
cd ..
cd ffmpeg-php-0.5.0
phpize
./configure
make
make install
### for cpanel insert in /usr/lib/php.ini
### for other system insert in /etc/php.ini
echo 'extension=ffmpeg.so' >> /usr/lib/php.ini
service httpd restart
php -r 'phpinfo();' | grep ffmpeg
VN:F [1.9.3_1094]
Rating: 9.0/10 (2 votes cast)
VN:F [1.9.3_1094]
Rating: -2 (from 2 votes)

Rebooting a server that wont reboot

Posted by HostsVault | Posted in How-To's | Posted on 05-09-2008-05-2008

0

Have you ever faced this kind of problem where you couldn’t even reboot your sever because it had a HDD error and you cant access the reboot or shutdown commands and they showed this kind of errors :

[root@hostsvault ~]# reboot
bash: /sbin/reboot: Input/output error
[root@hostsvault ~]# shutdown -r now
bash: /sbin/shutdown: Input/output error

Obviously, there is a problem with your drive. These commands are failing because the kernel is unable to access the /sbin/reboot and /sbin/shutdown binaries from the disk so that it can execute them.

A fsck on the next boot might be able to correct whatever is wrong with the disk, but first you need to get the system to reboot. If your machine is located at a managed hosting provider then you could submit a reboot ticket, but you’ll have to wait for someone to take responsibility.

Wouldn’t it be nice if there was a way to ask the kernel to reboot without needing to access the failing drive? Well, there is a way, and it is remarkably simple.

The “magic SysRq key” provides a way to send commands directly to the kernel through the /proc filesystem. It is enabled via a kernel compile time option, CONFIG_MAGIC_SYSRQ, which seems to be standard on most distributions. First you must activate the magic SysRq option:

echo 1 > /proc/sys/kernel/sysrq

When you are ready to reboot the machine simply run the following:

echo b > /proc/sysrq-trigger

 

This does not attempt to unmount or sync filesystems, so it should only be used when absolutely necessary, but if your drive is already failing then that may not be a concern.
In addition to rebooting the system the sysrq trick can be used to dump memory information to the console, sync all filesystems, remount all filesystems in read-only mode, send SIGTERM or SIGKILL to all processes except init, or power off the machine entirely, among other things.

Also, instead of echoing into /proc/sys/kernel/sysrq each time you can activate the magic SysRq key at system boot time using sysctl, where supported:

echo "kernel.sysrq = 1" >> /etc/sysctl.conf

 

If you would like to learn more about magic SysRq you can read the sysrq.txt file in the kernel documentation.

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: -1 (from 1 vote)

How to Configure BIND to Listen on certain IP address

Posted by HostsVault | Posted in How-To's | Posted on 25-08-2008-05-2008

0

Just thought of sharing this if anyone is interested in :

You can use the “listen-on ” directive for this by default its set to :

listen-on { any; };

Here is how it would look like to set it to listen to a certain ip

options
{
        listen-on { 208.43.195.240; };
        directory "/var/named"; // the default
        dump-file               "data/cache_dump.db";
        statistics-file         "data/named_stats.txt";
        /* memstatistics-file     "data/named_mem_stats.txt"; */
        dnssec-enable yes;
        recursion no;
        allow-notify { 208.43.195.240; 208.43.195.241; };
};
VN:F [1.9.3_1094]
Rating: 1.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

How to install APF

Posted by HostsVault | Posted in How-To's | Posted on 18-08-2008-05-2008

1

What is APF ?

Advanced Policy Firewall (APF) is an iptables(netfilter) based firewall system designed around the essential needs of today’s Internet deployed servers and the unique needs of custom deployed Linux installations. The configuration of APF is designed to be very informative and present the user with an easy to follow process, from top to bottom of the configuration file. The management of APF on a day-to-day basis is conducted from the command line with the ‘apf’ command, which includes detailed usage information and all the features one would expect from a current and forward thinking firewall solution

We are going to show you in this tutorial how to install it on your server.

* You need root access to install this

* The configured Ports here are for Cpanel servers.

cd /usr/src/
wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz
tar -xvzf apf-current.tar.gz
cd apf-0.9.6*
./install.sh

You should get responses similar to that :

Installation Details:
Install path:         /etc/apf/
Config path:          /etc/apf/conf.apf
Executable path:      /usr/local/sbin/apf
AntiDos install path: /etc/apf/ad/
AntiDos config path:  /etc/apf/ad/conf.antidos
DShield Client Parser:  /etc/apf/extras/dshield/

Other Details:
Listening TCP ports: 1,21,22,25,53,80,110,111,143,443,465,993,995,2082
,2083,2086,2087,2095,2096,3306
Listening UDP ports: 53,55880
Note: These ports are not auto-configured; they are simply presented for information purposes. You must manually configure all port options.</pre>
<p>Now configure APF :</p>
<pre lang="bash">pico  /etc/apf/conf.apf</pre>
<pre lang="bash">Change USE_DS="0"
to USE_DS="1"

This uses a list of networks that have exhibited suspicious activity captured from DShield.org

Now lets configure the ports to block/open

configure IG_TCP_CPORTS and IG_UDP_CPORTS (Incoming TCP/UDP connections)

IG_TCP_CPORTS="20,21,22,25,26,37,53,80,110,143,443,465,783,993,995,2077,2078,2082
,2083,2086,2087,2095,2096,3306"
IG_UDP_CPORTS="21,37,53,873"

configure EG_TCP_CPORTS and EG_UDP_CPORTS (Outgoing TCP/UDP connections)

EGF="1"
EG_TCP_CPORTS="21,22,25,37,43,53,80,443,873,2082,2083,2086
,2087,2089,3306"
EG_UDP_CPORTS="20,21,37,53,123,873"

Save your changes and exit the editor and then restart the firewall :

/etc/init.d/apf restart
OR
apf -r

Here is a list of other possible commands :

usage ./apf [OPTION]
-s|--start ......................... load firewall policies
-r|--restart ....................... flush & load firewall
-f|--flush|--stop .................. flush firewall
-l|--list .......................... list chain rules
-st|--status ....................... firewall status
-a HOST CMT|--allow HOST COMMENT ... add host (IP/FQDN) to allow_hosts.rules
and immediately load new rule into firewall
-d HOST CMT|--deny HOST COMMENT .... add host (IP/FQDN) to deny_hosts.rules
and immediately load new rule into firewall
After checking everything is fine and nothing is messed you should change
APF from running in development mode (default) as it restarts itself
every 5 minutes through cron.

 

pico /etc/apf/conf.apf

 

Change: DEVM=”1″
To: DEVM=”0″

Exit and restart the firewall.

Enjoy

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

How to install Favicon on your site

Posted by HostsVault | Posted in How-To's | Posted on 13-08-2008-05-2008

0

How Do You Make Favicon.ico Files?
Create a file that is 16 x 16 pixels with 16 colors. Then use a program like http://irfanview.com, or http://gimp.org to save it as an ico ( icon ) file with the name “favicon.ico”. You can also visit Favicon UK. They have a free online icon maker that sends your favicon.ico file to you via email.
Or even generate it online using http://www.favicongenerator.com/

Note, you can’t simply save a graphic file with .ico extension and hope it works. It must be a favicon.ico format.

How Do You Install Favicons?
Name the file favicon.ico ( must be a real icon file ), and upload it into your web directory in the root of your html files. For example you would put it here: http://www.domain.com/favicon.ico
Also add this line in your html head section :

If anyone bookmarks your web page now it will list that favicon will show up in their favorites and when they return to your website.

If you want them to have the same favicon on every page you’ll have to add some html code into your headers

What about Apache MIME types and Favicons?
By default your httpd.conf file should be set with “AddType image/x-icon .ico”, but if it isn’t, you need to get your server admin to add that line.

VN:F [1.9.3_1094]
Rating: 7.5/10 (2 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

How-to install mytop

Posted by HostsVault | Posted in How-To's | Posted on 13-08-2008-05-2008

0

MySQL is a widely used multi-threaded, multi-user RDBMS in the Linux world its intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.

However sometimes specially in the shared environment its the sole purpose of overload in the server

Here is a how-to to install mytop (top version for MySQL) which will help you identify a user query that’s taking long time or user opening to much connections to the server so it can help you maintain stability on your server.

First install TermReadKey:

cd /usr/local/src
wget http://search.cpan.org/CPAN/authors/id/J/JS/JSTOWE/TermReadKey-2.30.tar.gz
tar -zxf TermReadKey-2.30.tar.gz
cd TermRead*
perl Makefile.PL
make test
make
make install
cd ..

Then install DBI:

wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.48.tar.gz
tar -zxf DBI-1.48.tar.gz
cd DBI*
perl Makefile.PL
make test
make
make install
cd ..

And finally our beloved MyTop

wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.4.tar.gz
tar -zxf mytop-1.4.tar.gz
cd mytop*
perl Makefile.PL
make test
make
make install

Then by running mytop it will bring up a page similar to this :

mytop screenshot
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Set Up Postfix DKIM With dkim-milter

Posted by HostsVault | Posted in How-To's | Posted on 12-08-2008-05-2008

0

DKIM is an authentication framework which stores public-keys in DNS and digitally signs emails on a domain basis.

rpm --nodeps http://www.c-corp.net/linux/centos/5/general/RPMS/i386/dkim-milter-2.2.1-1.i386.rpm
mkdir /etc/dkim-milter
chown dkim-milt.dkim-milt /etc/dkim-milter
chmod 700 /etc/dkim-milter
chgrp postfix /var/run/dkim-milter
chmod 770 /var/run/dkim-milter

Generate The Keys

Enter the following command to generate your private key:

openssl genrsa -out rsa.private 768

Enter the following command to generate your public key:

openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM

mv rsa.private /etc/dkim-milter/_default.key.pem

Edit the file /etc/sysconfig/dkim-milter

USER="dkim-milt"
PORT=local:/var/run/dkim-milter/dkim.sock
SIGNING_DOMAIN=""
SELECTOR_NAME="default"
KEYFILE="/etc/dkim-milter/${SIGNING_DOMAIN}_${SELECTOR_NAME}.key.pem"
SIGNER=yes
VERIFIER=yes
CANON=simple
SIGALG=rsa-sha1
REJECTION="bad=r,dns=t,int=t,no=a,miss=r"
EXTRA_ARGS="-h -l -D"

Restart milter service

service dkim-milter start

Edit /etc/postfix/main.cf:
smtpd_milters = unix:/var/run/dkim-milter/dkim.sock
non_smtpd_milters = unix:/var/run/dkim-milter/dkim.sock

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)