Why Do?

Don’t do something because you feel you have to, or because you feel you are in debt to someone; do it simply because you want to.

How I Setup My PHP Dev Env: Part 2

This post is the second part of a 2-part series on how I setup my PHP Development Environment using Windows 7 as a base operating system and a basic LAMP server running on Ubuntu installed on Oracle VirtualBox. (You can read the first part here)

Section 1: phpMyAdmin

To be able to manage MySQL conveniently, we will install phpMyAdmin. We will need an internet connection and perform the following steps:

  1. Fire up your virtual machine and login.
  2. Run sudo apt-get install phpmyadmin to install the package.
  3. Direct your browser to localhost:8080/phpmyadmin. You should see the phpMyAdmin login page there. Try to login using the root account and the password you designated to it when you installed Ubuntu LAMP server.
  4. If you did not set a root password for MySQL, run cd /etc/phpmyadmin to switch to the phpMyAdmin installation directory and then run sudo pico config.inc.php to edit the configuration file. Press Ctrl-W and type in allownopassword to find the keyword, and then uncomment the line. Press Ctrl-X and then Y to save the file. You should now be able to log in as root without using a password.

That’s it, we should now be able to use phpMyAdmin.

Section 2: NetBeans PHP

Now, we’re going to install NetBeans PHP as our IDE of choice. You’re free to install any other IDE to your liking, but I’m only going to explain how to use NetBeans PHP.

  1. Go to the shared folder you have set up previously (see Part 1), create a new folder for your new project, and create a new index.php file there. Just fill it up with some HTML or some code.
  2. Download the Java SE Development Kit if you haven’t already done so. This is a prerequisite to install the NetBeans IDE. Install it.
  3. Download the installation file from the NetBeans website. Install it.
  4. Open NetBeans, then go to File –> New Project.
  5. Select PHP Application with Existing Sources. Click Next.
  6. Set the Sources Folder to the folder you created in step 1. Select your preferred PHP version, then click Next.
  7. Set the Run As option to Local Web Site, and click Finish. Make sure to edit your site URL to add your forwarded port number (set to 8080 in Part 1).

We are now ready to start writing code. Try creating a PHP file and write some echoes or whatever in it. Save it and then click the play button on the top toolbar to open a new browser window/tab directed at your site.

Section 3: Apache/PHP Configuration

The apache2 server works almost out of the box, but usually we would want it to be properly configured and equipped with some of the more common modules. Here’s how to do some basic configuration:

  1. Run sudo pico /etc/php5/apache2/php.ini to open and edit the PHP configuration file.
  2. Find the date.timezone parameter and set it to your liking. You can find the list of valid timezones here.
  3. Find the short_open_tag parameter and set it to Off. This is to prevent you from coding with short open tags, which might not be supported on some servers. Press Ctrl-X and then Y to save and close the file.
  4. Run sudo pico /etc/apache2/sites-available/default to open and edit the apache2 virtual host configuration file.
  5. In the <Directory> tag for root (/) and /var/www/, set AllowOverride to FileInfo Indexes. Save and close the file.
  6. Run sudo a2enmod rewrite proxy proxy_http proxy_ftp proxy_connect to enable the listed modules needed to support mod_rewrite.
  7. Run service apache2 restart to restart the apache2 server.

That’s it. Now we’re practically ready to start cracking. I might write some more about the actual code I’m working on, which is based on CodeIgniter 2 integrated with Doctrine ORM version 2, but I can’t make any promises as of now.

How I Setup My PHP Dev Env: Part 1

This is a post long overdue. Originally started as a favor to a good friend of mine, this now has also turned into my personal quest to document my efforts to set up my PHP Development Environment on my MacBook.

DISCLAIMER: This is some geeky stuff, you have been warned.

So, without further ado, let’s get to it!

Section 1: The Operating System

I have an Apple MacBook A1342, so the documentation pertains to that specific hardware. If you have another type or brand of computer, or if you choose another operating system, the following instructions should not apply to you. You should go ahead and install your operating system as you would normally.

