Get Apache, MySQL, PHP With mcrypt and phpMyAdmin working on OSX 10.9 Mavericks

One of the best thing about OSX 10.9 Mavericks for web developer is Apache and PHP already installed. You do not have to start the Apache – its automatically starts when mac starts.

Apache
Even though you want to start manually

sudo apachectl start

to stop it

sudo apachectl stop

to restart it

sudo apachectl restart

To find the Apache version

httpd -v

Now you can access the it by http://localhost.

The document root is /Library/WebServer/Documents/. But I would suggest you use User Level Root. First create folder “Sites” in your home folder. Now go to /etc/apache2/users/

cd /etc/apache2/users/

Suppose you username is “zakir”. You can found your name

whoami

Now create a conf file in /etc/apache2/users/

sudo nano zakir.conf

add the following to zakir.conf

<Directory "/Users/zakir/Sites/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>

Change permission of the zakir.conf

sudo chmod 644 zakir.conf

Now restart the apache

sudo apachectl restart

Now you access it via http://localhost/~zakir/. Now you need change httpd.conf file to allow .htaccess file.

sudo nano /etc/apache2/httpd.conf

Find the line . Change value of AllowOverride To All.

Permission of the Sites folder

sudo chmod go-rwx Sites
sudo chmod go+x Sites
sudo chgrp -R _www Sites
sudo chmod -R go-rwx Sites
sudo chmod -R g+rx Site

If you have mutiple website ie mutiple folders then do the following after creating each folder

sudo chown -R username ~/Sites/folder
sudo chmod go-rwx ~/Sites/folder
sudo chmod go+x ~/Sites/folder
sudo chgrp -R _www ~/Sites/folder
sudo chmod -R go-rwx ~/Sites/folder
sudo chmod -R g+rx ~/Sites/folder

In this way only you can edit the files and others can not edit files. Apache can also run files. To check permission of a file use following line

stat -f %Mp%Lp file

PHP
Open httpd.conf file

sudo nano /etc/apache2/httpd.conf

Uncomment “LoadModule php5_module libexec/apache2/libphp5.so” line.
Now restart the apache

sudo apachectl restart

Install mcrypt for PHP
First install xcode and xcode for command line see http://blog.jambura.com/2013/02/19/setup-homebrew-perlbrew-ruby-rvm-perl-cpanm-nginx-in-mountain-lion/ for details.

Create mcrypt folder in your home folder.

cd ~
mkdir mcrypt
cd mcrypt

Download libmcrypt from http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download and download php source http://museum.php.net/php5/php-5.4.17.tar.gz. Copy the files to mcrypt folder.
Untar the files

tar -zxvf libmcrypt-2.5.8.tar.gz
tar -zxvf php-5.4.17.tar.gz

Configuring libmcrypt

cd libmcrypt-2.5.8
./configure
make
sudo make install

Compile mcrypt php Extension

cd ../php-5.4.17/ext/mcrypt/
make
sudo make install

You will see this msg

Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20100525/

Copy php.ini from /etc

sudo cp /etc/php.ini.default /etc/php.ini
sudo chmod u+w  /etc/php.ini

Open /etc/php.ini and add the line below at the end

extension=mcrypt.so

Now restart the apache

sudo apachectl restart

MySQL
First download dmg file from http://dev.mysql.com/downloads/mysql/. Install Install all 3…

mysql5.6.xxx.pkg
MySQLstartupitem.pkg
MySQLPrefPane

Now got System Preference and then got mysql then start mysql
null

now set mysql password for mysql – I liked to set password blank

/usr/local/mysql/bin/mysqladmin -u root password ''

Fix the 2002 socket error

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Download phpMyAdmin, the zip package and move the folder with its contents into the ~/Sites/phpmyadmin folder.

Make the config folder and Change the permissions

mkdir ~/Sites/phpmyadmin/config
chmod o+w ~/Sites/phpmyadmin/config

Go to http://localhost/~zakir/phpmyadmin/setup/. Click new server, Switch to the Authentication tab and set the local mysql root user and the password. Make sure you click on save, then a config.inc.php is now in the /config directory of phpmyadmin directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.

