Wednesday, November 9, 2011

rebuilding corrupted named.conf in cpanel

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


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

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


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


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


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 [~]#