Categories

Monday, 24 March 2014

/etc/rc.local not running on the boot

Hi,

   /etc/rc.local is the file which runs once the system boots up. If we need to run few commands immediately once the system starts up, we can do it by adding those commands in /etc/rc.local.

Last week I faced an issue in which the commands inside the rc.local was not working, once the system boot.  I tried starting and stopping the systems so many times and tried to change the settings of /etc/rc.local, but still it was not working.  Then I read in one of the Centos Forums that it was some issue with the first boot.

In my machine firstboot got hanged and init was not able to execute the content inside /etc/rc.local. Below is the steps to resolve it

check to see if firstboot is still running and kill it:


ps ax |grep firstboot
killall firstboot


This will kill the first boot .

Then switch the firstboot permenantly using chkconfig

chkconfig firstboot off


The first boot issue was caused by some of the software installations which may confuse the firstboot.

Regards
Syamkumar.M
 

Tuesday, 18 March 2014

How to change ulimit values permanently for a user in Centos

Hi,

ulimit is the parameter which defines the limits a process can use on a linux system.  It will provide control over the resources a user or a process in a shell can use.  You can list the current setting of ulimit values by login as your user and type the following commands

# ulimit -Hn
# ulimit -Sn


Default values should be 4096 and 1024 respectively.
 

So it will also determine the number of open files a user can open or edit. For increasing the ulimit, you need to change those paramentes in a configuration file called

/etc/security/limits.conf

If I need to change the ulimit value for my user on  a linux system. Then you should login to machine as root.

Open the above file in editor and then add the following content to it.

syam        soft nofile 9000
syam        hard nofile 65000



Now you should see the changes to the ulimit value for a user when you switch user from the root. But still the limit won't get reflected when user login as ssh with the password. We need to add the following steps to get the changes reflected for the user upon ssh login as user .


  1. In /etc/pam.d/sshd added the line
session required pam_limits.so
  1. In /etc/pam.d/login added the line
session required pam_limits.so
  1. In /etc/ssh/sshd_config added
UsePAM yes

Now restart the sshd service

4. /etc/init.d/sshd restart

Now the ulimit values will be changed permenantly and you can see the values once you ssh into the machine as user.


ulimit -Hn
65000

ulimit -Sn

9000

Regards
Syamkumar.M




Tuesday, 11 March 2014

How to Delete a line from gz file having huge size

Hi,

We got a task to delete a specific line from a 6Gb gzip file. Below is the steps followed to delete the line.

1)Use zgrep to search through the gzip files

zgrep is used to search a line or pattern from the gzipped file. The output will be same as that of grep command on a normal file. Here we use the command as below. There is a specific pattern on that line through which we need to find the line number and then delete the line from that file using sed.

zgrep -in pattern test1.gz

2)From the above command we got the line number which we need to delete. It is 5344402. Then we need to use sed command to delete line on that line number. But we can't use sed on a gzipped file. So we need to unzip the file

unzip test.gzsya

3)Now we can use sed command to delete that line from the test file

sed -i '5344402d' test

Above command will delete the line on that line number of the file.

4)Again zip the file

zip test






Thats all
Thanks

Monday, 3 March 2014

Switch off redirection from http to https in DirectAdmin

Hi,

Below is the steps to disable redirection from http to https in the direct admin Login page. Default Direct admin Login URL is http://domainname:2222, where 2222 is the port used by Direct admin.

The DirectAdmin configuration file is

/usr/local/directadmin/conf/directadmin.conf

Open it in a text editor like vi to view its content

It contains all the default configuration for the directadmin like port and ssl.

Search for ssl in the file

SSL=1
cacert=/usr/local/directadmin/conf/cacert.pem
cakey=/usr/local/directadmin/conf/cakey.pem


You will get the result as above which contains certificate file location for the self signed certificate the directadmin is using.

You can turn the ssl off so that it will no longer redirect from http to https.

 SSL=0

Save the file and exit

Similarly if you need to change another port for directadmin Admin url you can change it in the above  configuration file.


Regards
Syamkumar.M




Thursday, 27 February 2014

ImageMagic Installation in plesk Centos


Hi,

Below is the steps to install ImageMagic on  plesk server.

1)Install ImageMagic using yum

yum install ImageMagic

2)Also Install ImageMagic-devel package

yum install ImageMagick-devel

3)For compiling ImageMagic with php, we need the package called php-pear

yum install php-pear

4)Now compile ImageMagic with php using pecl

pecl install imagick

For the above command to work, server need to have gcc compiler installed.

Some times you will get the error as sh: phpize: command not found

 To fix that error you need to install php5-devel package using the command

yum install php-devel

