Thursday, June 9, 2016

ejabberd : No other options except virtualhosts in admin

ejabberd : All links missing, partial admin appears

sudo nano /etc/ejabberd/ejabberd.cfg


Find lines
{acl, admin, {user, "", "localhost"}}.
%% Hostname
{hosts, ["localhost"]}.


and replace it with


{acl, admin, {user, "admin", "localhost"}}.
%% Hostname
{hosts, ["localhost"]}.




Restart ejabberd

Friday, May 6, 2016

ERROR: S3 error: 400 (InvalidRequest): The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

Solution :
Your s3cmd has older version, you need to upgrade it. Download latest one and use the file everywhere.
https://sourceforge.net/projects/s3tools/files/s3cmd/1.6.1/
I faced this problem on 1.1 version of s3cmd, I downloaded latest and got 1.6. After that I did not get the error.


How to use the downloaded folder.
1) Extract the folder and open it.
2) Now run your s3cmd command using this downloaded folder.
 /home/ubuntu/s3cmd-1.6.1/s3cmd ls s3://

/home/ubuntu/s3cmd-1.6.1/s3cmd -c /home/ubuntu/.s3cfg put /tmp/file.sql s3://bucketname


Server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

There are three modules related to this settings. 
prefork, worker and event

First find which module is activated using

a2query -M

Now change its conf file in mods-available. 

In following case, prefork is enabled, so make changes in mpm_prefork.conf

Open file mpm_prefork.conf and increase the MaxRequestWorkers settings according to your RAM.

MaxRequestWorkers
A simple calculation for MaxRequestWorkers would be: 

(Total Memory – Critical Services Memory) / Size Per Apache process

In this case the server has 3400Mb of memory allocated, 

250Mb used by mySQL and each Apache thread averages about 30Mb. 
MaxRequestWorkers = (3400– 250) / 30
therefore MaxRequestWorkers = 105

Restart Apache. Check here too.

Cannot allocate memory: fork: Unable to fork new process in ubuntu

There are three modules related to this settings. 
prefork, worker and event

First find which module is activated using

a2query -M

Now change its conf file in mods-available. 

In following case, prefork is enabled, so make changes in mpm_prefork.conf

MaxConnectionsPerChild
If MaxConnectionsPerChild is 0, then the process will never expire.
Setting MaxConnectionsPerChild to a non-zero value limits the amount of memory that process can consume by (accidental) memory leakage.

MaxRequestWorkers
A simple calculation for MaxRequestWorkers would be: 

(Total Memory – Critical Services Memory) / Size Per Apache process

In this case the server has 3400Mb of memory allocated, 

250Mb used by mySQL and each Apache thread averages about 30Mb. 
MaxRequestWorkers = (3400– 250) / 30
therefore MaxRequestWorkers = 105

/etc/apache2/mods-available/mpm_prefork.conf
 <ifmodule mpm_prefork_module>   
    StartServers          5
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers       100
    MaxConnectionsPerChild  1000
</ifmodule>
Restart Apache.

Not able to change permission or execute files in ubuntu

When your file is in NTFS partition, you are not allowed to change permission or execute file.

You need to add permissions for the partition.

Find UUID of all partitions using
sudo blkid

Open file /etc/fstab
and add following line for each partition which should be auto-mounted with executable file permissions.
UUID=12102C02102CEB83 /media/root ntfs-3g auto,users,exec,permissions 0 0

UUID of the partition can be found using above mentioned command and /media/root is the directory where you want the partition should be mounted

Now partition files have changeable and executable permissions.

Sunday, April 10, 2016

XAMPP - wrong ELF class: ELFCLASS64

If you have added an extension in your php.ini and you are getting this error while restarting XAMPP or running command  /opt/lampp/bin/php -v as well as as extension is not working, it means you are using 64 bit .so file(extension) in 32 bit XAMPP.

You can get this error while installing ioncube loader .so file, mongo.so file or in similar extension.

Download 32 bit version of .so file and put it in right place in xampp directory.
Mention it in php.ini file and Restart xampp .

Your extension should not be failed this time.

Browse files of Android mobile on ubuntu by bluetooth