Prerequisites:

  1. Apple MacBook A1342, or a variant of it
  2. Apple Mac OS X installation DVD that came with the laptop
  3. Single-disc Windows 7 64-bit installation DVD
  4. Internet connection (either via LAN or broadband modem)

Steps:

  1. Fire up your MacBook and let it enter Mac OS X as usual. Find Bootcamp Assistant in your Applications folder and open it. Set up your BOOTCAMP partition. As I’ve done this 2 years ago, I don’t need to do it again, and I can’t remember the exact steps, so please go visit Apple’s support site if you need more detailed information.
  2. Insert your Windows 7 64-bit installation DVD and restart your MacBook. Hold down the Option key while booting up to show the boot options, and select the DVD.
  3. Install Windows 7 as you would normally. Select BOOTCAMP as the partition to install Windows 7 on.
  4. At this point you should be able to log into Windows 7. Now, insert your Mac OS X installation DVD, find Bootcamp for Windows, and install it.
  5. Install any additional drivers and software as required.
  6. Voila! Your base operating system is now ready.

Section 2: The Virtual Machine

I choose to use a virtual machine to host my PHP and MySQL server. Why?

  1. I can emulate the deployment server environment as closely as possible without having to compromise my development environment. This way I can only install server software as necessary, perform server configuration as if I was doing it on the real server, and reinstall the entire server if necessary without having to install my base operating system.
  2. I can take the VM with me and run it on another computer if need be.
  3. I don’t have to install server software directly on my base operating system. This keeps it lean and clean for gaming and such 😀

Prerequisites:

  1. Newest stable release of Oracle VirtualBox
  2. Installation DVD (or disk image file) of a guest operating system of your choice, or preferably an image of it. I tend to like the latest server version, so I use Ubuntu 11.10 Oneiric Ocelot Server Edition (64-bit), which is downloadable from the Ubuntu website.
  3. A preferably fast and reliable internet connection.

Steps:

  1. Install Oracle VirtualBox. Just click next next next done. Simple as that.
  2. Fire up Oracle VirtualBox and click File –> Preferences.
  3. Set your Default Machine Folder, or leave it as it is if you prefer to do so. Click OK.
  4. Specify a name for your new virtual machine, set Operating System to Linux and Version to Ubuntu (64 bit). Click Next.
  5. Set the RAM allocated for the virtual machine. Usually 512MB is enough for servers, but you’d probably want to use more if you intend to install the desktop version of Ubuntu. Click Next.
  6. Create a new virtual hard drive. Leave all options as it is and click Next to bring up the virtual hard drive dialog. Select VDI, Dynamically Allocated, and set the size to your liking. I use 20GB.
  7. Click Next, then click Create. After the hard drive dialog disappears, click Create again.
  8. Insert your Ubuntu installation DVD or set the disk image file in Settings –> Storage –> IDE Controller and start your virtual machine.

At this point you should be booted into the Ubuntu installation DVD. Let’s move on:

  1. Select English and then select Install Ubuntu Server.
  2. Select your language and location, and configure the keyboard if necessary. I use English (U.S.).
  3. Specify your hostname.
  4. Set up your partitions. To keep it simple, I use guided partitioning using the entire disk.
  5. Set up your user name, password, and home folder encryption (if you want to).
  6. When asked for a proxy configuration, leave it blank. The installer should start downloading stuff using apt.
  7. Choose your automatic security update setting.
  8. In the software selection, select LAMP Server and Mail Server. Select Internet Site for the mail server setting.
  9. It’s safe to install GRUB as recommended, go ahead and do it.

Section 3: VirtualBox Guest Additions

