Wednesday, November 30, 2011

calling two parameters from a file using bash script

Advertisements

this script explains how to call two parameters or arguments or values from a file using bash script in a for loop

file_path :  path to the file
i and j are the variables for the calling values


for i in `cut -d: -f2 file_path`
do
j=`cat file_path | grep $i | awk {'print $1'} | cut -d: -f1`
echo $i $j
done

Thursday, November 24, 2011

How to block the mails by subject in exim

Advertisements


Suppose you want to block the mails having subject job
Open the file /etc/mail/spamassassin/local.cf
And add the following lines.

header   JOB_SUBJECT Subject =~ /job/i
header   JOB_FROM    From =~ /job/i
meta     JOB_HEADER JOB_FROM && JOB_SUBJECT
score    JOB_HEADER 10.0
describe JOB_HEADER Block Mails with job in subject

save the file and restart the exim service if needed.

How to block mails by body content in exim

Advertisements

open the file /etc/mail/spamassassin/local.cf

and add the following lines.


rawbody  RULE_NAME  /CONTENT_WORD/i
score RULE_NAME 100

Restart the exim service if needed.

Tuesday, November 15, 2011

How to create a php info page

Advertisements

Go to the DocumentRoot of your domain or default DocumentRoot of your webserver.

Create a php info file as follows.
[root@server1 public_html]# cat info.php

<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
[root@server1 public_html]#

Give proper permissions
permission 644
ownership as domain owners

Now go to the browser and access as given below:
http://your_domain/info.php
or

How to enable php json on centos

Advertisements


We can enable php json using pecl. This can be used in directadmin servers also.

First we have to find the location of perl command. Using the following command.
[root@server1 /]# which pecl
/usr/local/bin/pecl

Now installing json using pecl
[root@server1 /]# /usr/local/bin/pecl install json

Testing the module
[root@server1 /]# php -ini | grep json
json
json support => enabled
json version => 1.2.1
[root@server1 /]#

Wednesday, November 9, 2011

rebuilding corrupted named.conf in cpanel

Advertisements

Sometimes we will get our named.conf corrupted. Here is the way to fix that in cpanel servers.

First of all clear the named.conf using the following command

root@cpaneltest [~]#> /etc/named.conf

Now execute the cpanel script to rebuild the named.conf
root@cpaneltest [~]#/scripts/rebuildnamedconf

Now restart the named service
root@cpaneltest [~]#/etc/init.d/named restart
Everything should be fixed now.

/usr/sbin/chkfontpath is needed by msttcorefonts-2.0-1.noarch

Advertisements


You may getting this error while installing rpms.
/usr/sbin/chkfontpath is needed by msttcorefonts-2.0-1.noarch

Eg:
[root@vps /]# rpm -ivh msttcorefonts-2.0-1.noarch.rpm
error: Failed dependencies:
        /usr/sbin/chkfontpath is needed by msttcorefonts-2.0-1.noarch

You have to install the package chkfontpath using the fowllowing command
[root@vps /]# yum  install chkfontpath

You you can install the rpm without errors.
[root@vps /]# rpm -ivh msttcorefonts-2.0-1.noarch.rpm
Preparing...                   ########################################### [100%]
   1:msttcorefonts          ########################################### [100%]
[root@vps /]#

Confirming the installation
[root@vps /]# rpm -q msttcorefonts
msttcorefonts-2.0-1
[root@vps /]#

Tuesday, November 8, 2011

Configuring nginx as proxy for apache in ubuntu

Advertisements

Install apache2 and nginx services.

In this setup we configured apache to run on port 81 and nginx on port 80

nginx configuration file is given below :


root@host ~ # vi /etc/nginx/nginx.conf
user www-data;


worker_processes  1;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
    # multi_accept on;
}
http {
    include       /etc/nginx/mime.types;
    access_log  /var/log/nginx/access.log;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
server {
        listen ip_address:80;
        server_name domain.com www.domain.com;
        location / {
        proxy_pass http://ip_address:81/;
        proxy_redirect http://ip_address:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout 150;
        proxy_send_timeout 100;
        proxy_read_timeout 100;
        proxy_buffers 4 32k;
        client_max_body_size 8m;
        client_body_buffer_size 128k;
                }
        location ~* ^.+\.(jpg|js|jpeg|png|ico|gif|txt|js|css|swf|zip|rar|avi|exe|mpg|mp3|wav|mpeg|asf|wmv)$ {
        root document_root_of_domain;
                }
        }
}

Disabling the unnecessary services in ubuntu or debian

Advertisements


We can list all the services currently running using the following command. 
#service --status-all