To browse files of Android phone (memory card), you should have obex installed on your Ubuntu.
sudo apt-get install obexfs obexftp

Now you should have a server on your android phone. Install app "Bluetooth File Transfer" on your Android phone. When you open the app, it starts FTP (File Transfer Protocol) and OPP (object push profile) services on two different ports.

Start Bluetooh of android device and ubuntu and make both discoverable. Now mount your Android device on Ubuntu.
sudo obexfs -b android:device:id /mount/directory
Make sure mounted directory is empty.

To find your android device id, run command 
hcitool scan
Make sure your phone is discoverable and bluetooth is turned on.

Suppose your device id is 00:19:99:4c:68:12 and mounted directory on Ubuntu is /mnt/user.
Run command on ubuntu
sudo obexfs -b 00:19:99:4c:68:12 /mnt/user
Make sure you have started Bluetooth File Transfer app in your phone.

Now you can see all your memory card files in the directory /mnt/user.

I got maximum transfer speed 30 kbps from phone to system or vice versa. The only advantage I found, I need not carry USB cable and my Laptop usb port is not used in this process. Otherwise it is not useful for bigger transfer, sometimes it loses the connection and sometimes it is really annoying.

Saturday, March 12, 2016

ProxySet: unknown lbmethod lbmethod=byrequests; balancer://mycluster

apache2 error : While creating Load Balancer
ProxySet: unknown lbmethod lbmethod=byrequests; balancer://mycluster

If you are getting above error after setting Load Balancer in your conf file while restarting apache, you need to enable following module in apache.

Run following command 
sudo a2enmod lbmethod_byrequests

Now Restart apache.

Tuesday, February 16, 2016

Not able to find sendmail log

If you are not able to see log in /var/log/mail.log and file is empty, check the mail logs in /var/log/syslog
tail -n 25 /var/log/syslog

pecl install stomp error