Proceed until the virtual machine restarts, then shut it down. Remove the Ubuntu installation DVD (image) from the (virtual) drive and insert the VBoxGuestAdditions.iso image from C:Program FilesOracleVirtualBox. Now it’s time to play with the command line:

  1. Run sudo apt-get update to update the repository to the latest source.
  2. Run sudo apt-get dist-upgrade to upgrade all installed packages to the latest version.
  3. Run sudo apt-get install dkms to install Dynamic Kernel Module Support (DKMS), which will be used to install VirtualBox guest additions on your Linux machine.
  4. Run sudo mount /dev/cdrom /media/cdrom to mount the VBoxGuestAdditions media.
  5. Run cd /media/cdrom to switch directory to the mounted media.
  6. Run sudo sh ./VBoxLinuxAdditions.run to install the VirtualBox Guest Additions.

Section 4: Shared Folders

Now that we have VirtualBox Guest Additions installed, we can start adding shared folders to the virtual box:

  1. Shutdown the virtual box, go to Settings –> Shared Folders, and create a shared folder referencing a directory of your choice on the host machine. Take note of the share name.
  2. Run mkdir /home/[your_username]/public_html to create your own public html directory. This will be the mount point of the shared folder.
  3. Run id [your_username] to find out your uid and gid. Take note of this.
  4. Run cd /etc/init.d to change to the startup script directory.
  5. Run sudo pico vboxshare-automount to open pico and create a new file called vboxshare-automount.
  6. Write mount -t vboxsf -o uid=[your_uid],gid=[your_gid] [your_shared_folder_name] /home/[your_user_name]/public_html in the file. Press Ctrl-X and then Y, enter, to save the file.
  7. Run sudo chmod +x vboxshare-automount to make the file executable.
  8. Run sudo update-rc.d vboxshare-automount defaults to make the script run on every startup.
  9. Restart your virtual box, then login and run cd public_html. If you run ls, you should see the contents of your shared folder there.

Section 5: Port Forwarding, User Directories, and PHP Parsing

Alright, we now have a shared folder that we can use to directly edit our PHP files. Now we need to enable our host machine to access the virtual box’s PHP server:

  1. Shutdown your virtual box if it’s not already off.
  2. Go to Settings –> Network –> Adapter 1. It should be set to NAT by default.
  3. Click on Advanced and then Port Forwarding.
  4. Click on the add icon, then set rule name to http, protocol is TCP, host port 8080, and guest port 80.
  5. Start up your virtual box.
  6. Fire up your browser and go to http://localhost:8080. You should see the default apache2 page saying that it works.
  7. Now go to the virtual box’s console and run sudo a2enmod userdir to enable per-user directory service.
  8. Run sudo pico /etc/apache2/mods-available/php5.conf to edit the PHP5 module configuration. Comment out the part between the <IfModule> tags to enable PHP parsing in home directories.
  9. Run sudo /etc/init.d/apache2 restart to restart the apache server.
  10. On your host machine, create a new file info.php in the root of the shared folder. Fill it with the usual phpinfo(); code.
  11. Direct your browser to localhost:8080/~[your_user_name]/info.php. You should see the PHP information page there.

That’s it. Now we have a working Apache/PHP server running on Ubuntu and accessible seamlessly through our Windows machine. Next we should check if we have phpMyAdmin and everything else we need to really start cracking. But I think I’ll save that for another post: Part 2.

Moms

…and what they’d do to protect their kids.

Moms

I know she’ll catch me whenever I fall. But she can’t protect me from the choices I make.

It doesn’t matter, mom, I still love you.

Cheating Death

A part of Steve Jobs’ speech at Stanford went like this:

No one wants to die. Even people who want to go to heaven don’t want to die to get there. And yet death is the destination we all share. No one has ever escaped it.

I could say that I’ve cheated Death once. I came so close to Death that it would’ve changed my entire perspective on Life. Unfortunately, I was still too young to understand. Maybe I’m still too young now to understand it all.

But Death is still there, whether we understand it or not. We can’t foresee it, but we can be sure that each second that passes brings us ever closer to it. Just thinking about this can have a profound effect on you.

What have  I done?

What do I want to achieve? Have I achieved it?

How do I want to be remembered?

In the past 27-odd years, have I contributed anything for the good of my family/church/friends/community/workplace?

