Friday, November 7, 2014

php pdo driver not found

php connect to mssql database on Linux using pdo: driver not found
php pdo mssql driver installation on centos and ubuntu

If you are using CentOS, fedora or RHEL, Run commands
sudo yum install php-pdo
sudo yum install php-mssql
sudo yum install freetds-devel libxml2-devel
If you are using Debian or Ubuntu, Run

sudo apt-get install php5-dev php5-mysql php5-odbc php5-sybase libmysqlclient-dev freetds-dev

dblib is needed on Linux to connect to mssql server using pdo.

Here is php code to connect to ms sql server from Linux Apache using pdo.
<?php
$dsn = 'dblib:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
$dbh = new PDO($dsn, $user, $password);
?>
Now try to connect MS SQL server.

mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ffi-1.9.6 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/ffi-1.9.6/ext/ffi_c/gem_make.out


If you are using CentOS, fedora or RHEL, Run command
sudo yum install ruby-devel
If you are using debian or ubuntu, Run command
sudo apt-get install ruby-dev

nodejs npm - Fatal error: unable to find local grunt

Fatal error: unable to find local grunt

You need to install grunt on your system.
All the explanations are here.

To solve this problem, Run following command in terminal :
npm install -g grunt-cli
npm install grunt --save-dev
npm install grunt-cli

cronjob is running at wrong timezone

cronjob time zone is wrong

First check hardware time and timezone using command
hwclock
If it is different than system time, it may be possible that your cron is following hardware time.

Set your hardware clock time same as system time using command
hwclock -w
Now check if cron is following correct time zone.

If you are still facing problem, Restart cron daemon once.
You need to restart cron when you change your time zone.

If you are still facing problem, Restart your system once.

karma - can not start chrome

INFO [karma]: Karma v0.12.24 server started at http://localhost:xxxx/
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome


Set chrome path using
export CHROME_BIN=/opt/google/chrome/google-chrome
Now run your script.

If you are still facing this error, Install chrome launcher using
npm install karma-chrome-launcher
Now run your script.

If you are still facing this error.
Kill all instances of chrome.
Output of `ps aux | grep chrome | grep -v grep` should be empty.
Now run your script.

Tuesday, October 7, 2014

Install ioncube loader on ubuntu

ioncube loaders are available for 32 bit and 64 bit system both.
Suppose you are using 32 bit Linux system (CentOs, Fedora, Ubuntu or Debian).

Download 32 bit ioncube loader zip file from

http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
Extract it and Put the directory in your htdocs, Now run

http://localhost/ioncube/loader-wizard.php
There are number of ioncube .so files in the ioncube directory because you may have different version of php. When you run the wizard, it shows required .so file which you should use, copy your required ioncube.so file and put it in /usr/lib/php5/200.....

Add following line at bottom of the line [php] in the file php.ini
zend_extension = /usr/lib/php5/200..../ioncube_loader_lin_5.x.so
Restart apache2, and run

http://localhost/ioncube/loader-wizard.php
you will get
The ionCube Loader version 4.6.1 for PHP 5.4 is already installed and encoded files should run without problems.

Friday, October 3, 2014

Install ioncube-loader on centOS 64bit

ioncube loaders are available for 32 bit and 64 bit system both.
Suppose you are using 64 bit Linux system (CentOs, Fedora, Ubuntu or Debian).

Download 64 bit ioncube loader zip file from

http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
Extract it and Put the directory in your htdocs, Now run

http://localhost/ioncube/loader-wizard.php
There are number of ioncube .so files in the ioncube directory because you may have different version of php. When you run the wizard, it shows required .so file which you should use, copy your required ioncube.so file and put it in /usr/lib64/php/modules (for centOS 64 bit) 

Add following line at bottom of the line [php] in the file php.ini
zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_5.4.so
Restart httpd, and run

http://localhost/ioncube/loader-wizard.php
you will get
The ionCube Loader version 4.6.1 for PHP 5.4 is already installed and encoded files should run without problems.

If you restart httpd and check the status,if it says
httpd dead but subsys locked

 
It means zend_extension is somewhere defined in the ini file, comment the line, restart httpd and it will be running.

Cronjob is executing twice / multiple times

If you have set a script in cron and it executes twice, check following things.

1) Check if there is another entry of same cronjob.