17. January 2014 by Zakir Hyder
Categories: Apple, Server Management, Web Development | Tags: , , , , , , , , , , , , | Comments

I reviewed “Getting Started with Citrix® CloudPortal™”

I have reviewed the Getting Started with Citrix® CloudPortal™.

  • Overview of CPSM and CPBM architectures, and planning CPSM and CPBM
  • Become efficient in product management, workflow management, and billing and pricing management
  • Provision services efficiently to cloud consumers and clients

14. January 2014 by Zakir Hyder
Categories: Jambura | Comments

How To Apply For Passport in Bangladesh

First of all – be patience.

Prepare following documents
1) 2 photocopies of National ID card
2) Or 2 photocopies of Birth Certificate
3) 2 copies of passport size photos
4) one person who can attest your photos, application and willing to give his/her phone number and his/her nation id in your application.
5) Police will ask for electricity bill so keep a copy of that also
6) If you live on rented house then make copy of National ID of the person whose name is on the electricity bill because Police will ask for it.
7)If you give profession as software engineer make sure you have your hon’s certificate 2 copies.

Its better if you pay your fee first then you can finish all formalities of taking photo for passport in one day. Different branch of sonali bank is dedicated to take the fee. My branch was awlad hossain market. Make you you write you name in CAPITAL in the receipt. Also make sure you write the same name as you will give for your passport. Because the officer checks your from will math both and will not accept if both does not match.

Now go to http://www.passport.gov.bd/Default.aspx. Fill out all information “passport application – Stage 1″. In Stage 2, give correct mobile number and email address. Because police will call you. Make sure you are entering correct Receipt number. It is the number top left corner. Or you can ask which is the Receipt number when you are paying the fees at the Bank. An email will be sent with link to pdf of your from. Print that out – TWO copies.

Now affix the photo on first page and write your name in Bangla on first page – in both copies. Now go to the person who will attest your from. Make sure attest over the photo on the first page and fourth page. On fourth page enter his/her address, phone number and passport/nation id. Now attest you all of your photocopies. Sign on page 3.

Now you will affix the receipt you got from bank on first page of one of the copy. Affix it bellow the bar code. You need affix it on one copy not both.

Now go to the passport office next day. I would suggest go to the office as early as possible if possible go to 7:30 AM. They will let you in at 8:45 AM. after army person gives stamp on you from go directly 2nd floor room 301. After the officer okes your from and gives stamp – go to ground floor. Near the stair you will two army person sitting – Show your both from. They will give another stamp. Now go to the 3rd floor. There is only one army person sitting. Show you from and he will give you serial number. Wait for your number. They will call the number go to the room let them take you photograph and finger print. Then they will give you printed page. Now go home and wait for police to call.

When police call make sure you have your photocopy of you ID, electricity bill. Its better to give him something for his trouble :D or ask him what he thinks is fair to him. Generally its between 500 – 1500 BDT. Keep his mobile number saved.

Call the police officer after 1/2 days to make sure sent the police report to passport office. Now go to Special Branch at and get a receipt number from reception. Now take that number to passport office after launch to 2nd floor/3rd floor. Ask some to check you police report came or not. If not then show your receipt number. Give 100-200 BDT as boksis. Then your number will be written to their ledger. Now all you have to is to go to passport office at date mention on the printed paper.

02. January 2014 by Zakir Hyder
Categories: Jambura | Comments

Use Only Bootstrap’s Modal component Not All The Whole Framework

Bootstrap comes with 13 components and some other helpers. I use the modal component most. Some times I just want to use just the modal not the others. So I am going show how you can use only the modal without using the whole Framework. First go to http://getbootstrap.com/2.3.2/customize.html. You can use the same technique for Bootstrap version 3.

First Select following checkbox – Buttons(Base CSS), Modals(JS Components), Close icon, Component animations(miscellaneous)

Then select jQuery plugins – Transitions, Modals, Buttons

Then change top: -25%; to top: -125%;

.modal.fade {
  -webkit-transition: opacity .3s linear, top .3s ease-out;
  -moz-transition: opacity .3s linear, top .3s ease-out;
  -o-transition: opacity .3s linear, top .3s ease-out;
  transition: opacity .3s linear, top .3s ease-out;
  top: -125%;
}