5)Now the extension module for imagick.so will be created under the php modules directory usually under /usr/lib/php/modules/

So we need to add the extension to php.ini

find out the location of php.ini on the server using the command

php -i | grep php.ini

default location should be /etc/php.ini

vi /etc/php.ini

open it in a editor and add the following line under “extension_dir” directive

extension = “imagick.so”

6)Save file and restart apache.

ImageMagic should be installed now.  The path of the convert for the ImageMagic should be /usr/bin/convert.


Thanks
Syamkumar.M

Monday, 24 February 2014

Fix Sungrid Engine state 'E' (error)

Hi All,

I got an error state named E on some of the nodes running sun grid engine. The error message is getting while I issue the command

qstat -f 

queuename                      qtype resv/used/tot. load_avg arch          states
---------------------------------------------------------------------------------
m1.large@machine1.com BIP   0/0/1          -NA-     lx26-amd64    au
---------------------------------------------------------------------------------
m1.large@machine2.com BIP   0/0/1          -NA-     lx26-amd64    au
---------------------------------------------------------------------------------
m1.large@machine3.com BIP   0/0/1          0.05   lx26-amd64    E
---------------------------------------------------------------------------------
m1.large@machine4.com BIP   0/0/1          -NA-     lx26-amd64    au
---------------------------------------------------------------------------------



As shown above you can see that the machine3 is in E state. On the sungrid engine documentation E state  is an error state.



You will get the exact reason for this error state by issuing the command

qstat -f -explain E

  The E error state will not clear till the node is rebooted or restarting the grid engine. 

Because of this error, no job will hook in to that node and job will be in queue wait state.

Once you resolved the issues related to that node, you can issue the command 

# qmod -c '*'

This will clear the E state of the node and now job will hook into it.

Cheers
Syamkumar.M


Sunday, 23 February 2014

Steps to Migrate Wordpress websites in Linux

Hi,

In this post, I am explaining the steps to migrate a wordpress website from one hosting space to another.

Wordpress is a popular blogging software now adays and is used in many of the popular websites. It was completely based on  mysql and php. The key configuration file for the wordpress is wp-config.php where the wordpress stores the database details.

Typical configuration details of mysql in wp-config.php is like below


// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'skm_wp717');

/** MySQL database username */
define('DB_USER', 'skm_wp717');

/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

We should specify a database with a db user with full privileges to the database. Also need to specify the database password of the DB user.


Here I only describe the steps needed to migrate the wordpress website

1)First login to your wordpress website document root(for a cpanel it will be /home/user/public_html). And open the configuration file wp-config.php. Note down the database name, username, password from it.

2)Take a backup of the database you got from the configuration file wp-config.php.

If you have root access to the server, then you can create a database backup using mysql dump

mysqldump -u root -pdbpassword skm_wp717 > skm_wp717.sql

This will generate the mysql backup in sql format. 

Also you can export the backup of the database from the phpmyadmin.

3)Now you need to copy the data from the existing server to a new server.  I assume you already know the document root where the database files exists for the wordpress site. So you can eithere use scp or rsync to copy the files from here to there. You can also use the FTP as well.

scp example command for the transfer

scp -r root@servername:/home/user/public_html root@remoteserver:/home/newuser/public_html

Also copy the database to the new server using scp or rsync or ftp

scp root@servername:/home/user/skm_wp717.sql root@remoteserver:/home/


4)Now the data and mysql has been migrated.  You need to check if the permission for the files we transfered are correct with respect to the user in the new server. If not you need to change them manually

That is for changing the owner ship and group of the files in the new server .

cd /home/user
chown -R newuser:newuser public_html

if all the files need to have 644 permission , you can use the command find to change the permission of files to 644 and directories to 755.

Note: the below command is for cpanel users , as cpanel files need to have 644 permission for files and 755 permission for directories
cd public_html
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 { } \;

5)Now create a database (Eithere you can use the same name or another). If you have different name . then you need to change it in the wp-config.php

Also create a database user with password and grant all previlages to the user on that database.

6)Now restore the database tables from the backup sql file to the new database we had created.

mysql -u root -ppassword newdatabase < skm_wp717.sql

Once it completes you have all the database data on your new db.

7)Open wp-config.php and change the values to the new one on it. Modify database name , user and password to the new one if it is different from the old server. If you have created the db, user and password same as that of the old server, you can skipp this step, but need to cross check the wp-config.php

8)Open your website with the new configurations from the new server.  You can do it by specifying the new ip with the website name in /etc/hosts file in your linux system

open /etc/hosts

ip websitename


If every thing is correct, then the wordpress page will load fine.

Cheers
Syamkumar.M





Ad