2) Check if two different users are executing the same cron.

If both solutions are not working, Try this.

3) There may be high chances if cron daemon is running twice. Check if it is true using command

ps aux | grep cron | grep -v grep

If there are two entries, kill one job or stop the cron service twice and run it again. Make sure you check again that there is only one cron daemon is running.

Alias "bootstrap.helpers.*" is invalid. Make sure it points to an existing directory or file

Alias "bootstrap.helpers.*" is invalid. Make sure it points to an existing directory or file

If you are getting this error while executing a php web application. The reason may be your php version is less than 5.3. Upgrade it equal to or greater than 5.3 and try again.

If you have PHP Version 5.2.17 or similar, you may have this error.

Wednesday, September 3, 2014

Errors were encountered while processing: mysql-server-5.5 ... E: Sub-process /usr/bin/dpkg returned an error code (1)

start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):

subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)


I know you have tried all these solutions that's why you are here but just take a look at once before watching my final solution which is going to work for you.

Solution : 1
Run command
sudo dpkg --configure -a
Solution : 2
Remove and install mysql server again, Run commands :
sudo apt-get --purge remove mysql-server
sudo apt-get install mysql-server

Solution : 3
Remove mysql-server and mysql-server-5.5 package from the file /var/lib/dpkg/status and reconfigure mysql-server
sudo dpkg --configure -a
But you have tried all these solutions and still you are facing same problem, try this Final Solution.
 
Final Solution
Run Command :
sudo apt-get install --reinstall apparmor
Now comment following line in the file /etc/mysql/my.cnf
skip-bdb
Restart mysql
sudo service mysql start
Now your mysql will be started.

Saturday, August 9, 2014

Transfer files from one linux server to another linux server

scp from one remote server to another remote server

If you are trying to transfer files from one remote server to another remote server using scp and you are getting permission denied error, here is the solution for you.

Suppose you are using system A and you want to transfer files from system B to system C and you are trying
scp user1@systemB-IP:/location/sourcefile user2@systemC-IP:/location/targetFile
But you are getting permission denied error

You should use
ssh user1@systemB-IP scp /location/sourceFile user2@systemC-IP:/location/targetFile
But still you are getting permission denied error, try
ssh -t user1@systemB-IP scp /location/sourceFile user2@systemC-IP:/location/targetFile
Example :
IP of system A - 192.168.0.11
IP of system B - 192.168.0.12
IP of system C - 192.168.0.13

Source file location on system B - /opt/lampp/htdocs/install.log
Destination location on system C - /opt/logs

You are log in to system A and you want to transfer file from system B to system C. Run following command :
ssh -t root@192.168.0.12 scp /opt/lampp/htdocs/install.log root@192.168.0.13:/opt/logs


Solution : 2
Save public key file of your system (system A) into system B and system C.

scp $HOME/.ssh/filename.pub root@192.168.0.12:/root/.ssh/authorized_keys

scp $HOME/.ssh/filename.pub root@192.168.0.13:/root/.ssh/authorized_keys

and now run
scp root@192.168.0.12:/opt/lampp/htdocs/install.log root@192.168.0.13:/opt/logs

Pseudo-terminal will not be allocated because stdin is not a terminal

Pseudo-terminal will not be allocated because stdin is not a terminal

if you get this error while log into another Linux account using ssh, here is the solution.

Use -t -t with ssh.
ssh -t -t hostname
Example :
ssh -t -t user@192.168.0.7

unknown job `servicename`

unknown job error ubuntu

Service is installed but when you try to start, stop or restart, it gives you unknown job error. 
If you are facing this problem in root account, here is the solution.

Use sudo with your command but there should be no need to use sudo in root account. Use sudo and if your command is executed successfully, it means you have not created alias for sudo.

Add this line in .bashrc file of root.
alias service="sudo service"
You will find the file here i.e. /root/.bashrc

ubuntu - root login not possible through ssh

ubuntu 14.04 - Enable root login for ssh

If you are trying to log into root account of ubuntu system using ssh and you are getting permission denied error. You are quite sure that your password is correct but still you are facing this error. It means root account is disabled for ssh.
Follow the steps to enable it.

Open file /etc/ssh/sshd_config on your ubuntu system.
Replace line
PermitRootLogin without-password
with
PermitRootLogin yes
Restart ssh.
Now try to log into root account using ssh.