Eg:
root@host ~ # service --status-all
 [ ? ]  amavis
 [ + ]  apache2
 [ + ]  apparmor
 [ ? ]  atd
 [ + ]  bind9
 [ - ]  bootlogd
 [ - ]  clamav-daemon
 [ + ]  clamav-freshclam
 [ ? ]  console-setup
***********out put truncated********


To remove a service from debian startup execute the following command
#update-rc.d -f  service_name remove

Eg:

root@host ~ # update-rc.d -f atd remove
 Removing any system startup links for /etc/init.d/atd ...
root@host ~ #


In case if you want to add a service to ubuntu default runlevels execute the following command. 
#update-rc.d service_name defaults

Eg:

root@host ~ # update-rc.d proftpd defaults
 Adding system startup for /etc/init.d/proftpd ...
   /etc/rc0.d/K20proftpd -> ../init.d/proftpd
   /etc/rc1.d/K20proftpd -> ../init.d/proftpd
   /etc/rc6.d/K20proftpd -> ../init.d/proftpd
   /etc/rc2.d/S20proftpd -> ../init.d/proftpd
   /etc/rc3.d/S20proftpd -> ../init.d/proftpd
   /etc/rc4.d/S20proftpd -> ../init.d/proftpd
   /etc/rc5.d/S20proftpd -> ../init.d/proftpd
root@host ~ #

How to find the parent package of a file on Ubuntu

Advertisements


We can find the parent package of a file using following command in debian or ubuntu. 

root@host ~ # dpkg -S /usr/sbin/mysqld
percona-server-server-5.5: /usr/sbin/mysqld
root@host ~ #

For the same purpose you can use following command in centos, redbat or fedora 


root@cpaneltest [~]# rpm -qf /usr/sbin/mysqld
MySQL-server-5.0.92-0.glibc23
root@cpaneltest [~]#


How to find the parent package of a file on Ubuntu

Advertisements


We can find the parent package of a file using following command in debian or ubuntu. 

root@host ~ # dpkg -S /usr/sbin/mysqld
percona-server-server-5.5: /usr/sbin/mysqld
root@host ~ #

For the same purpose you can use following command in centos, redbat or fedora 


root@cpaneltest [~]# rpm -qf /usr/sbin/mysqld
MySQL-server-5.0.92-0.glibc23
root@cpaneltest [~]#


Saturday, November 5, 2011

Configuring the GNUpanel

Advertisements

Configuring the GNUpanel here are the steps :

1. login to your vps  as root user.

2. run these following commands to configure :
 # cd /directorio/gnupanel_lenny_ubuntu_hardy_intrepid_0.3.0_R7
# gnupanel-config.sh

3. when the configuration finished the admin interface can be located here: http://ip-publica/admin

4. the detail instruction can be found here: http://gnupanel.org/archives/category/howtos

Friday, November 4, 2011

Finding the clientid and licenseid of directadmin

Advertisements

You can find the clientid and licenseid of currently installed directadmin  from the file /usr/local/directadmin/scripts/setup.txt


[root@localhost ~]# cat /usr/local/directadmin/scripts/setup.txt
hostname=host.domain.tld
email=admin@host.domain.tld
mysql=aQGNqbDD
mysqluser=da_admin
adminname=admin
adminpass=o9uMqaIn
ns1=ns1.domain.tld
ns2=ns2.domain.tld
ip=
netmask=
uid=123
lid=4567
services=services_es50.tar.gz
[root@localhost ~]#

You can update the license manually as follows

[root@localhost ~]#cd /usr/local/directadmin/scripts 
[root@localhost ~]#./getLicense.sh 123 1234
[root@localhost ~]#service directadmin restart

Tuesday, November 1, 2011

FFmpeg installation on Centos cpanel server

Advertisements

First you have to install the following repositories for yum. [check your system architecture]


rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-5-0.1.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-nonfree-release-5-0.1.noarch.rpm

Install ffmpeg, mplayer and mencoder

yum install ffmpeg mplayer mencoder

Install ruby using cpanel script
/scripts/installruby

Install flvtool
gem install flvtool2

Install MP4Box
yum install gpac gpac-libs

Install development packages for ffmpeg
yum install ffmpeg-devel

Install ffmpeg-php
wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
tar xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
phpize
./configure
make
make install

Enabling ssl version 3 in apache

Advertisements

This post explains how to enable ssl version3 and TLS v1.0 using apache httpd webserver.

Edit the httpd.conf file and add the following lines to it.


[root@server ~]# vi /etc/httpd/conf/httpd.conf
#SSL3


<IfDefine SSL>
SSLProtocol -all +SSLv3 +TLSv1
SSLCipherSuite SSLv3:+HIGH:+MEDIUM
</IfDefine>

Now restart the httpd service.
[root@server ~]# /etc/init.d/httpd restart

Thats it.