linux

Install Tomcat on Fedora VM for @msdev

This is continuation from Previous article on how to create a Fedora VM, with SFTP installed/configured (https://gridwizard.wordpress.com/2014/12/26/setup-linux-vm-with-sftp-guide-for-msdev). This article is for @msdev who’re unfamiliar with Linux environment.

STEP 1. Download Java SDK (it includes JRE). Then install Java on linux box under path /usr/java/jdk and /usr/java/jre
You may download from your Windows development box, then follow these instructions (https://gridwizard.wordpress.com/2014/12/26/setup-linux-vm-with-sftp-guide-for-msdev) to upload package to your Linux server box via SFTP.
@msdev, if you’re not familiar with Linux commands, the following commands may be handy.
cd /usr
mkdir java
cd /home/johndoe
mv jdk-8u25-linux-i586.gz /usr/java
tar -xvf jdk-8u25-linux-i586.gz
Also in case if you want to delete something:
rmdir ./SomeDirectory (SomeDirectory must be empty)
rm -rf ./SomeDirectory    (non-empty directory)
rm SomeFile (Delete a file)
Also to set environment variables for java Temporarily:
export PATH=
/usr/java/jdk1.8.0_25/bin:$PATH

To set the env var permanently, add the same line to ~/.bashrc.

export PATH=/usr/java/jdk1.8.0_25/bin:$PATH

STEP 2. Download and install Apache Tomcat under path /usr/apache/tomcat
Download Tar.gz package from here: http://tomcat.apache.org/download-70.cgi

To configure JAVA_HOME and CATALINA_HOME, place a setenv.sh in the the /usr/apache/tomcat/apache-tomcat-7.0.57/bin directory with

JAVA_HOME=/usr/java/jdk1.8.0_25/
JRE_HOME=/usr/java/jdk1.8.0_25/jre
CATALINA_HOME=/usr/apache/tomcat/apache-tomcat-7.0.57

http://stackoverflow.com/questions/1698913/how-to-set-java-home-in-tomcat-config

STEP 3. Start Tomcat

Navigate to /usr/apache/tomcat/apache-tomcat-7.0.57/bin

startup.sh

From your Windows box hosting the VM, you can access the default webpage hosted by Tomcat. Test from Browser:

http://192.168.56.102:8080/

8080 is Tomcat default port, which can be changed from server.xml in conf folder. http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port

Next, we’ll discuss how to develop a simple Java-WS (Web Service), put it on Fedora VM (on VirtualBox), the consume it from a dotnet Console Application on Windows box.

Happy Coding!

Advertisements

Setup Linux VM with SFTP, Guide for @msdev

This article will quickly shows, in particular for #msdev who’re not familiar with Linux, how to set up a 32 bit Fedora VM with VirtualBox, and setup a SFTP server, then connect from Filezilla client from Windows machine hosting the Fedora VM.

STEP 1. Create Linux VM on VirtualBox. First, download vdi/vmdk image of Linux operating system. Google for “vdi vmdk Ubuntu” for example. Make sure you download an x64 image with username/pwd specified! Similar for SuSE, Fedora …etc

Ubuntu x64

http://www.osboxes.org/ubuntu/                           (username: osboxes, pwd: osboxes.org)

Ubuntu-14.10_64bit.7z

Ubuntu_12.04-64bit.7z

http://imagesvm.sourceforge.net/                        (username: vuser, pwd: vuser)

ubuntu-12.04-lts-x64-en.vdi.bz2

ubuntu-12.04.2-lts-server-x64-en-2tb.7z

Fedora x86

http://cable2.cs.ucdavis.edu/FedoraVM.rar        (username: root, pwd: Pwl!ghsnts.)

http://virtualboxes.org/images/

This version has Desktop pre-installed.

    Link: https://sourceforge.net/projects/virtualboximage/files/Fedora/17/Fedora-17-x86.7z
    Active user account(s) (username/password): root/reverse, fedora/reverse

 

Then follow these instructions.

http://csifdocs.cs.ucdavis.edu/documentation/archives/csif-fedora-on-a-virtual-machine

Don’t forget to check “Enable PAE/NX”

VirtualBox.EnablePAENX

And add a second Network Adapter if your first Adapter is configured in NAT mode.

VirtualBox.AddSecondNetworkAdapter

REF: http://ubuntuforums.org/showthread.php?t=1421927

“Please check the network settings of the Ubuntu VM. If it is configured in NAT mode (which is the default mode), then you will not be able to access your windows 7 host from your VM nor will you be able to access your VM from outside. If that is the case, you can add another virtual network adapter to the VM and configure the network mode as “Host-only Adapter”, so that it would get an IP address in the series of “192.168.56.xxx”. Similarly, host will also acquire a virtual NIC and IP address 192.168.56.1. Now you would be able to communicate between the VM and the host using the 192.168.56.x network.”

Please note that if you enabled this Host-only adapter, you wouldn’t be able to for example ping cnn.com

You wouldn’t be able to:

yum repolist all
yum info kernel

Instead you’d get error:

Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again

(Anyway, you’d still need to fix a few things for yum to work. REF: http://digitizor.com/2009/06/17/how-to-fix-the-cannot-retrieve-repository-metadata-repomd-xml-error-in-fedora-11)

Also, if you’re downloading the vm to test mono, try download a supported distribution (Ubuntu, SuSE for example):

http://www.codeproject.com/Articles/9407/Introduction-to-Mono-Your-first-Mono-app

http://www.mono-project.com/download/#download-lin

 

Also, Right-CTRL is default hotkey for VirtualBox to exit mouse capture.

*** The following steps for Fedora ***

STEP 2. Create user account:

groupadd sftp_users

useradd johndoe

passwd johndoe             (Then it will prompt you to enter the pwd for ‘johndoe’. For this exercise, pwd=SomePassw0rd)

usermod -G sftp_users johndoe

http://www.labtestproject.com/linuse/adding_user.html

STEP 3. Then config and start SFTP server like this:

cd /etc/ssh

vi sshd_config

Press INSERT to enter text in vi.

Press ESC when done. Then “:wq!” to save+exit

To set /home as root folder, modify “ChrootDirectory” setting using vi, then hit “wq!”:

ChrootDirectory /home

Also, comment out and add a line like below

#Subsystem sftp /usr/libexec/openssh/sftp-server

Subsystem sftp internal-sft

Then restart the service:

systemctl restart sshd.service

And try connect locally:

sftp johndoe@localhost

Then, try connect to VM from your Windows workstation hosting the VM? From VM command prompt, type ifconfig (not ipconfig) to identify IP address of your VM (2nd Network Adapter).

VirtualBox.ifconfigsf

Then from for example, Filezilla client:

VirtualBox.FilezillaClient

Happy Coding!