Friday, December 15, 2017

Invalid command '\xef\xbb\xbf#', perhaps misspelled or defined by a module not included in the server configuration


\xef\xbb\xbf are three invisible junk characters (at least from Apache's perspective) called the Unicode BOM, or byte order mark. Apache thinks that those characters are part of the command that follows right after. This is what you see in the log, though the characters are escaped so they're visible to the naked eye. \xef\xbb\xbfRewriteEngine

Copy the content in any advanced notepad editor which will detect the characters and you can easily remove them.

If you are not able to see these characters, remove this file completely and write again.

cpanel - wordpress - internal server error because of invalid permissions

cpanel - wordpress application - fix wordpress permissions of complete directory

cpanel > wordpress tool kit > Manage your site (Click on manage button) > Fix Permissions

It will fix all permissions of wordpress directory.

s3cmd : Configure multiple s3 buckets of multiple aws accounts on same server


First configure s3 bucket of 'AWS account - A' with s3cmd
s3cmd --configure
Add Access key and Secret Key of your 'AWS account A'.

Now rename ~/.s3cfg to ~/.s3cfg-first
You can find .s3cfg file in your home directory of logged in user.

Now configure s3 bucket of 'AWS account - B'
s3cmd --configure
Add Access key and Secret Key of your 'AWS account B'.
Now rename ~/.s3cfg to ~/.s3cfg-second

 
Configure third and so on

If you do not define config file parameter in command, it takes default config file i.e. .s3cfg


You need to define config file with command and you can communicate with different s3 buckets of one AWS account or multiple AWS accounts.
s3cmd ls s3://bucketname -c ~/.s3cfg-first
Above command will list the content of the defined s3 bucket of AWS account - A.
s3cmd ls s3://bucketname -c ~/.s3cfg-second
Similarly it will list the content of the defined s3 bucket of AWS account - B.

Now you can copy content, delete content or move them with different s3cmd commands.

Note : Number of buckets you can access of AWS account A or AWS account B, it depends on the privileges provided to access key and secret key and privileges are defined by the policy attached to the user whose access key and secret key you are using. 

If a policy which has read, write and list access of only one bucket 'Bucket-A' of an AWS account and this is the only policy attached to a user whose access key and secret key you are using then you can access only Bucket-A of that AWS account by using the access key and secret key of the user.

Use Redirect and Proxypass under one virtualhost in apache


If you need to redirect your domain on another domain or you need to redirect http to https, you use Redirect Permanent in your virtualhost to achieve but if your application is running on different port (node, python, ruby etc) and you have resolved port using proxy pass then your redirect attribute might not be working.

To solve this issue, use redirect under proxy directive.

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

<Proxy *>
    Redirect permanent / https://domain.co.in
</Proxy>

</VirtualHost>

Now your port will be resolved with domain as well as you can redirect domain too.

/opt/lampp/bin/httpd: relocation error: .so: symbol SSL_library_init, version OPENSSL_1.0.0 not defined in file libssl.so.1.0.0 with link time reference

Xampp apache is not starting after adding stomp extension or mongo extension in php.ini file. After installation using pecl, you have added following line in php.ini file.
extension=mongo.so
extension=stomp.so

Now when you try to restart xampp, apache does not start. 

When you check the apache log, you see following error.

/opt/lampp/bin/httpd: relocation error: stomp.so: symbol SSL_library_init, version OPENSSL_1.0.0 not defined in file libssl.so.1.0.0 with link time reference

/opt/lampp/bin/httpd: relocation error: mongo.so: symbol SSL_library_init, version OPENSSL_1.0.0 not defined in file libssl.so.1.0.0 with link time reference

If you remove the extension line in php.ini, apache works fine but you need to use the extension so you can not remove it, here is the solution.

Solution :

Install stomp or mongo or other extension with disable ssl support


Choose no option while installing stomp/mongo/extension-name

OpenSSL install prefix (no to disable SSL support) [/usr] : no

Now when you add extension in php.ini, the apache works fine and you are able to use the installed extension.



XAMPP is currently only available as 32 bit application. Please use a 32 bit compatibility library for your system.

Solution - I
If you have latest 64 bit Linux Operating system like recent versions of Ubuntu / Debian / CentOS or Fedora and you want to use older version of php or mysql ( php 5.3 or php 5.4) then you should follow Solution - I.

Older libraries of xampp supports 32 bit operating system so your latest 64 bit operating system is not able to install older xampp.

To make it working install Ubuntu 12.04 LTS or Debian 7.0 in Vmware or Virtualbox
or 
Download ubuntu 12.04 docker image and install xampp inside it, it is faster solution and will not occupy too much RAM.

Solution - II
If your xampp was working fine and suddenly it has started giving this error then this solution is for you

Most common reason of this error, you have added an extension in xampp and after adding it in php.ini, the lampp is not getting started. You are getting following error :

XAMPP is currently only available as 32 bit application. Please use a 32 bit compatibility library for your system.

Here is the solution for you.

Comment following code in the file /opt/lampp/lampp

#case `uname -m` in
#    *_64)
#    if $XAMPP_ROOT/bin/php -v > /dev/null 2>&1
#    then
#        :
#    else
#        $GETTEXT -s "XAMPP is currently only availably as 32 bit application. Please use a 32 bit compatibility library for your system."
#        exit 1
#    fi
#    ;;
#esac


Now restart xampp and you should not get above error.

If still there is error and it was because of new installed extension, I would suggest to comment the extension .so line in php.ini and restart xampp.

You can see the solution in the following video.
 


Error : pecl/pecl_http requires PHP (version >= 7.0.0), installed version is 5

Not able to install STOMP extension in XAMPP

Solution :

Current stable version of stomp is 2.0 which supports php 7.0, 
if we run

pecl install stomp
or
/opt/lampp/bin/pecl install stomp

it installs stomp-2.0 by default which needs php 7.0 so we need to install stomp which supports php 5.x,


Run :
pecl install stomp-1.0.9
or
/opt/lampp/bin/pecl install stomp-1.0.9

Stomp 1.0.9 is for php 5.x versions.
Now you should not get php version error.

Tuesday, November 7, 2017

phpmyadmin exporting html in place of sql

Solution :

Add/Uncomment following attribute in php.ini

max_input_vars = 5000
Restart Apache.

FATAL: Peer authentication failed for user "postgres"

psql dump database from other user without loginto postgres user

$ whoami
ubuntu

$ pg_dump -U postgres dbname > db.sql
FATAL:  Peer authentication failed for user "postgres"


Solution :

sudo nano /etc/postgresql/9.4/main/pg_hba.conf

Change

local   all             postgres                                peer
to
local   all             postgres                                trust


Restart postgresql.

mysqli::mysqli(): Headers and client library minor version mismatch. Headers:50552 Library:100120


In centos or fedora, If you are facing above error.

Solution :


yum remove php56w-mysql

yum install php56w-mysqlnd

I used php56  in command as I installed php with php56 package because I wanted php 5.6 on my server. If you have installed php using simple php or php5 command, remove php-mysql or php5-mysql package and install php-mysqlnd or php5-mysqlnd.

Restart apache and verify the issue. It should be fixed.

Error: EACCES: permission denied, mkdir 'node_modules/node-sass'



Unable to save binary /usr/lib/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:891:18)
    at sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/lib/node_modules/node-sass/scripts/install.js:111:11)
    at Object.<anonymous> (/usr/lib/node_modules/node-sass/scripts/install.js:154:1)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)



