Mar 25, 2013

Set up a Virtual Machine as developer environment

Preparation


As I have already mentioned, for more complicated systems and to emulate the live environment it is suggested to use a separate virtual machine(s) with installed LAMP environment in it.

You will need a virtual machine software, my favorite is the OracleVM VirtualBox: it is lightweight, it has a big comminity and it is free.




We need to get a Linux distribution, since usually there is no need to have a GUI included, I suggest to download an ISO file of a Debian or Ubuntu Server. Further on I will make examples with Ubuntu 12.10.




Installation of Ubuntu


There are tons of descriptions for the topic available, so I would rather skip this.

Access Ubuntu via ssh


If you have not chosen the openssh package installation during the Ubuntu installation, you should do it now:

To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt:

 sudo apt-get install openssh-client  


To install the OpenSSH server application, and related support files, use this command at a terminal prompt:

 sudo apt-get install openssh-server  


You have to add a new network adapter to your virtual machine instance at the host application, choose a "Bridge" option from the "Attached to" dropbox, then in the installed Ubuntu set up the IP address of the adapter:

 nano /etc/network/interfaces  


 auto eth1  
 iface eth1 inet static  
 address 192.168.56.10 # this is the IP address of your guest os  
 netmask 255.255.255.0  

And you should enable it:

  sudo ifup eth1  

If you have done everything fine, you should be able to ssh into you guest OS via ssh client.


Installing Nginx


The Nginx is available as a package, so it can be installed in the following way:

 sudo apt-get install nginx  

Afterwards you need to start it:

 sudo /etc/init.d/nginx start  

If you have no issues during the installation you should see the following screen on load of the http://ubuntu-vm




Installing PHP5


In Ubuntu you can make PHP5 work in Nginx through PHP-FPM, which is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server set by default on port 9000.

 apt-get install php5-fpm  


Set up the Nginx virtualhost


Create a folder for your new virtualhosted application here:

 mkdir /var/www/localhost  


Create a config for the new host:

 sudo nano /etc/nginx/sites-available/localhost  


 server {  
     listen  80; ## listen for ipv4; this line is default and implied  
     #listen  [::]:80 default ipv6only=on; ## listen for ipv6  
     root /var/www/localhost;  
     index index.php index.html index.htm;  
     # Make site accessible from http://ubuntu_localhost/  
     server_name ubuntu_localhost;  
     location / {  
         try_files $uri $uri/ /index.php;  
     }  
     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
     #  
     location ~ \.php$ {  
         #try_files $uri =404;  
         fastcgi_split_path_info ^(.+\.php)(/.+)$;  
         fastcgi_pass 127.0.0.1:9000;  
         fastcgi_index index.php;  
         include fastcgi_params;  
     }  
 }  



Set up your Windows hosts file accordingly :

 192.168.1.10     ubuntu_localhost  

Create a symlink to it in the sites-enabled directory:

 sudo ln -s /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled/localhost  

Restart nginx:

 sudo /etc/init.d/nginx restart  

Create an index.php file in the newly created /var/www/localhost folder with the following content:

 <?php   
 phpinfo();
  



If you have set up everything properly, you should see the phpinfo() page upon loading the http://ubuntu_localhost/




Set up Samba


Here you can find a pretty nice guide how to set up a samba share between the host Windows 7 and guest Ubuntu 12.

Dec 27, 2012

Essential tools for web development (Linux)

I spent most of the day using the Ubuntu OS, which is currently on the 12.10 version and so far the most user friendly and reliable Linux distribution as to me.

I have already created a list of the tools needed in Windows based development, so I'd like to create some parallel between them.


Dec 24, 2012

Essential tools for web development (Windows)

For warming up I would like to describe what kind of applications and tools I am using for web development. Since I am working both on Win 7 and Ubuntu I'd like to separate the list for each platform and start with the tools for Windows first.
(Update: here you can find the list for the Linux platform)

Dec 23, 2012

Here we go...

... few words about myself

I am a Web developer with a 5+ professional experience mostly in PHP/Java development. I have recently changed my location from Hungary to Germany and since almost the last half year I've working and living in a strongly multicultural environment. The last four years I spent with creating different solutions for various e-commerce platforms.

... why have I created a blog?


To be honest, I'm not really sure. I already had a thematic blog before, but I always found excuses to not to post anything on it, so in the end it was like 3-4 post per year. The very last one was published in May.
Although there was so many changes in my professional life and there are so much things I've learnt during the last 8-9 months that are really inspirational so I would like to structurize somehow the gained knowledge, to have a clear overview of my developer experience so far.
Besides that I have found several references before that pointed me that every developer should have a blog. According to them sharing knowledge helps becoming more professional - as you teach you learn - so I hope I can help somebody else too.

... what is the blog about?


I will post about those technological topics and problems I found interesting, mostly regarding the PHP and Web development. I am following such communities as Habrahabr and StackOverflow, so I might to try to evolve some topics from there to my needs.