Category: Redhat

            • Install ruby on cPanel

              Under cPanel 11 you can install Ruby by running /scripts/installruby. This will install both ruby and rubygems.

              root@main [~]# ruby -v
              ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]

              root@main [~]# gem list

              *** LOCAL GEMS ***

              actionmailer (2.3.11)
              actionpack (2.3.11)
              activerecord (2.3.11)
              activeresource (2.3.11)
              activesupport (2.3.11)
              cgi_multipart_eof_fix (2.5.0)
              daemons (1.1.4)
              fastthread (1.0.7)
              gem_plugin (0.2.3)
              mongrel (1.1.5)
              rack (1.1.2)
              rails (2.3.11)
              rake (0.9.2)
              rubygems-update (1.8.5)

            • Yum and RPM Tricks

              This applies to Centos 5.6 but most likely it works on any rpm based distro.

              1. It happened many times to mess the permissions of a file and services not to work properly. In order to get fixed I run :

              rpm -qf /path/to/file

              rpm -ql Lists all files from a package.

              This should show the package that contains the modified file. Then I run :

              rpm --setperms

              Also this command should show a list of modified files within a package:

              rpm -V

              2. To view the Changelog:

              rpm -q --changelog | less

              3. View package based on repo:

              rpm -qa release="*rf*"

              4. Extract just one File:

              rpm2cpio logrotate-1.0-1.i386.rpm |cpio -ivd etc/logrotate.conf

              5. Query Package Install Order and Dates

              rpm -qa --last >~/RPMS_by_Install_Date

              6. Query Available Packages from a Repo

            • Using mod_proxy in Plesk to redirect to a different site

              Scenario:

              Site1 : www.site.com
              Site2 : shop.site2.com

              The idea is to make a proxy redirect so if I access www.site.com/shop to be redirected to shop.site2.com and keep the URL in the browser.
              This can be done either by using mod_rewrite (if both sites are on the same server) or by using mod_proxy. In my case I had to do this on a Plesk server.

              I’ve created in /var/www/vhosts/site.com/conf a file called vhost.conf that contains:

              ProxyRequests off
              Order deny,allow
              Allow from all

              ProxyPass /shop http://shop.site2.com
              ProxyPassReverse /shop http://shop.site2.com
              SetEnv force-proxy-request-1.0 1
              SetEnv proxy-nokeepalive 1


              Order allow,deny
              Allow from all

              Then I ran:

              /usr/local/psa/admin/bin/websrvmng -a -v

              Verify httpd.include to see if there is any Include directive.

              Now if you go to www.site.com/shop/ you should be redirected to shop.site2.com. Notice the trailing slash after (../shop/). That needs to be there otherwise it won’t load the images properly.

              This can be fixed by adding in vhost.conf a Rewrite rule like:
              RewriteEngine on
              RewriteRule ^/shop$ /shop/ [R]

            • Update php in Plesk

              Run:

              Download http://www.atomicorp.com/installers/atomic.sh
              sh atomic.sh
              yum update php

            • Install Dante socks proxy

              Dante socks install :

              Download Dante from : ftp://ftp.inet.no/pub/socks/dante-1.2.0.tar.gz

              tar zxvf dante-1.2.0.tar.gz
              cd dante-1.2.0
              yum install gcc make
              ./configure
              make -j4
              make install

              ifconfig -a |  grep inet | awk ‘{print $2}’ | awk -F ‘:’ ‘{print $2}’ | grep -v 127.0.0.1 >  /root/ips

              for i in `cat ips` ;do echo “internal: $i port = 6060″ >> /root/sockd.conf ;done

              Example of sockd.conf :

              logoutput: stderr
              method: username none
              external: externalIPtouse
              client pass {
              from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
              }
              pass {
              from: 0.0.0.0/0 to: 0.0.0.0/0
              method: username
              protocol: tcp udp
              }

              Launch using :

              sockd -f /root/sockd.conf -d

            • How much disk space a database takes?

              Login to mysql and run :

              select SUM(data_length) + SUM(index_length) as size from information_schema.tables where table_schema = 'your_database';

            • Move Windows with screen
              • change to the window you want to move
              • type (for example) ^a:number 1
              • ^x is the host key (usually ^a on most machines)  (CTRL+A)
              • :number (typed literally) is the command
              • 1 the number to move the current screen to