Access Apache on VirtualBox OS from Host OS

Problem

You have a RHEL or CentOS 6 VirtualBox Virtual Machine and a Windows or other host and would like to access a web server on the VM from the Host OS.

Solution

Assure that the Apache Web Server is available and started on the guest OS:

`sudo httpd start`

Assure that firewall allows the guest OS to handle web requests.

Type ` sudo system-config-firewall` and enable the WWW service.

Configure port forwarding for the VM. Go to the VM settings in the Oracle VM VirtualBox Manager / Page ‘Network’.

Click on the button [Port Forwarding] and add an entry such as the following:

Now, on your host OS, you should be able to see the Apache Server test page when opening `http://localhost:8080` in a browser.

Troubleshooting

Since every system is configured differently there might be some problems you encounter. If you don’t see the test page, you could try the following:

  • Disable SELinux by opening the file ` /etc/selinux/config` and setting the configuration to ` SELINUX=disabled` (see a more detailed guide here)
  • This tutorial assumes that you use the default NAT network adapter for you VM. If you use a ‘host-only’ or ‘bridged’ connection, the process will be a bit different.

References

Stackoverflow – How to SSH to a VirtualBox guest externally through a host? Very helpful, also read the comments

Stackoverflow – Apache restart causes DocumentRoot must be a directory, even though it is a directory and there seem to be no privilege issues

CentOS Board – Basic firewall config (just port 80 and ssh 22)

 

Import GitHub project to Android Studio

Problem

You have an existing GitHub project and would like to import it to Android Studio.

Solution

Perform the following steps to import your project.

Step 1: Install git for Windows

It can be downloaded for free from git-scm.com.

Most settings available during the installation process should be compatible with Android studio. Just choose the settings you deem the most appropriate.

Step 2: Link git executable to Android Studio

Open Android Studio and got to Settings. In the Setting dialog open the page Version Control / Git. Here define the path to the git executable you have just installed.

Step 3: Get the Path to your Repository from Github

Go to the GitHub page and get the HTTPs path to your repository. For instance:

https://github.com/mxro/WallOfTheWiseAndroid.git

Step 4: Import the Git project to Android Studio

Go to Android Studio and go to Menu / VCS / Checkout from Version Control / Git

Paste the HTTPS path you obtained from GitHub in the previous step and click on [Clone].

Provide your GitHub username and password.

Now the project should be imported to Android Studio and you should be able to commit and push future changes back to GitHub.

References

Android Studio Git Tutorial (Part 1) « Wii’s Blog

github – How to clone a remote git repository with Android Studio? – Stack Overflow

Setup Android Developer Studio | devroyal.de

Setting Up eclipse Luna with Maven for Android

As of August 2014, don’t even try this.

Officially, the Google Eclipse plugin supports Eclipse 4.4 (Luna) at present. However, in order to be able to create projects which are both Maven projects and Android projects you will need to install the m2e-android plugin. This currently does not support eclipse Luna. Probably, if you create a new Android project based on the archetype suggested by the m2e-android plugin, you might get errors such as:

  • …R cannot be resolved to a variable
  • Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (execution: default-generate-sources, phase: generate-sources)
  • Project configurator “me.gladwell.eclipse.m2e.android.androidDevelopmentToolsProjectConfigurator” is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.
  • Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:proguard (execution: default-proguard, phase: process-classes)

My recommendation is to use Android Studio.

You can easily add Maven dependencies to projects in Android Studio. Just locate the ‘build.gradle’ file in your application directory and add a compile dependency.