Thursday, May 9, 2013

How to build a virtual web server and enable access from external network (Windows 8, CentOS 6, VMware Workstation)


I am faced with a task where I have to build a development webserver on a notebook, spesifically a Lenovo ThinkPad Twist (Intel Core i7, 8GB RAM, Windows 8 64-bit).
I would not use werbserver package such as XAMPP werbserver, PHPTriad, etc, to avoid incompatibility issues at the time of deployment later.
It means, I must build a pure web server environment, and for that I would use CentOS operating system.

Since the ThinkPad Twist already came with an original Windows 8, so I'm not going to use a dual-boot approach. The only way is to install CentOS virtual guest host on Windows 8 with VMware Workstation.

Concern that must be achieved are:
  • Host OS is Windows 8 64-bit 
  • Guest OS is Linux CentOS 6.4 Final 
  • Apache web server running on Guest OS
  • MySQL database server running on Guest OS 
  • The web server on Guest OS must be accessible from the Host OS 
  • The web server on Guest OS must also be accessible from the external network, for colaborative development needs. (Allows access to SSH, HTTP, and MySQL to Guest webserver) 

 I will explain how to make it, step by step:

Devices :  

  1. Lenovo ThinkPad Twist (Intel Core i7, 8GB RAM, Windows 8 64-bit) as the host, also installed VMWare Workstation 9.0 with 64-bit CentOS 6.4 as a guest OS that will act as a webserver. Let assume the IP address for this notebook is 10.2.2.213 
  2. Lenovo ThinkPad X100e (AMD Athlon Neo MV-40, 2GB of RAM, Windows 7 64-bit), act as the client computer that needs access to webserver. The IP address is 10.2.2.214

Installation: 

I'm not going to explain how to install CentOS guest OS, I assume you've understand how to install a guest OS in VMWare Workstation. Maybe, if there is some free time, I will write it in a separate article.

Once the OS has been installed in VMWare Centos, it is advisable to install VMWare Tools.
Next step, is to install the necessary packages:

Apache2 Webserver:
yum install httpd
chkconfig - levels 235 httpd on
/etc/init.d/httpd start

MySQL database server:
yum install mysql-server mysql
chkconfig - levels 235 mysqld on
/etc/init.d/mysqld start

PHP5:
yum install php
/etc/init.d/httpd restart

MySQL Support in PHP5:
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
/etc/init.d/httpd restart

Enable SSH daemon:
chkconfig - levels 235 sshd on
service sshd start

Let's make sure everything is going well:
[root@localhost ~]# service httpd status; service mysqld status; service sshd status
httpd (pid 2490) is running ...
mysqld (pid 2355) is running ...
openssh-daemon (pid 3760) is running ...

Then, try to direct your browser to http://localhost

Apache2 Test Page


NAT Settings: 

OK, next we will configure the NAT (Network Address Translation) in VMWare Workstation.
First, give a static IP on the guest OS. In this case, I give the IP address with 192.168.222.128. Please write down the IP somewhere, we will need it later.



On VMware, choose Edit > Virtual Network Editor menu. In the dialog that appears, select VMnet8 adapter with external NAT connection, then press the NAT Settings button.



On NAT Settings, we will do some port forwarding. The principle, if there is a request to port XXX on the host OS, it will be forwarded (forwarding) to YYY ports in the guest OS.

We will forward some ports  as follows:
Host IP Port Guest IP Port
127.0.0.1 8888 192.168.222.128 80
127.0.0.1 3333 192.168.222.128 3306
127.0.0.1 2222 192.168.222.128 22



The final result will be like this:



Now back to the host OS (Windows 8), I open the browser, navigate to http://127.0.0.1:8888, and hooplaa... it works !
 
So how to access the webserver from external network? Simple, just point your browser to the IP address of the host computer and adding the port number that we've specified above. For example htpp://10.2.2.213:8888

For SSH access, use the 10.2.2.213 IP address on port 2222
For accessing MySQL Databases remotely, use 10.2.2.213 IP address on port 3333


OK guys, i hope this article will helps :-)
drop me ur comment

Sunday, May 5, 2013

CentOS : yum install problems - [Errno 14] Could not open / read file

Today I've just finished installing CentOS guest in VirtualBox for development server needs. As usual, the first thing I did was to install my favorite file editor / commander , the Midnight Commander (mc). But a strange thing happened when I tried to install mc:
[root@localhost ~]# yum install mc
Loaded plugins: fastestmirror, refresh-PackageKit, security
Loading mirror speeds from cached hostfile
 * Base: ossm.utm.my
 * C6-media:
 * Centosplus: ossm.utm.my
 * Extras: ossm.utm.my
 * Updates: ossm.utm.myfile :///media/CentOS/repodata/repomd.xml: 
[Errno 14] Could not open / read file :///media/CentOS/repodata/repomd.xml
Trying other mirror.file :///media/cdrecorder/repodata/repomd.xml: 
[Errno 14] Could not open / read file :///media/cdrecorder/repodata/repomd.xml
Trying other mirror.file :///media/cdrom/repodata/repomd.xml: 
[Errno 14] Could not open / read file :///media/cdrom/repodata/repomd.xml
Trying other mirror.Error: Can not retrieve repository metadata (repomd.xml) for repository: c6-media. 
Please verify its path and try again
After searching for the cause, I can solved this problem quite easy. First, edit this file :
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Media.repo
Find a line labelled "enabled=1", then change its value into "enabled=0" (without quotes). Save the file, and try to repeat the installation.
[root@localhost ~]# yum install mc
Loaded plugins: fastestmirror, refresh-PackageKit, security
Loading mirror speeds from cached hostfile
 * Base: ossm.utm.my
 * Centosplus: ossm.utm.my
 * Extras: ossm.utm.my
 * Updates: ossm.utm.my
Setting up Install Process
Resolving Dependencies-> Running transaction check---> Package mc.x86_64 1:4.7.0.2-3. El6 will be installed
-> Finished Dependency Resolution
Dependencies Resolved================================================== 
Package Arch Version Repository Size===================================
Installing:
 mc x86_64 1:4.7.0.2-3. el6 base 1.6 M
Transaction Summary
=======================================================================
Install 1 Package (s)Total download size: 1.6 M
Installed size: 5.4 M
Is this ok [y / N]: y

Downloading Packages:mc-4.7.0.2-3.el6.x86_64.rpm | 1.6 MB 00:42
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: 1: mc-4.7.0.2-3.el6.x86_64 1/1
  Verifying: 1: mc-4.7.0.2-3.el6.x86_64 1/1Installed:
  mc.x86_64 1:4.7.0.2-3. el6
Complete!
[root@localhost ~]#

Saturday, May 4, 2013

Huawei Mobile Partner for Windows 8

Huawei - Windows 8

The first problem I've experienced when trying Windows 8 for the first time is when I try to stick my HSDPA USB modem, Huawei E160E into my notebook and Windows 8 does not recognize it at all.

The problem is because the default driver inside the modem is not compatible with Windows 8. The solution is to upgrade the Mobile Partner's
software with the latest version (currently version 23.009.09.00.983 UTPs). You can download it here

Done! My Huawei E160E now is recognized well by Windows 8!
This driver also compatible with any types of Huawei's modems.

Hopefully this can help you whom experiencing similar problems