Monday, June 19, 2017

Best method get disk usage from command line

First try : df -lh
$ df -lh
Filesystem      Size      Used  Avail Use% Mounted on
/dev/sda2       518G    39G   453G   8%      /
udev              16G      4.0K   16G   1%      /dev
tmpfs             3.2G    236K  3.2G   1%      /run
none              5.0M     0        5.0M  0%     /run/lock
none              16G      0        16G    0%     /run/shm
/dev/sda1        93M   4.3M   89M   5%     /boot/efi

Second method for detail disk usage :

Works well from the command line. It's ncurses-based and interactive.
$ncdu /

Wednesday, June 14, 2017

How can I downgrade / Upgrade from PHP 7.0 to PHP 5.6 / PHP 5.6 to PHP 7.0 on Ubuntu 16.04

Ubuntu 16.04 comes with php7.0, and some php web applications might fail to run  with php7.0. So, you test your web app with both php7.0 and php5.0  version. 

You can do following changes with Ubuntu 16.04 

guru@pc1# sudo su
root@pc1# add-apt-repository ppa:ondrej/php
root@pc1# apt-get update
root@pc1# apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0 php5.6-curl php5.6-gd php5.6-mcrypt php5.6-xml php5.6-xmlrpc

Installing both php5.6 & php7.0 was clean in my case: no complain of issues, etc.

To switch from php7.0 to php5.6:

# For php in web apps
sudo a2dismod php7.0 && sudo a2enmod php5.6 && sudo service apache2 restart
# For php-cli in the command line
sudo ln -sfn /usr/bin/php5.6 /etc/alternatives/php
or from  php5.6 to php7:
# For php in web apps
sudo a2dismod php5.6 && sudo a2enmod php7.0 && sudo service apache2 restart
# For php-cli in the command line
sudo ln -sfn /usr/bin/php7.0 /etc/alternatives/php
Now Check php version : root@pc1# php --version or php -v

Sunday, June 11, 2017

Problems faced during migration php/mysql code Windows to Linux

1.  Slashes in file names when migrating PHP project to Windows server from Linux server.
Solution : Need to remove back slash & forward slash with underscore (" _ ")

2. Case Sensitive : Mostly in windows both "A" and "a" treat same. But in Linux thinks are different. So need to take care of this. This problems faces both in PHP and MySql files and table respectively. 

You can configuring MySQL Tables to be Case Insensitive by editing the MySQL configuration file, which is generally found at /etc/mysql/my.cnf/etc/my.cnf or ~/my.cnf

Add the following line to the my.cnf configuration file:
Then restart MySQL (or reboot):
/etc/init.d/mysql restart (Debian/Ubuntu/SuSE)
/etc/init.d/mysqld restart (Red Hat/CentOS/Fedora)

Today me facing problem the CodeIgniter Web Framework  code. In case of windows folder name was in cap mean in Upper case and in php coding same folder in lower case. It working fine with window server (XAMPP). But when I migrate same into Linux server (ubuntu LAMP) case sensitivity matters and creating problem to load files. You need to take care this otherwise php code does not work. 

Wednesday, June 7, 2017

Apache SSL Certificate Installation on Linux (Ubuntu) OS

For SSL Certificate Installation in Apache (Ubuntu OS)  follow the instructions below :

1. First Copy the Certificate files to your server on apache directory : In case of Ubuntu or Linux OS find path /etc/apache2/

2. Find the Apache config file to edit  Apache's main configuration file is typically named httpd.conf or /etc/apache2/conf.d/ or /etc/apache/sites-available/. 

3. Create  a files under apache configuration directory mention above like website-ssl.conf  for SSL.
If you need your site to be accessible through both secure (https) and non-secure (http) connections, you will need a virtual host for each type of connection. Make a copy of the existing non-secure virtual host.

4. Configure it for SSL as described below :

 <VirtualHost *:443>
DocumentRoot /var/www/html/
SSLEngine on
SSLCertificateFile /path/to/your_domain_name.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/DigiCertCA.crt


rename the file names to match your certificate files as mention above.

5. Test your Apache config before restarting your apache serviceRun the following command in case of ubuntu OS.

sudo service apache2 restart

Troubleshooting: If your web site is publicly accessible tool  like (SSL Tool 1 , SSL Tool 2SSL (Grading)) can help you find problems.

Wednesday, January 13, 2016

Create and Embed Barcodes using PHP

PHP GD Library 
In case of Debian Linux just run command :

#sudo apt-get install php5-gd

Barcode script : 
View the code here:

That Scripts generates barcodes in four barcode formats including Code 128, Code 39, Code 2of5, and Codabar. With a little over 100 lines of code you have the options of “vertical” or “horizontal” display, varying barcode heights, and one of four barcode formats.

How to embed in HTML code:
Example 1:
<img alt="testing" src="/yourfilelocation/barcode.php" />
Example 2 (with text data):
<img alt="testing" src="/yourfilelocation/barcode.php?text=testing" />
Example 3 (with codetype, size, text)
<img alt="TESTING" src="/yourfilelocation/barcode.php?codetype=Code39&size=40&text=TESTING" />