You are trying these commands in project directory
sudo npm install node-sass
or
npm install node-sass
and it is giving above error and module is not getting installed.

Solution :

sudo chmod -R 777 projectfolder
Now it has sufficient permission to create files inside it. 
Do not use sudo with npm, it does not need root access to install package(module).
Now Run :
npm install node-sass
Now it will be installed. You can give correct permission to folder and files again, 777 is a security breach. We just made it for installing this module.

Magento Installation Error : set always_populate_raw_post_data to -1

Magento Installation Error :

PHP Settings Check * Need Help? PHP Documentation Your PHP Version is 5.6.30, but always_populate_raw_post_data = 0. $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. This will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.

Solution :
 Open .htaccess file of magento and add line php_value always_populate_raw_post_data -1 between tags <IfModule mod_php5.c> and </IfModule>

<IfModule mod_php5.c>    php_value always_populate_raw_post_data -1
</IfModule>


Now Try to install again. You should not get same error again.

Monday, October 2, 2017

Convert Text into Hexadecimal and Hexadecimal into Text on command line


Convert Text into Hexadecimal using command line :
printf "linux is awesome" | xxd

or

echo -n "linux is awesome" | od -A n -t x1


Convert Hexadecimal into Text using command line:
echo "6c 69 6e 75 78 20 69 73 20 61 77 65 73 6f 6d 65" | xxd -r -p && echo ""