configure: error: Cannot find OpenSSL's libraries
ERROR: `/var/tmp/stomp/configure --with-openssl-dir=/usr' failed


Solution :
While installing stomp using pecl, it asks
OpenSSL install prefix (no to disable SSL support) [/usr] :
Type yes and press return key.


Do not leave the input blank.

Server sent passive reply with unroutable address. Using server address instead

Filezilla Error : Server sent passive reply with unroutable address. Using server address instead

Solution :
In FileZilla, click on Edit > Settings.
1) Under Connection, click on FTP and choose Active as the Transfer Mode.
2) Under Connection, under FTP, click on Active mode and choose “Ask your operating system for the external IP address” (the default setting).
3) Under Connection, under FTP, click on Passive mode and choose “Fall back to active mode” (this is an optional setting).

Remove Apache server info from web page header

If you are using Ubuntu or Debian
Edit file  /etc/apache2/conf-enabled/security.conf

Change “ServerTokens OS” to “ServerTokens Prod”

and
Change “ServerSignature On” to “ServerSignature Off”

Restart apache.

If you are using CentOS, RHEL or fedora
Edit file /etc/httpd/conf/httpd.conf

Change “ServerTokens OS” to “ServerTokens Prod”
and
Change “ServerSignature On” to “ServerSignature Off”

Restart apache. 

If there are no entries of these lines, add both lines in the file.
Restart apache

Apache remove php version info from the web page header


Edit your php.ini and set following attribute.

expose_php = off
Restart apache.

Saturday, December 19, 2015

grub rescue error

grub rescue error : unknown filesystem

If you have tried following commands and still you are getting grub rescue error.
ls
ls (hd0,msdosx)/ #where x is the number depends on ls output.In this case,it is 6
set prefix=(hd0,6)/boot/grub
set root=(hd0,6)
insmod normal
normal
If insmod normal command is not working and showing unknown file system error.

Solution :
Boot your linux with pendrive or cd/dvd.
Select option "Run without installing". Now you can open terminal.
You need to scan the filesystem to resolve errors. Run command
sudo fsck /dev/sda1
where /dev/sda1 is the root partition of your hard disk.

Once it scans and checks complete filesystem, reboot your system.
You will not end up with grub rescue error.

/var/tmp/mongo/contrib/php-ssl.h:33:25: error: openssl/evp.h: No such file or directory

Compilation error : mongo compilation error :
/var/tmp/mongo/contrib/php-ssl.h:33:25: error: openssl/evp.h: No such file or directory

Solution :

You need to install package openssl-devel

Run following command on Centos/Fedora/RHEL
yum install openssl-devel

Now try to compile your package again, you will not get this error.

mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: No space left on device

mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: No space left on device

Not able to create new files, Not able to restart apache or mysql, Not able to run find or similar commands because of above error.

Solution :

You need to check two things on your system, first remaining space and second usage of inodes.

Delete some large files and make some empty space.

But if your hard disk is not full and sufficient space is there but still you are getting this error, there is fair enough chance that inode may be the reason.

If used inodes are 100% then you can not create any more files or restart servers or execute find command etc. Every new file or directory needs inode number and if all inodes are used, you can not create new.

Now how to check use inode %. Simply run command :
df -i

Here you can see total number of inode and used number of inode. If you have used all inodes, it means some program is creating large number of small files like any session directory of web application (ex- magento) or any similar program, You need to delete these all unused files and make some inodes free.

Once you have enough inodes, you can start creating files or restarting servers or making other tasks.

ffmpeg: error while loading shared libraries: libavdevice.so.55: cannot open shared object file: No such file or directory

ffmpeg compilation error on CentOS 

ffmpeg: error while loading shared libraries: libavdevice.so.55: cannot open shared object file: No such file or directory

After compilation of ffmpeg on Centos, you run the command ffmpeg and you get this error.

Solution :

Open file /etc/ld.so.conf and add the content in it.
sudo nano /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/lib
/usr/local/lib

Save file and run command.
ldconfig
Now run the command ffmpeg, you will not get this error.


Tuesday, December 15, 2015

Friday, November 6, 2015

Install VLC Media Player 1.1.13 in ubuntu

Install VLC Media Player 1.1.13 The Luggage in ubuntu 10.04
sudo add-apt-repository ppa:n-muench/vlc2
sudo apt-get install vlc

Ubuntu: Run vlc player as root

Open VLC player as root in Linux

Run following command :
sed -i 's/geteuid/getppid/' /usr/bin/vlc
Now you will be able to open vlc player as root user.

Saturday, October 10, 2015

git using http- gtk warning : cannot open display

Solution :
Run Command
unset SSH_ASKPASS
Note :
To remove this error permanently, add this command in your ~/.bashrc file.

/bin/sh: 1: r.js: not found

Solution :
Run Command :

npm install requirejs

Error in plugin 'gulp-shell'

Solution :
Run command
npm install gulp-shell

xubuntu : could not mount /dev/sda1 read-write is write-protected

Solution :
Run command

fsck -Af

Can't locate MongoDB.pm

Solution :
Run command
cpan Mojolicious::Plugin::Mongodb

Can't locate Data/Entropy/Algorithms.pm

Solution :

Run command
cpan Data::Entropy::Algorithms

Can't locate Crypt::Eksblowfish::Bcrypt

Solution :
Run command

CPAN Crypt::Eksblowfish::Bcrypt

Can't locate autodie.pm

Solution :
Run Command

cpan autodie

Can't locate Digest/Perl/MD5.pm in @INC

Solution :
Run command
cpan Digest::MD5

Can't locate CPAN.pm in @INC

If you are using CentOS/RHEL/Fedora and you get this error, Run following command to solve the error.
yum install perl-CPAN

Tuesday, September 8, 2015

gulp : watch error - Waiting…Fatal error: watch ENOSPC

gulp : watch error - Waiting…Fatal error: watch ENOSPC

Run command :
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Tuesday, August 18, 2015

ERROR:nacl_fork_delegate_linux.cc(314)] Bad NaCl helper startup ack (0 bytes)

Google Chrome Error :

Remove beta version if it is installed
sudo apt-get --purge remove google-chrome-beta
Remove stable version if it is installed

sudo apt-get --purge remove google-chrome-stable
Install stable version again suppose it is 36.

dpkg -i google-chrome-stable_current_i386_36.0.deb
 
If above solution is not working, Run following command in your terminal.

google-chrome --no-sandbox --user-data-dir

Monday, July 6, 2015

firefox start error - Couldn't load XPCOM

firefox start error - Couldn't load XPCOM

Check ubuntu is 32 bit or 64 bit and firefox is 32 bit or 64 bit.
Generally you get this when you install 32 bit firefox on 64 bit ubuntu.


Check your firefox is 32 bit or 64 bit, run in firefox
about:


If you get
Build identifier: Mozilla/5.0 (X11; Linux i686; rv:36.0) Gecko/20100101 Firefox/36.0
Note: i686, i386, i586 are 32-bit builds.

and if you get
Build identifier: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0
Note: x86_64 is 64-bit build.

Download 64 bit firefox from here.
Download 32 bit firefox from here.

DBD::Pg perl module hasn't been fully installed

install_driver(Pg) failed: Can't locate DBD/Pg.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 3) line 3.
Perhaps the DBD::Pg perl module hasn't been fully installed
sudo yum install perl-DBD-Pg
If you are using ubuntu, Run
sudo apt-get install libdbd-pg-perl

Friday, June 5, 2015

Install Zend Framework in XAMPP Ubuntu or any other Linux

Install Zend Framework 2 on XAMPP Linux


Ist method :
First change the directory.
cd /opt/lampp/htdocs
Now clone the framework using following git command :
git clone git://github.com/zendframework/ZendSkeletonApplication.git
Now change the directory again.
cd ZendSkeletonApplication
Run Command :
/opt/lampp/bin/php composer.phar self-update
Now
/opt/lampp/bin/php composer.phar install
and finally run command
curl -#L https://github.com/zendframework/ZendSkeletonApplication/tarball/master | tar xz --strip-components=1
Now you can open the zend frame work on your localhost using
http://localhost/ZendSkeletonApplication/public/

IInd method :
Run these commands :
cd /opt/lampp/htdocs
git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive
Now try to open framework using
http://localhost/ZendSkeletonApplication/public/

Thursday, May 14, 2015

ImportError: No module named pygtk

It means, the python your package is using is not the correct one or source package python.

Find using command `which python`.
If it is /usr/local/bin/python


Rename this file , the original python file will be in /usr/bin/python


Now run your package again.

Thursday, April 2, 2015

Ubuntu / Centos - Linux - Check Hyperthreading is enabled or not

Check Hyperthreading status :

Run command :
cat /proc/cpuinfo

If the number of siblings is equal to the number of cores then you have CPUs which are not hyperthreading or hyperthreading is switched off, If the number of siblings is 2x the number of cores then you have a hyperthreading CPU with hyperthreading switched on.

Friday, March 13, 2015

ssh-add - Add keys permanent

Keys are removed after reboot, Add ssh keys permanent

If you add private keys or .pem files using ssh-add and reboot your system, they are disappeared.

To add the keys permanently, here is the solution.

Suppose your key file is filename.pem and it is in Documents. In this case, Add the following command in your .bashrc file.


ssh-add /root/Documents/filename.pem 2>/dev/null

 
Now this key will be added permanently in your listing.


You can add as many keys you want.

Monday, February 23, 2015

Make xubuntu desktop classic

Remove Unity theme from xubuntu and install classic desktop


Install :
sudo apt-get install xubuntu-desktop gksu leafpad synaptic

Wednesday, February 18, 2015

AWS - Amazon - Stopping the instance changes my public IP

AWS - Public IP should not be changed

When you stop and start instance, it changes your public IP. If you do not want to change every time, Here is a solution for you.
You need to create Elastic IP for it. 
It will generate a new IP and it will not be changed.

EC2 > Elastic IPs (under network and security)
click on Allocate New address - A new IP will be generated
Now connect this IP to your instance.
Select the new created public IP. Click on the Associated Address.
Enter your instance name. It will show current private IP and current public IP in the drop down.
Now associated with it. Now your instance is connected to new created public IP.
Now if you stop or start your instance, public IP will not be changed.



Friday, January 2, 2015

Keep Python Server Running even after closing the terminal



Suppose you use following command to run your python server
python manage.py runserver
But once you close the terminal, process is killed and python server is stopped automatically.
This can be a bigger problem if server is placed remotely and you want to keep it running always whether your system is turned on or turned off.

Here is a solution for you. Use nohup with your command.
nohup your-command &

In this case, Run this command
nohup python manage.py runserver &
Now if you close the terminal, server still runs.

postgres: Postgres-XC: must start as either a Coordinator (--coordinator) or Datanode (--datanode)

Postgresql Server Error in Ubuntu :
postgres: Postgres-XC: must start as either a Coordinator (--coordinator) or Datanode (--datanode)

To remove this error, remove the package
apt-get --purge remove postgres-xc
But if you are not able to remove it because of an error, Find all processes of postgres using
ps aux | grep postgres
or
ps aux | grep psql

and kill all one by one. Now try to remove again.

Now install these packages:
apt-get install postgresql-client-common
apt-get install postgresql-common
apt-get install postgresql-9.3
apt-get install postgresql-client-9.3
apt-get install postgresql-contrib-9.3

* No PostgreSQL clusters exist; see "man pg_createcluster"

psql error : * No PostgreSQL clusters exist; see "man pg_createcluster"

If you are trying to start postgresql server and you get this error.
Here is solution for you.

First you need to find the server version of your postgresql then you need to create cluster.

Suppose your server version is 9.3
pg_createcluster 9.3 main --start


psql: could not connect to server: No such file or directory

 psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


 If you are trying to open command prompt of postgresql using command psql and it gives above error it means your postgresql server is not started, you need to start it first.
service postgresql start
If it is giving error postgresql: unrecognized service, it means you are not starting correct service, you need to verify the correct name of the service.
Is it postgresql-9.3 or postgresql-9.4 or postgresql-8.4?

Now restart it after confirmation.
service postgresql-9.3 start
or
service postgresql-9.4 start
or
service postgresql-8.4 start

psql: FATAL: Ident authentication failed for user "root"

Postgresql error
psql: FATAL:  Ident authentication failed for user "root"

If you run command psql on terminal as root user and you get the error
psql: FATAL:  Ident authentication failed for user "root"
Here is solution for you. 

To resolve this error, Run these two commands on your terminal.
sudo -u postgres createuser root
It might give you this message
could not change directory to "/root"
Do not worry about it, when it asks
Shall the new role be a superuser? (y/n)

Enter y and press return key.

and the other command is
sudo -u postgres createdb root -O root
Now run command psql on terminal and you will log into postgresql command prompt as user root.

To check the list of postgresql databases, run command
\list

to quit the psql command prompt, run command
\q

Find Orientation of an image captured by a digital camera or mobile / cell phone

Download exiftool tar file from http://www.sno.phy.queensu.ca/~phil/exiftool/ and extract it. Now run these commands.
First change directory.
cd Image-ExifTool-9.78/
Run these commands one by one.

perl Makefile.PL
make
make test
make install

To find the orientation of a camera image run command after installation :

exiftool Orientation -n "/path/of/camera_image.jpg"
Do not use downloaded image, make sure it is clicked by digital camera.

Note : Orientation means the correct position of the image with respect to the camera button when it was clicked.

ssh: Could not resolve hostname bitbucket.org: Name or service not known

If you are trying to run git commands to pull and push and you are getting this. Here is the solution for you.

Open file /etc/resolv.conf and add following line in it

nameserver 8.8.8.8
Now save the file and try to pull/push again.

Warning: No xauth data; using fake authentication data for X11 forwarding

Either you have changed your hostname or any similar activity on your system that's why other system is not identifying you.

Solution :
Run this command on terminal
xauth add :0 . `mcookie`
To check whether your hostname is added in the list or not, run
xauth list
Now ssh into other system, you will not get this error.

Received disconnect from IP: 2: Too many authentication failures for root

Received disconnect from : 2: Too many authentication failures for root

You are getting this error because your public keys are not saved on the server and it is not prompting for password so the public key authentication is failed, it throws you back on the command prompt with error.


The solution is simple. Either you need to save your public keys on server in authorized_keys file or set PubkeyAuthentication=no in your command. Now it will ask for password.

ssh -o PubkeyAuthentication=no server-IP
Example :
If you want to loginto server whose IP is 192.168.0.10, Run

ssh -o PubkeyAuthentication=no 192.168.0.10