Friday, July 4, 2014

Postfix : Port 25 is not opened in Linux, opened in firewall

Port 25 is not in opened port list

If you have installed postfix mail server and port 25 is not visible in opened port list. 
Have you opened it in iptables ( firewall ) ?
The line should be included in iptables.
-A INPUT -p tcp -m state -m tcp --dport 25 --state NEW -j ACCEPT

Yes, Yes, it is opened in firewall. I do not want this solution. 
Okay Okay

Open configuration file of postfix. /etc/postfix/main.cf
Check the parameter inet_interface, it should be
inet_interface=all
Now restart postfix again. It will be listed in opened port list.

lvm device not found in /dev/mapper

lvm device is missing. lvm Volume status is not available. Missing Volume.

If you are not able to find your logical volume (lvm device), check the status of the device or volume.
Run command
lvdisplay
If LV status is Not Available, it will not be listed in /dev/mapper or your lvm device directory.
Make the status available, Run command
vgchange -a y
It makes status available of all volumes.

Now the device will be visible in /dev/mapper or your lvm device directory.
Mount the device using
mount -t ext4 /path/of/the/lvm/device /path/of/mounted/location
Suppose I want to mount vg-lv_home in /home, I run
mount -t ext4 /dev/mapper/vg-lv_home /home
Now I can see all my files of the volume in /home

lvm commands not found

-bash: pvscan: command not found
-bash: lvdisplay: command not found
-bash: vgcreate: command not found
-bash: lvcreate: command not found
-bash: lvscan: command not found
-bash: pvdisplay: command not found
-bash: lvm: command not found

If you are using CentOS or fedora or RHEL and you are getting these errors again and again when you try to run lvm commands. It means lvm is not installed or corrupted on your system. Reinstall lvm again.
yum install lvm2
If it is not able to find lvm2 package and shows
No package lvm2 available.
It means your repositories do not have this package.
Enable appropriate repository like base, remi, rpmforge or epel and install it again.

If you have enabled all available repositories and still it shows "No package available."
Check the file /etc/yum.conf

The lvm2 package should not be there in exclude packages.
Repos do not list exclude packages and do not install them. If it is under exclude attribute, remove it and run install command again.
It should be installed.

Create Case insensitive databases and tables in mysql

Linux is case sensitive system. You can create Test or test or tesT files in same directory.
That's why you can create Test and teST both databases in mysql.
But if you do not want case sensitivity while creating databases and tables in mysql. Here is solution for you.

Add following attribute in the file my.cnf
lower_case_table_names = 1
Restart mysql.
It disables case sensitivity. Now you can not create linuxamination or Linuxamination or LinuXamination all three databases. You can create any one of three. Same rule is applicable for tables.

If you do not want this feature, remove this line or set the attribute 0.