To customise the css in modal content use the following css

.modal h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 10px 0;
  font-family: inherit;
  font-weight: bold;
  line-height: 1;
  color: inherit;
  text-rendering: optimizelegibility;
}

.modal label,
input,
button,
select,
textarea {
  font-size: 12px;
  font-weight: normal;
  line-height: 18px;
}

.modal p {
margin: 0 0 10px;
}

28. November 2013 by Zakir Hyder
Categories: CSS, Web Development | Tags: , , , , , , , , , | Comments

Install memcached in Mac OS and using it in Perl

memcached is quite powerful but easy to use caching system. I would suggest you to read this wonderful story https://code.google.com/p/memcached/wiki/TutorialCachingStory to make you understand how it works.

To install memcached in Mac os we going to use brew. You can follow http://blog.jambura.com/2013/02/19/setup-homebrew-perlbrew-ruby-rvm-perl-cpanm-nginx-in-mountain-lion/ to install brew.

brew update
brew install memcached

Then add memcached to launchctl

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

You can run as daemon also

memcached -l 127.0.0.1 -p 11211 -d

There two Perl library I found Cache::Memcached::Fast and Cache::Memcached. While using Cache::Memcached I found this error “Storable binary image v48.98 more recent than I am (v2.8)”. Which is happening in Storable.pm line 417. While searching for solution, I found its much harder to fix. So its better to use Cache::Memcached::Fast. Its quite easy to use.

my $memd = new Cache::Memcached::Fast{servers => [$self->memd_server], compress_threshold => 100_000};
my $sub_tree_path = 'cat/car', my $attr = [1,2,3];
$memd->set($sub_tree_path, $attr);
my $memd_attr = $memd->get($sub_tree_path);

26. November 2013 by Zakir Hyder
Categories: Caching, Perl | Tags: , , , , | Comments

Style a Select Box Using CSS

Recently while working on new design for cellbazaar mobile which will only load on smart phone, I found way to design select box only using text-indent and text-overflow. BTW -moz-appearance does not work in Firefox :(. So this implementation is necessary when you are designing custom select box.

My plan is to make this into

This
null
This

Into this

Here is css code

.styled-select {
   width:100px;
   overflow: hidden;
   background: #F8F8F8;
   border: 1px solid #DDDDDD;
   height: 30px;
   border-radius:2px;
 }

.styled-select select {
  width: 100%;
  border: 0;
  line-height: 1.5;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-indent: 0.01px;
  text-overflow: '';
  appearance: none;
  background: transparent url("/img/smart_arrows.png") no-repeat scroll 97% 8px;
  @media (-webkit-min-device-pixel-ratio: 2), 
    (min-resolution: 192dpi) {
      background: transparent url("/img/smart_arrows@2x.png") no-repeat scroll 97% 8px;
      background-size: 16px 144px;
    }
}

Basically the .styled-select container div which will hold the select box. It’s overflow property is hidden so if the select box moves to right it wont show any bars. So the html code is like this

<div class="styled-select">
  <select >  
    <option value="">From</option> 
  </select>
</div>

If you are wondering about “@media (-webkit-min-device-pixel-ratio: 2)” see this Retina displays High Resolution Background Image.

05. November 2013 by Zakir Hyder
Categories: CSS, HTML | Tags: , , , , , | Comments

I Reviewed The “Twilio Cookbook”

I have reviewed the Twilio Cookbook. This book is all you need to know about Twilio.

  • Add 2-factor authentication to your web apps to verify your users
  • Set up a company directory
  • Buy a phone number
  • Conduct surveys using SMS
  • Set up a conference calling system
  • Use APIs to build a local search system for finding businesses, movies, and weather forecasts
  • Delve into SMS messaging and learn how to set up order tracking, bulk SMS sending, and a group chat system
  • Set up an appointment reminder using SMS
  • Build an interactive IVR menu system
  • Build your first PVR
  • Learn about OpenVBX plugins to extend its existing functionality
  • Verify that a person is answering the phone and not a machine

17. October 2013 by Zakir Hyder
Categories: twillo | Tags: , , , , | Comments

← Older posts