Articles in the ‘Linux’ Category

Create a repository in XEN server

Thursday, November 24th, 2011

1. Be sure that you have the path created. In the above example it’s /var/opt/xen/iso_import.
2. Copy the ISO images directly in this folder (Centos ISO images works fine).
3. Use the following command to create a local repository in XEN

xe sr-create name-label="S5 Repository" type=iso device-config:location=/var/opt/xen/iso_import/ device-config:legacy_mode=true content-type=iso

4. In XENCENTER use the OTher media install to create VMs.

Ignore folder in SVN

Thursday, October 6th, 2011

Use this:

DIRNAME
-CHILD1
-CHILD2

DIRNAME> svn propset svn:ignore CHILD1 .

attention! You have to be inside DIRNAME.

Error: Missing Dependency: perl-String-CRC32

Tuesday, September 13th, 2011

Fixing this error:

--> Missing Dependency: perl(String::CRC32) is needed by package lftp-3.7.11-4.el5_5.3.x86_64 (base)
Error: Missing Dependency: perl-String-CRC32 is needed by package lftp-3.7.11-4.el5_5.3.x86_64 (base)
Error: Missing Dependency: perl(String::CRC32) is needed by package lftp-3.7.11-4.el5_5.3.x86_64 (base)

You just need to install the Perl module. To do this, login to SSH as root and type:

perl -e shell -MCPAN

If it asks you to set it up, just type “no” and it’ll use the defaults.

cpan> install String::CRC32
cpan> exit

How to check SDA drive speed in Linux?

Sunday, July 31st, 2011

Use the following command:

hdparm -tT /dev/sda1

A good test result is this one:
# hdparm -tT /dev/sda1

/dev/sda1:
Timing cached reads: 21416 MB in 1.99 seconds = 10785.03 MB/sec
Timing buffered disk reads: 106 MB in 3.01 seconds = 35.16 MB/sec

Convert MYSQL tables to INNODB script

Tuesday, July 12th, 2011

If you want to convert MYSQL tables to INNODB use the following script:

mysql -u root -p -e "SHOW TABLES IN DATABASE-NAME;" | tail -n +2 | xargs -I '{}' echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql
and then run:
perl -p -i -e 's/(search_[a-z_]+ ENGINE=)INNODB/\1MYISAM/g' alter_table.sql

Replace “DATABASE-NAME” with your database name. You also need root access (preferably).

Using eAccelerator with cPanel and FASTCGI

Tuesday, March 8th, 2011

If you want to use eAccelerator with cPanel and Apache, disable suPHP through easyApache or you will have “Cached Scripts 0″ in control panel of eAccelerator.

Same rule applies with APC.

APC fails to install via WHM in cPanel

Monday, March 7th, 2011

If you try to install APC via WHM in cpanel and you get:

cpanel /usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

then you need to install PCRE-devel.

Follow the next step

Go to / and type

yum install pcre-devel

Now, go back to WHM and try to install again PCRE.

NGINX with Apache and cPanel

Thursday, October 7th, 2010

In this setup, NGinx will be integrated with Apache (under cPanel) and used to server the static files.

Run SSH console

cd /root
wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
tar xvzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
cd /root
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make
make install
cd /root
tar xvzf nginx-0.8.52.tar.gz
cd nginx-0.8.52
./configure --with-http_ssl_module --with-http_realip_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module
make
make install

-Login to WHM and look for the following route:
Main >> Service Configuration >> Apache Setup > Include Editor > Pre Main Include

- Add the following configuration and save, LIST_OF_YOUR_IPS changing the IP you occupy in your site:

LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 LIST_OF_YOUR_IPS
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings
# allows to have the same hostnames as in the "real"
# configuration for the forwarding Apache
RPAFheader X-Real-IP
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests

- Change the apache port to 81 (tweak settings)
Open whm – tweak settings and find 0.0.0.0:80 and change it to 0.0.0.0.:81

- Run SSH console

/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/scripts/rebuildhttpdconf
httpd restart

create automated nginx virtual host creator

touch nginx.sh
chmod 755 nginx.sh
nano nginx.sh

and add the content from here.

then run it

./nginx.sh

-Check the configuration

/usr/local/nginx/sbin/nginx -t

Until now only the managing nginx connections, but is not serving static content. For the latter you must edit the following file:

nano /usr/local/nginx/conf/vhost.conf

-Remove the 3 # signs of the following lines:

#location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
# root /home/myweb/public_html;
#}

so the final configuration will looks like

location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
root /home/myweb/public_html;
}

Configure nginx startup scripts

touch /etc/init.d/nginx
chmod +x /etc/init.d/nginx
nano /etc/init.d/nginx

and add the following content from here.

Now, let’s test the scripts:

/etc/init.d/nginx restart
ps aux | grep nginx

and last, add nginx as autostart deamon

/sbin/chkconfig nginx on
/sbin/chkconfig --list | grep nginx

How to install Memcache in cPanel?

Tuesday, September 28th, 2010

Take a coffee, this is going to be a long process.

Step 1: Configure Apache
Login to cPanel and start EasyApache. At the Exhaustive Option List choose Memcache. Compile Apache & Restart it.

Step 2: Memcache requires LibEvent
LibEvent can be downloaded from Monkey.org. Download the last 1.4.x available version.

wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
tar xvfz libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure; make; make install

Step 3: Register LibEvent

nano /etc/ld.so.conf.d/libevent-i386.conf

Add the following text inside:

/usr/local/lib/

and at last, run:

ldconfig

Step 4: Compile and install Memcache (deamon)
Now you can install Memcache with the last version from their site.

wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xvfz memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure; make; make install

Step 5: Install PHP extension for Memcache
Normall, you should be able to do this from cPanel but i get a compiling error. So here is an alternative:

wget http://pecl.php.net/get/memcache-3.0.3.tgz
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
phpize
./configure
make
make install

Edit /usr/local/lib/php.ini

nano /usr/local/lib/php.ini

and copy paste at the end of the file:

extension=memcache.so

and at last, restart Apache:

service httpd restart

Step 6: Run Memcache as a deamon on the startup files

nano /etc/memcached.conf

and add inside:

#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1

create the startup files

touch /etc/init.d/memcached
chmod +x /etc/init.d/memcached

and add inside it

nano /etc/init.d/memcached

the following text

then run:

touch /usr/local/bin/start-memcached
chmod +x /usr/local/bin/start-memcached

and add inside the following text

Now, let’s test the scripts:

/etc/init.d/memcached restart

and review if the conf file is parsed ok:

ps aux | grep memcached

and last, add memcached as autostart deamon

/sbin/chkconfig memcached on
/sbin/chkconfig --list | grep memcached

it should output:

memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Step 7: Test Memcache in PHP
Create the memcache.php file and add this text
You should have in the browser:

String to store in memcached.

How to unpack .tar.gz?

Thursday, July 15th, 2010

To unpack a tar archive ending in .tar.gz use the following command:


tar -xzf archive.tar.gz