Tuesday, September 15, 2015

Installing Ubuntu 14.04 in VirtualBox for NGiNX modules development

For teh first time, after many years with RHEL / FEdora / CentOS family I decded to give a try to Ubuntu. Why? First, because it is the Linux of choice at AWS, after Amazon Linux of course.
Second, in order to learn something different. Third, in order to make some comparison by myself.

First surprise with Ubuntu 14.04.03 which I installed with Oracle VirtualBox (I gave this development VM 4 CPUs, 12 GB RAM, 40GB HD) is that there is no root access. I defined a user during the install and this user got 'sudo' permissions. So either I have to write 'sudo' every time or allow root access. The latest is not recommended, and this explains why the root access is by default disabled at Ubuntu. In general, I agree with the idea that there is no need to run any user process as a root, and for any system I develop I actually define a specific user which such a system uses. So let's see if I can manage it without enabling root account.

After installing a basic server configuration I wanted to add a Desktop so I could add development IDE there. The only thing I needed to run was:
sudo apt-get install ubuntu-desktop
(as per this link) followed by reboot did the job. Next, I added VBox Guest Additions and got a full-screen resizable Desktop. After that I started to look how I can open a terminal window :). This was a real challenge since "Search" for 'xterm' using top-left Ubuntu icon only gave me the reference documentation for that. It did not run the terminal process though.
CTR-ALT-T worked, but I could not find any other app as well, even not a web browser.

Since I do dnot save the snapshot for teh basic server install I decided to give up and re-installed Ubuntu 14.04 server. Once the basic server install was completed I ran
sudo apt-get --install-recommends install ubuntu-desktop
It took about 15 minutes on my i7 Windows 8.1 machine to install all the required packages, and than I got a black screen with no text. As per System Monitor the VirtualBox process was keep writing things on disk and kept using CPU. First time it happened I killed the process after 10 minutes or so and started over. Next time it happened again, so I decided to give it a chance and left it open.
At the end I found out that I just had to press ENTER and the text is now shown again!
sudo reboot now.
I started VirtualBox Guest Additions CDROM, than Rebooted the machine (had to repeat it twice until it worked) and got teh working Desktop environment.

All-in-all, about 4h to get there with trial and errors.

Next, I installet NetBeans 8.1beta for C++/Java/Scala development. It requested to install JDK (8u60). I also had to install GNU C++ compiler:
sudo apt-get install g++
and CMake
sudo apt-get install cmake
I also had to install PCRE, zlib and a few more librbaries on Ubuntu in order to properly build quite a minimal configuration of NGiNX from the sources:
sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev build-essential libssl-dev

Now I configured NGiNX from the source to be installed in a development path:
cd ; ./configure --prefix=/home/david/dev/nginx
It created Makefile in that folder. I started NetBeans with "New C/C++ project from existing source", pointed to that  and got the Netbeans project for NGiNX.

I had to modify Netbeans project (Right-click on project -> Properties)
adding
${MAKE} -f Makefile install 
instead of 
${MAKE} -f Makefile
to Build section,
and adding 
./configure --prefix=/home/david/dev/nginx
to Pre-build section (check "Pre-build" checkbox!)
After all, I got an IDE-compiled running NGiNX.



No comments: