Tuesday, May 15, 2012

VirtualBox on headless CentOS 6

Due to the need to install a server which will be used mainly for hosting virtual machines, but also be capable to provide other services, such as being FTP and Samba server, I decided to go with the CentOS Linux, without having X windows and such unnecessary things installed, Oracle’s VirtualBox, and the PHP front-end for it called phpVirtualBox.
Anyway, to make a long story short, here’s how to do it.

First of, obviously, we’ll need to install CentOS on the machine. The only thing that should be highlighted about this phase is to choose the Basic Server installation method and let the installation process finish.

Once the installation is finished and the system is up and running the first thing that we should do is to login as root and update it:
yum -y update
After the update is finished reboot the machine to make it boot into the fresh new kernel.

Next, the regular user should be added to the system:
useradd reguser
and, to unlock newly created user account and set the password:
passwd reguser

The following two steps aren’t really necessary, but since I’m running this server inside the LAN, and don’t need SELinux and firewall to be enabled I disabled all of those.

Disable SELinux by editing the /etc/selinux/config file and changing the value of SELINUX variable from enforcing to disabled. This change will take effect after the machine is rebooted. To disable SELinux right away type:
setenforce 0

Disabling iptables firewall consists of the following commands:
service iptables save
service iptables stop
chkconfig iptables off
service ip6tables save
service ip6tables stop
chkconfig ip6tables off

After all that we will need to install Apache web server, PHP and PHP SOAP extension (which is needed by the phpVirtualBox to operate properly), start Apache web server and set it to start automatically on boot (didn’t need to edit the Apache config file, since the default one was just fine for me):
yum -y install httpd php php-soap
service httpd start
chkconfig httpd on

We will also need to install the Development Tools group, which is a prerequisite for VirtualBox kernel modules to compile:
yum -y groupinstall "Development Tools"

After that, we add the VirtualBox repository to the list of the repositories on our system.
wget -O /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

Now it’s time to install VirtualBox:
yum -y install VirtualBox-4.1

Once the installation is done add the regular user to the vboxusers user group:
usermod -G vboxusers reguser

Download and unzip the latest version of the phpVirtualBox:
wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt`
unzip phpvirtualbox-*.zip

Then, copy the phpVirtualBox files to the Apache Documents Root directory:
cp -r phpvirtualbox-*/* /var/www/html/

Next, copy and edit the phpVirtualBox configuration file:
cp /var/www/html/config.php-example /var/www/html/config.php
vim /var/www/html/config.php
The username and password variables within this file should be changed to reflect the values set for regular user, under whose credentials we will run VirtualBox, for example:
var $username = 'reguser';
var $password = 'verycomplexpass';

If not already present create the config file for the VirtualBox web service (/etc/default/virtualbox). This file should contain at least the VBOXWEB_USER variable. My system didn’t have it so I just put this one variable into it:
echo "VBOXWEB_USER='reguser'" > /etc/default/virtualbox

Now start the vboxweb service and configure it to start automatically on boot:
service vboxweb-service start
chkconfig vboxweb-service on

Enable USB support in VirtualBox:
mkdir /vbusbfs
echo "none /vbusbfs usbfs rw,devgid=$(awk -F : '/vboxusers/ {print $3}' /etc/group),devmode=664 0 0" >> /etc/fstab
mount -a

Install the VirtualBox Extension Pack (has to be the same version as VirtualBox itself, and is required in order to be able to run the guest’s console through web interface):
wget http://download.virtualbox.org/virtualbox/4.1.10/Oracle_VM_VirtualBox_Extension_Pack-4.1.10-76795.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.10-76795.vbox-extpack

After all that, install the custom init script to start and stop virtual machines automatically on startup and shutdown:
wget http://www.dzinovic.net/dl-files/vmsctrl/vbox/vmsctrl.tar.gz
tar xvzf vmsctrl.tar.gz -C /etc/init.d/
chkconfig --add vmsctrl

Last, but not least, make your system automatically recompile VirtualBox kernel modules on kernel update:
wget http://www.dzinovic.net/dl-files/vmsctrl/vbox/VBoxCompileInstall
chmod +x VBoxCompileInstall
./VBoxCompileInstall
The original of the above script was found here and modified a bit to match CentOS.

That should be it, now reboot your machine once more for everything to settle up, and once it’s up connect to the phpVirtualBox interface by simply typing the IP address of your server into your web browser.
Default username/password combination is admin/admin.
<Sưu tầm Dzinovic>

Wednesday, September 28, 2011

Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?

The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).

Tuesday, August 30, 2011

Apache Web using POP3 Auth

Install Auth mechanism.
cpan install Apache::AuthPOP3
cpan install Net::POP3

Apache configuration
httpd.conf
ServerName userweb.linuxreaders.com
DocumentRoot /home/userweb
DirectoryIndex index.html
PerlModule Apache::AuthDBI
AuthName "Enter your Email ID & Password"
AuthType Basic
PerlAuthenHandler Apache::AuthPOP3
PerlSetVar        MailHost pop.linuxreaders.com
#PerlSetVar        UserMap pop3user1=>realname1,pop3user2=>realname2
Require valid-user 
 
 

Wednesday, July 6, 2011

Mysql command

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Wednesday, January 12, 2011

This is a linux command line reference for common operations.

CommandDescription
apropos whatisShow commands pertinent to string. See also threadsafe
man -t ascii | ps2pdf - > ascii.pdfmake a pdf of a manual page
 which commandShow full path name of command
 time commandSee how long a command takes
time catStart stopwatch. Ctrl-d to stop. See also sw
dir navigation

Tuesday, December 28, 2010

Cài đặt và cấu hình Subversion


1-      Cài đặt apache và svn:  yum install --exclude=*.i386 httpd* mod_dav_svn
2-      Cấu hình web apache:  vi /etc/httpd/conf.d/subversion.conf

+ Đường dẫn lưu trú của repos : /var/www/svn/kimsach/
            Cách tạo:
            #mkdir /var/www/svn
            #svnadmin create /var/www/svn/kimsach

Thursday, December 16, 2010

Checking the file attributes using lsattr

lsattr is a command line program for listing the attributes on a Linux second extended file system
It is also a command to display attributes of devices on an AIX operating system