Tuesday, June 25, 2013

Website Building Tutorials

I have been making websites for many years now and helped lots of people get started with their own websites and blogs.

People with less knowledge about web stuff tend to believe that building website is a very difficult job. Believe me now it has become a child’s play if you know about the right tools.

I own this domain websiteown.com for quite a while. I thought I should start a blog about building websites and blog on it.

If you are interested you can follow it.

I have already written a post regarding how to build a website for free.

Tuesday, June 11, 2013

How to add swap to amazon ec2

Like me if you are using amazon free tier to host your websites then you must have learnt that hosting any decent traffic website on the amount of RAM ec2 micro provides is very risky. specially mysql keep on eating the RAM. I use amazon RDS it also comes  under amazon free tier. But if you like to keep you mysql instance on your ec2 instance than you can add some swap space to it.

Here is  how to add swap space to amazon ec2 instance in step by step guide.

You need to be root to perform these commands. To do this issue this command

$ sudo su

Type the following command with count being equal to the desired block size:

dd if=/dev/zero of=/swapfile bs=1M count=1024

Setup the swap file with the command:

mkswap /swapfile

To enable the swap file immediately but not automatically at boot time:

swapon /swapfile

To enable it at the boot time, add the following entry into /etc/fstab:

/swapfile swap swap defaults 0 0

 

Remember last line is not a command. You have to add this line to the file /etc/fstab.

You can do this by

nano /etc/fstab

then paste above line right clicking.

hit control+x

type ‘y’

hit enter.

Tuesday, June 4, 2013

Redirect directory to root .htaccess

Simple of the things sometimes waste too much time. Recently I needed this simple htaccess script to direct one of the subdirectory to the root. I needed same url other than the directory part.

This htaccess code did it for me

RewriteEngine On
RewriteBase /
# redirect stores to root
RewriteRule ^stores/(.*)$ /$1 [R=301,NC,L]

This code redirected all the content of the stores directory to root directory.

I placed this code in the root htaccess and removed the htaccess file from stores directory.

Monday, April 15, 2013

Relaod/refresh page with Javascript Jquery

$('#something').click(function() {
location.reload();
});
the reload() function takes an optional parameter that can be set to true to reload from the server rather than the cache. The parameter defaults to false, so by default the page reloads from the browser's cache.

Saturday, April 6, 2013

Installing Ioncube

1. Download ioncube:

wget http://downloads.ioncube.com/loader_down...x86.tar.gz

2. Extract ioncube
tar zxvf ioncube_loaders_lin_x86.tar.gz


3.move file ioncube_loader_lin_5.3.so
mv ioncube/ioncube_loader_lin_5.3.so /usr/lib/php5/20090626/


4.create file called ioncube.ini (I use nano, you pick your editor)
nano /etc/php5/conf.d/ioncube.ini

5.copy and paste this line
zend_extension = /usr/lib/php5/20090626/ioncube_loader_lin_5.3.so

6. Restart Apache
/etc/init.d/apache2 restart


7. check if installed correctly
php –v

You should have working ioncube installation now. If not check what you missed.

Switching to worker mpm from prefork apache 2 on ubuntu


I'm on ubuntu and according to some tutorials, the following lines would do all the tricks:
apt-get install apache2-mpm-worker libapache2-mod-fastcgi php5-fpm php5-gd
a2enmod actions fastcgi alias
Then you setup configuration in /etc/apache2/conf.d/php5-fpm.conf:
<IfModule mod_fastcgi.c>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization</IfModule>
After all these, restart:
service apache2 restart && service php5-fpm restart
 
Done! 

PHP files downloading instead of executing

When you open your site php files are downloading instead of executing follow these simple steps and you will be good to go again.

first, install libapache2-mod-php5

sudo apt-get install libapache2-mod-php5

Then enable it

sudo a2enmod php5

Restart apache

sudo service apache2 restart

Clear your cache on your browser, and re-load the page.

Your php files should start executing again and you will see your site.

Thursday, February 21, 2013

Jquery date picker z-index issue

In your css use

'.ui-datepicker{ z-index: 9999 !important;}'

Here 9999 can be replaced to whatever layer value you want your datepicker available.

Neither any code is to be commented nor adding 'position:relative;' css on input elements. Because increasing the z-index of input elements will have effect on all input type buttons, which may not be needed for some cases.

Thursday, February 14, 2013

Install phpmyadmin

This is how we install phpmyadmin is LAMP stack

apt-get install phpmyadmin

nano /etc/apache2/apache2.conf

and add following code

Include /etc/phpmyadmin/apache.conf

then restart apache

service httpd restart

or

/etc/init.d/apache2 restart

 

access at

localhost/phpmyadmin

or

ip address/phpmyadmin

or

domainname/phpmyadmin