Monday, September 4, 2017

No PostgreSQL clusters exist; see "man pg_createcluster"

Solution :

Run commands :
dpkg-reconfigure locales

pg_createcluster 9.3 main --start
or
pg_createcluster 9.4 main --start
or
pg_createcluster 9.5 main --start
(depends on your postgresql version.)

Ubuntu Apache php error : Class 'NumberFormatter' not found

Solution :

Install Package :
apt-get install php5-intl
or
apt-get install php-intl


Make sure intl.so file is generated and it is defined as an extension in .ini file.

Tuesday, August 15, 2017

Regression testing of Web Application using Automation

Human beings try to explore new things that's why they do not want to do same work again and again. It is in their jeans, deep inside. The similar work appears monotonous for them. 

Regression testing is something that no tester wants to do and when developer tries to fix a bug and breaks a functionality which was working absolutely fine before, this condition disturbs a tester psychologically. It increases irritation and makes a tester annoyed, impatient and angry.

But for automation, it is a different story. The tools do not feel bad if you assign them same task again and again. That's why a script is a best friend of a tester whose work is regression.

If you want to do automation testing, the first tool comes in mind is Selenium. Definitely it gives the result efficiently and it is quite flawless. Big companies are using it as their primary testing tool and testers who are seeking good career opportunities are trying to learn it as fast as possible but it is not the only tool which can give you automation results.

Today I am going to discuss two less used web application automation test tools.

First is CURL yes you heard right, I am not joking. If you enjoy working on terminal and you like scripting, curl is one of the best tool to achieve regression testing task. It is so efficient that hacker started using to manipulate data that's why many big sites have blocked it.

How to do regression testing using CURL
1. Create a curl command for login or registration what you want to test by passing valid data with valid method like POST or GET.
If your form uses cookies, you can save and reuse again in CURL.

Example :
curl -c cookie.txt -d "LoginName=someuser" -d "password=somepass" https://oursite/a 

curl -b cookie.txt https://oursite/myaccount


2. You can use this command in BASH script and after running the script new user will be registered or existing user will be logged in successfully.

3. You can achieve login protected task like edit profile, create category, edit tasks, schedule tasks using CURL. You need to make script for each task and while regression, you do not need to do it again and again manually

A failed script is enough to notify that functionality is broken. Not only it will be efficient but it will save your time too.

Second one is JMETER. You must be thinking that we are not talking about performance testing, first we should achieve a working functionality. You can use JMETER for functionality testing too. It has a UI interface so it is quite easier than CURL.

How to do regression testing using JMETER
1. Record a script of functionality like login or registration.
2. Save the test plan as .jmx file 
Now this is a script which you can use in regression testing.

Jmeter has cookie manager using it you can achieve cookie based login to test login protected functionlity. Using regular expression extractor, you can test CSRF based login functionality or pass dynamic values by storing them in variables. Using csv set config, you can run data driven tests as well as parametrization can be done. Not only REST API and LDAP tasks but you can perform all types of java based web application functionality testing tasks.

This is very little that I have listed advantages of JMETER, once you start using it, you will come to know that it is fine tool to perform regression testing. 

Tutorials to Learn Jmeter : 
https://www.youtube.com/watch?v=f6AvTKLrD8A
https://www.youtube.com/watch?v=KgKtM48ujxQ
https://www.youtube.com/watch?v=LLTZG6tbyC8
https://www.youtube.com/watch?v=EdABL-1Z1qU
https://www.youtube.com/watch?v=hlnjD650oMY

Friday, August 11, 2017

Copy files into sd card which is mounted as mtp on Linux Command ine

mtp is media transfer protocol. These devices are mounted in /run/user/$UID/gvfs/mtp*

/run/user/0/gvfs/mtp\:host\=%5Busb%3A002%2C075%5D/Internal\ storage/Documents/

we can copy into this location


just use back slash (\) before spaces in file name (if you have spaces)) in cp command.


Similar way, you can use scp to copy from remote location

Examples :
cp /root/Documents/perl.pdf /run/user/0/gvfs/mtp\:host\=%5Busb%3A002%2C075%5D/Internal\ storage/Documents

or