Configure: error: not found. Please provide a path to MagickWand-config or Wand-config program. ERROR: `/tmp/pear/temp/imagick/configure --with-imagick' failed

/tmp/pear related errors while installing imagick

If you are facing this error in Ubuntu or Debian
sudo apt-get install libmagickwand-dev libmagickcore-dev
If you are facing this error in fedora or CentOS
sudo yum install imagemagick php-magickwand php-pecl-imagick

Install Imagick on Linux

Install Imagick on CentOS, fedora or RHEL
If you are using XAMPP, Run
sudo /opt/lampp/bin/pecl install imagick
If you get any error related to /tmp/pear, it means development packages are not installed in your xampp. Download and install latest version of xampp. It comes with devel packages or find and install devel packages of your version of xampp.

If you have installed httpd/mysqld on CentOS, fedora or RHEL, Run
sudo pecl install imagick
Click here and here to resolve error.

If it installs successfully, add line 
extension=imagick.so
in the file php.ini
Restart apache. 

Install Imagick on Ubuntu or Debian
If you are using XAMPP, Run
sudo /opt/lampp/bin/pecl install imagick
If you get any error related to /tmp/pear, it means development packages are not installed in your xampp. Download and install latest version of xampp. It comes with devel packages or find and install devel packages of your version of xampp.
If you have installed apache2/mysql on Ubuntu or Debian, Run
sudo pecl install imagick
Click here and here to resolve error.

If it installs successfully, add line 
extension=imagick.so
in the file php.ini
Restart apache.

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - liblcms2.so.2: cannot open shared object file: No such file or directory in Unknown on line 0

Not able to install imagick on CentOS, fedora or RHEL
liblcms2.so.2: cannot open shared object file

Install following packages in RHEL, fedora or CentOS
yum install lcms2

mysql Error : Missing system table mysql.proxies_priv

To remove the error, run following command
sudo mysql_upgrade -u root -p
If your system does not identify mysql_upgrade, you can try these two commands.
mysqlcheck --no-defaults --check-upgrade --all-databases --auto-repair
mysql < fix_priv_tables

InnoDB: Database was not shut down normally!

mysql crashes frequently

Solution : 1
Restart your machine.

If it does not solve the problem and mysql crashes frequently with same error.

Solution : 2
Check attribute max_allowed_packet in the file my.cnf
max_allowed_packet=128M
OR
max_allowed_packet=256M

Restart mysql.
If it is not there, add it and restart mysql.

but if it does not solve the problem and mysql crashes frequently with same error.

Solution : 3
Repair all databases of mysql using following commands.
mysqlcheck --no-defaults --check-upgrade --all-databases --auto-repair
mysqlcheck --no-defaults --all-databases --fix-db-names --fix-table-names

If still your mysql crashes frequently.
Reinstall it again.

Allow / Block ssh / sftp for specific Users / Group

Allow ssh / sftp to selected users
If you want to give ssh / sftp privileges to certain users, here is the solution.
Add following line in the file /etc/sshd_config
AllowUsers username1 username2 username3
If you want to allow certain groups only, add following line in /etc/sshd_config
AllowGroups username1 username2 username3
Restart service ssh.

Block ssh / sftp for selected users
If you want to restrict certain users to access ssh / sftp, here is the solution.
Add following line in the file /etc/sshd_config
DenyUsers username1 username2 username3
If you want to block certain groups only, add following line in /etc/sshd_config
DenyGroups username1 username2 username3
Restart service ssh.

Extract an iso file in Linux using command line

Extract an iso file on terminal in Linux

Run following command
sudo mount -o loop "/path/of/iso/file.iso" /mnt
Example :
sudo mount -o loop "/home/user/Downloadsubuntu-12.04.3-desktop-i386.iso" /mnt


Now the iso file contents will be mounted in /mnt
You can copy them anywhere.
sudo cp -r /mnt /your/desired/destination/directory
Example :
sudo cp -r /mnt /home/user/Documents/files


If you do not want to use command line, you can extract it using Archive Manager.
Right click on the iso file and select "Extract here'.
If you have Archive manager, you can mount it using Archive Mounter and files will be opened as separate drive.


Monday, June 2, 2014

Postfix - Change Sender's email address from root

When you send mail using Postfix through command line or similar way, it shows sender's e-mail address root@domain-name. You do not want this and you want your defined email should be visible in recipient's mailbox. Follow the steps.

Add following line in the file /etc/postfix/main.cf 
smtp_generic_maps = hash:/etc/postfix/generic
Now edit the file /etc/postfix/generic, if it is not there, create it.
Add your 'from address' and 'the address you want to be seen in place of from address' in this file.
Example :
root@domain.com linuxamination@gmail.com
user1@domain.com linuxamination@gmail.com
You can define different mail addresses for each user of Linux. 
Now Run following commands in terminal.
postmap /etc/postfix/generic
and
service postfix restart
Now it displays linuxamination@gmail.com as sender, when I send mail as a root or user1.
echo "content-of-the-mail" | mail -s "subject-of-the-mail" "recipient@mail-address.com" 

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable ERROR: `phpize' failed

Install autoconf on your Linux system.

If you are using Debian or Ubuntu, Run
sudo apt-get install autoconf
If you are using CentOS or RHEL or fedora, Run 
sudo yum install autoconf

httpd dead but pid file exists

Your Apache is not working because it gives following error :
httpd dead but pid file exists

You have tried to restart Apache several times but still it gives same error.
To remove this error, you need to remove Semaphore Arrays of Apache.

Find all Semaphore Arrays of Apache. Run following command in terminal.
ipcs -s | grep apache
Now remove each entry using command
ipcrm -s semid
semid is second column of the table.

If there are multiple entries of Apache and it is difficult to remove each entry individually, Run following command.
for i in `ipcs -s | grep apache | awk '{ print $2 }'` ; do ipcrm -s $i ; done;
If it is not working for you, Run
ipcs -s | grep apache |  perl -e 'while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}'
Now restart Apache. Run following command.
service httpd restart 

Solution : 2
If still you are facing same error after restarting Apache. Run
rm /var/lock/subsys/httpd
and Run
rm /var/run/httpd/httpd.pid
Now restart Apache again.
service httpd restart 
Now what is Semaphore Array
A semaphore is a variable or abstract data type that is used for controlling access, by multiple processes.
In its simplest form a semaphore is a location in memory whose value can be tested and set by more than one process. 
ipcs  provides  information on the ipc facilities for which the calling process has read access.
-s displays semaphore arrays.
ipcrm removes a message queue, semaphore set or shared memory id.

Tuesday, May 20, 2014

code 127 --> sh: /usr/bin/expect: not found

 sh: /usr/bin/expect: not found

Install expect on your Linux system.

If you are using ubuntu or debian, Run
sudo apt-get install expect

If you are using CentOS, fedora or RHEL, Run
sudo yum install expect

ftp server vsftpd - Allow root login

 
By Default, root is not able to access ftp because it's name in the list of /etc/ftpusers or /etc/vsftpd/ftpusers
Remove root from the list. Save the file.
Restart vsftpd.
root will be able to log-in using ftp.

If you are using CentOS, fedora or RHEL and still you are not able to log in as root in your ftp server.
Add following line in the file vsftpd.conf
userlist_deny=YES
Remove user root in file /etc/vsftpd/user_list 
Restart vsftpd.
root should be able to log-in using ftp.
 
You can see the solution in the following video.
 


Friday, May 16, 2014

Open XAMPP control Panel - A GUI interface

XAMPP Control Panel - A GUI Interface

If you do not want to start/stop/restart xampp using command line, you can do it using UI interface. Just click on the button and your service will be started/stopped.

If you are using new XAMPP
To open XAMPP's control Panel (GUI interface), Run following command.
cd /opt/lampp && sudo ./manager-linux.run
If you are using older versions of XAMPP, Run following command.
gksu /opt/lampp/share/xampp-control-panel/xampp-control-panel

You can create launcher for this command. Whenever you run the launcher, it launches the XAMPP control panel.

Install XAMPP using command line on Linux

Install XAMPP using command line on Ubuntu, CentOS, Fedora, Debian, RHEL

If you are installing xampp first time on your linux system then it is fine but if you have installed it before and there is directory lampp in your /opt. You should rename it first.
# mv /opt/lampp /opt/lampp_old
Now download xampp installer from here.
A file xampp-linux-version-number-installer.run will be downloaded.
Suppose it is in directory Downloads.
Make the file executable.
# chmod a+x ~/Downloads/xampp-linux-version-number-installer.run
Now run the file.
# cd ~/Downloads
# ./xampp-linux-version-number-installer.run
It will open the wizard, now complete it to install xampp.


 





Now when you click on finish button, XAMPP's GUI interface will be appeared.


Now you can start/stop Apache & mysql using UI interface. Click on 'Manage servers' and you will be able to start/stop servers using buttons.

Open xampp in Browser
http://localhost/xampp

Open XAMPP control panel / GUI interface
Run following command in terminal
# cd /opt/lampp && sudo ./manager-linux.run




X11 connection rejected because of wrong authentication

If you are not able to log into Linux user account using ssh and you are getting this error, here is the solution.

Open the file etc/ssh/ssh_config on your system , client side (NOT on the server where you want to connect)

Check this parameter in the file
ForwardX11 yes
It should be uncommented as well as set as yes.

Restart ssh on your system. Try to connect again.

If you are still getting this error, open the file /etc/ssh/sshd_config server side where you want to connect.

Check this parameter in the file
X11Forwarding yes
It should be uncommented as well as set as yes.

Saturday, April 26, 2014

Fatal error: ini_set(): To prevent data corruption, you are not allowed to turn on the mongo.native_long setting on 32-bit platforms in Unknown on line 0

It is a mongo client - RockMongo error.

To remove the error, open file index.php in the directory rockmongo and comment the line
ini_set("mongo.native_long", 1);
Make it two forward slashes at the starting of the line to comment it out.
// ini_set("mongo.native_long", 1);
Now try again.