How much time do I have until my fragile body succumbs to the various damages I have done to it throughout my life?

Have I taken good care of my body?

Have I learned anything from all the mistakes I made?

Have I changed to be better?

Have I been kind?

These questions, and a lot more, came storming and conquered my puny mind. I do hope that I can answer those questions honestly, and do something to change my answers if I don’t like it.

I’ve cheated Death once. I don’t think Death likes to be cheated twice, nor will I be able to cheat it again.

Here’s to Death, the single best invention of Life!

Make Me A Channel of Your Peace

Sometimes life sucks. Sometimes you just want to kill yourself and get it over with. Sometimes those who you trust most, those who you hold dear to your heart, turn out to be the ones who betray you. And because they are the ones who make your life seem worthwhile, the cut feels deeper than it actually is.

There maybe people who can calm you down, remind you that everything is not lost. They’re only humans. They are not perfect. But there is one perfect solution.

This is one of the ways it is sung:

It is the prayer of St. Francis.

Make me a channel of your peace:
Where there is hatred, let me bring your love,
Where there is injury, your pardon, Lord,
And where there’s doubt true faith in you.

Make me a channel of your peace:
Where there’s despair in life, let me bring hope,
Where there is darkness, only light,
And where there’s sadness, ever joy.

O Master, grant that I may never seek
So much to be consoled as to console;
To be understood as to understand,
To be loved, as to love with all my soul!

Make me a channel of your peace:
It is in pardoning that we are pardoned,
In giving of ourselves that we receive,
And in dying that we are born to eternal life.

Humans can’t save you. You can’t even save yourself. But He in who we trust, He will take care of you.

Humans sleep. They eat, they go to work, they ignore, they lie. They do all kinds of bad stuff. But He will always, always be available.

I hope you‘ll find your peace soon.

You Could Be The One

I seldom post a song, let alone a video clip. But this song has been in my head since I don’t know when, and I love this arrangement with all the strings and everything…

Nobody wants to be alone
The heart beats happy when it has a place
And if it doesn’t have a home
It can come into my space

So you can be the one I love
I can be the one you long for
You can be the one I want… want
And you can be the one I love
This could be our world wide open
You can be the one I want… want

When you’ve fallen for someone
But that someone doesn’t feel the same
But before you come undone
You can call out my name

So you can be the one I love
I can be the one you long for
You can be the one I want… want
And you can be the one I love
This could be our world wide open
You can be the one I want… want

So you can be the one… one one one
I can be the one… one one one
So you can be the one… one one one
I can be the one… one one one

So you can be the one I love
I can be the one you long for
You can be the one I want… want
And you can be the one I love
This could be our world wide open
You can be the one I want… want

I miss my headphones…

Vanilla Me

I realize that just a few months ago I posted about how I should be thankful, how no one was able to be a perfect friend, and that my friends are good enough for me. Well, I just had this thought…

This is not a gripe. Just a thought.

What if… I didn’t have all the things I have right now? What if I didn’t have a 32-inch LED TV? What if I didn’t have a motorbike? What if I didn’t have a MacBook? Or a sound system set? A gym membership?

What if I didn’t know a thing about programming? What if I was stupid? What if I had no arms or no legs or no limbs at all? What if I had that nasty tumor attack me once more and I bleed to an almost certain death?

Nah, it’s getting too extreme… Let’s take a few steps back…

What if I was just… me? Plain-old-me. Vanilla me. No possessions. No wealth. No skills.

Just. Me.

Would you still be my friend? Would you still want to be a friend to me?

Would you ask if I wanted to go to the beach? Would you text me or buzz me just to see if I’m OK? Would you care if I hadn’t eaten lunch? Would you tell me how your mom scolded your sister because she went out with the wrong boy? Would you share a bowl of fruits with me because both of us couldn’t afford a full meal? Would you ask me to meet up just so we could talk about anything and everything until both of us couldn’t keep our eyes open anymore?

Would you?