scp 192.168.0.99:/root/Documents/perl.pdf  /run/user/0/gvfs/mtp\:host\=%5Busb%3A002%2C075%5D/Internal\ storage/Documents/


Zurmo CRM Error - Notice: Undefined property: WebApplication::$minScript in app/protected/core/views/PageView.php

If you are trying to open zurmo using url and not able to open because of following errors

Notice: Undefined property: WebApplication::$minScript in zurmo/app/protected/core/views/PageView.php on line 268

Fatal error: Call to a member function generateScriptMap() on a non-object in zurmo/app/protected/core/views/PageView.php on line 268


Solution :

Remove content of runtime Folder.

sudo rm -r zurmo/app/protected/runtime/*

Now try to open it again. You should not get the error now.

Monday, July 3, 2017

Convert Text file into pdf on Linux command line

Create a small size pdf file from a text file

First install enscript on linux system.

Debian/Ubuntu
apt-get install enscript


CentOS/Fedora
yum install enscript


Command to convert text file into pdf
enscript -B /path/of/text-file.txt -o - | ps2pdf - "/path/of/output.pdf"

-B is for not printing header on top of the pdf pages

Thursday, June 8, 2017

Mongodb secondary database - database list and collection is not visible

MongoDB secondary replica does not have collections as in primary

Error : 
"$err" : "not master and slaveOk=false", "code" : 13435

Solution :
serverdb:SECONDARY> rs.slaveOk()

Running Command rs.slaveOk() on secondary instance is the solution.

Thursday, May 18, 2017

Mysql installation conflict with mariadb

Error :
Renaming removed key_buffer and myisam-recover options (if present)


mysql_upgrade: Got error: 1524: Plugin 'unix_socket' is not loaded while connecting to the MySQL server


Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11


dpkg: error processing package mysql-server-5.7 (--configure):subprocess installed post-installation script returned error exit status 1


Errors were encountered while processing:mysql-server-5.7


Solution :
If you have installed MariaDB and then you have removed it to install mysql. This can be the cause of this issue. If you try to purge all old config filess and set everything up from scratch then it should work. 

Take Back up your important data before doing it.

# sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server
# sudo apt update 
# sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install
# sudo apt install mysql-server

Saturday, April 8, 2017

Odoo - Remove Manage Databases link from Login page

Odoo - Remove Powered by Odoo Text from Login page

Edit file addons/web/views/webclient_templates.xml
sudo nano /opt/odoo/addons/web/views/webclient_templates.xml

Remove or Comment text "Manage Databases" and "Powered by Odoo".


Now you tried to restart the odoo server but you are not able to see your changes on the browser.

Here you need to load the web module because you ahve changed content in the file of web module. Without loading web module, you will not be able to see your changes. Restarting Odoo does not load the web module.


sudo -S su postgres -c "./odoo-bin start --update=web"

--update=all loads all modules but we need to reload only web module to see the changes. Now changes will be visible.

Sunday, March 12, 2017

mysql - select query denied error

select command denied to user ''@'' for table ''

Solution :

You are getting this error because you are logged into the mysql user account where Select_priv is set as N for the user.

If you are able to modify your own privileges that is really good (Generally this can't be done because of security) otherwise you need to login with super user and need to set this privilege as Y.

Run this query :

update user set Select_priv = 'Y' where User = 'username';

Changes will not take effect after running this query. You will have to flush privileges.

Run Query :

FLUSH PRIVILEGES;

After flushing privileges, if still you face denied error for select query, Log out from mysql, Log in again with same user and running select query again.
You will not get the error.

If you get same denied error for Insert, Update and Delete queries, you need to set them as Y using same method.

Restarting mysql does the job but every time you do not have command line access to restart it that's why you need to flush privileges.

Friday, February 3, 2017

Magento - No trailing slash appears after domain name

Magento - js/css/image files are not loading because no trailing slash appears after domain name

No trailing slash after domain makes all js/css/skin/media urls 404.

Solution :
Give trailing slash in domain name in column web/unsecure/base_url and web/secure/base_url of table  core_config_data.


http://domainname/

Even if problem persists, login as admin.


Go to system > cache management
Flush all cache including 'flush magento cache' and 'flush cache storage'.


Now open site url. You should not get this issue.

Monday, January 9, 2017

Composer is getting stuck on installing dependencies

 php composer update stuck

Solution :

a) Download and Install updated composer
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04

b) Use update command with verbose mode
composer -vvv update
It will display every single output and you will not be impatient.