The default username and password is admin

You may find some deprecated error here but you can use the RockMongo without fatal error.

Tuesday, April 15, 2014

Install nodejs or node.js on CentOS / RHEL / fedora

To install node.js ( nodejs ) on CentOS / RHEL / fedora, Run following commands.

# sudo yum install nodejs

Install Packages using npm on CentOS / RHEL / fedora
First install npm on centos / RHEL / fedora
# sudo yum install npm
Now install packages using npm
Install mongodb :
# npm install mongodb
Install express :
# npm install express

Install nodejs or node.js on ubuntu

To install node.js ( nodejs ) on ubuntu, Run following commands.

# sudo add-apt-repository ppa:chris-lea/node.js

# sudo apt-get update

# sudo apt-get install nodejs

# sudo apt-get install software-properties-common

Install Packages using npm on Ubuntu
First install npm on ubuntu
# sudo apt-get install npm
Now install packages using npm
Install mongodb :
# npm install mongodb
Install express :
# npm install express

XAMPP - Fatal error: Class 'ZipArchive' not found

Run following command to download file zip.so
# /opt/lampp/bin/pecl install zip
It will install zip functionality, now enable the extension zip.so

To Enable this, uncomment following line (remove the semi colon (;) )
extension="zip.so"
in the file /opt/lampp/etc/php.ini

Restart xampp.

phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

CentOS - If you are getting this error while executing phantomjs on terminal

phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory
 
To remove this error.

# sudo yum install fontconfig
If you are still facing the error, Run
# sudo yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6
Note :
If you are using ubuntu or debian, use apt-get install to install this package.

phantomjs: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory

CentOS - If you are getting this error while executing phantomjs on terminal

phantomjs: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
 
To remove this error.

# sudo yum install freetype
If you are still facing the error, Run
# sudo yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6
Note :
If you are using ubuntu or debian, use apt-get install to install this package.

Install phantomjs on Linux

Install phantomjs on Ubuntu / Debian

Download phantomjs package from here

If you have 32 bit Linux distribution, download 32 bit file package or if you are using 64 bit Linux distribution, download the 64 bit package.

Extract the zip file and open the directory. Now you will find the phantomjs file inside bin directory.

Copy the file and paste into /usr/bin, /usr/local/bin & /usr/local/share.

Create a file hello.js and put following code into it.


console.log('Hello, world!');
phantom.exit();
Now run the phantomjs from the terminal.
# phantomjs /path/of/hello.js or # /usr/bin/phantomjs /path/of/hello.js

Install phantomjs on CentOS / RHEL

Download phantomjs package from here

If you have 32 bit Linux distribution, download 32 bit file package or if you are using 64 bit Linux distribution, download the 64 bit package.

Extract the zip file and open the directory. Now you will find the phantomjs file inside bin directory.

Copy the file and paste into /usr/bin, /usr/local/bin & /usr/local/share.

Create a file hello.js and put following code into it.
console.log('Hello, world!'); phantom.exit();
Now run the phantomjs from the terminal.
# phantomjs /path/of/hello.js or # /usr/bin/phantomjs /path/of/hello.js
If you get the error
phantomjs: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory

 
To remove this error.

# sudo yum install freetype

Now run hello.js again but if you get another error
phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

 
To remove this error.

# sudo yum install fontconfig
 If you are still facing the error, Run
# sudo yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6
Now run again, it should work.

# phantomjs hello.js Hello, world!
Note : 
Execute or Run phantomjs on browser
you can't directly reference a phantomjs script in your browser, but you can communicate with a PhantomJS instance using HTTP GET/POST with Web Server module

Monday, April 14, 2014

ERROR:dbus.proxies:Introspect error on :1.303:/org/freedesktop/PackageKit: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken

Open file /etc/dbus-1/system.d/org.freedesktop.PackageKit.conf
Find the line
<allow send_interface=org.freedesktop.PackageKit"/>
Add following line after above line
<allow send_interface="org.freedesktop.PackageKit.Transaction"/>

Open file /etc/dbus-1/system.conf
Find both lines
<allow send_requested_reply="true" send_type="method_return"/>
<allow send_requested_reply="true" send_type="error"/>

and replace top line with following line
<allow send_requested_reply="true"/>
Now delete the bottom line.