Archive

Archive for the ‘Joyent SmartOSPlus (Server)’ Category

Apache Web Server on Joyent

March 2, 2012 Leave a comment

Apache Web Server comes installed by default on the SmartOSPlus installation. When I provisioned my machine I had a difficult time finding the Apache directory. To my surprise, it took some time exploring the file system to find the necessary files. Joyent takes a different approach for installing Apache Web Server. Log files are placed with other log files, configuration files are with other configuration files, etc.

It seems most of the the tutorials on the Internet revolve around installing Apache Web Server for personal use. These tutorials expect you to keep the directory structure intact which is clearly different from a Joyent installation.

The important directories are below. This applies to the SmartOSPlus (32 bit) image that Joyent offers. Other OS images may have a different directory structure.

Apache Server Configuration Files:
/opt/local/etc/httpd/

For example, the httpd.conf configuration file is located at:
/opt/local/etc/httpd/httpd.conf

Virtual Host Configuration Files:
/opt/local/etc/httpd/virtualhosts/

For example, the Apache Virtual Host Directive for each of your websites is stored here. If I am hosting http://www.apache.org it would be located at:
/opt/local/etc/httpd/virtualhosts/apache.org.conf

Apache Modules Directory:
/opt/local/lib/httpd/

This is where you will install the mod_jk.so connector for using Tomcat in Apache Web Server.
/opt/local/lib/httpd/mod_jk.so

You will also find mod_alias.so and mod_rewrite.so for URL Rewrites.

Apache Log Files
/var/log/httpd/

You will find access log, error log, module logs, etc. This is a good place to put your mod_jk connector log file and mod_rewrite log files (use mod_rewrite logging for development purposes only).

Setup SSH to connect to Joyent Server

March 2, 2012 Leave a comment

The first step after provisioning your Joyent Server is to connect to it. Please read up on the wiki articles provided at Joyent for setting up a SSH connection. See tutorial for Windows, Mac, Ubuntu Desktop.

Once you have established your connection with your Joyent server, you have several options for logging in via different users. These include:

root
root user is all powerful and should not be used.

admin
admin has elevated privileges which is the account i use for configuring the server.

jill
The user jill is a general purpose user.

Setup SSH Connection using Windows.

Connecting to your Joyent server is an essential part of managing the web server. On Windows computers a terminal emulator is needed for connecting to Joyent servers. This uses SSH (Secure SHell) which is a safe and secure way to connect. For Windows, Joyent recommends you download the PuTTY application as well as PuTTYgen tool.
Install both PuTTY and PuTTYgen with default installation settings. You can download both putty.exe and puttygen.exe from:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Follow this video tutorial on using puttygen to create a public/private key.

Once your public key is created; copy it to the clipboard and paste in Joyent Administration control panel under SSH Keys. This is where you register your SSH Keys for each computer that is connecting to the server.

SSH Key Settings for Joyent Server:
Key Type: SSH-2 RSA
Number of Bits: 4096

Joyent SSH Key Settings

Configure PuTTY to Connect to Joyent (Windows)

Configuring Putty to connect to Joyent Server is simple.

1. IP Address. Enter your Joyent Public IP Address in the Host Name text field.

2. Port. Set port to 22

3. Connection Type. Select SSH as Connection Type.

4. Private Key File.In “Category” TreeView component, open SSH node, select Auth Node. Under authentication parameters, browse to your private key file that you created using the puttygen tool. This file will have a .ppk file extension. [See image 2].

5. Save. Go back to main screen by selecting Session Node in the tree view and click Save to save your connection details.

Connect to Joyent using PuTTY

Finally, double click your Session to connect. You will enter the terminal session as shown in second photo below. On Windows, you will enter your username; such as root, admin, or any other users. Next enter passphrase for that user.

Joyent Server, Tomcat, Apache Web Server and mod_jk Connector

February 15, 2012 Leave a comment

I just setup a new Joyent Server Smart Machine. I have to admit it was a challenge for me to get it up and running. I am a novice to Linux so this setup came with a steep learning curve. But I say it was worth it from how much I learned. Here is what I did – I hope that something here helps you.

Server Details:
I am running the SmartOSPlus (32bit) Image. This version is recommended for those who want a quick setup and minimal configuration. This package comes with most Linux based tools. Note that a few are different since these machines run Sun Solaris.

SmartOS vs Linux.

At Joyent you have the option of a Linux or Solaris (SmartOS) installation. Here are some factors to consider that might help you make a decision on which OS to choose.

Linux instances run on top of KVM Hypervisor on SmartOS in the Joyent Cloud.  By doing this, a lot of the built in performance/instant scalability features of SmartOS are disabled as they do not work beyond the hypervisor.  The specifics are listed out below:

SmartOS gives you several advantages over Linux.  They include:

  1. ARC for caching of files in memory on each server
  2. CPU bursting for flash incidents that require more compute – no cost for this.
  3. Live resize w/o reboot of RAM (up and down) via API or my.joyentcloud.com dashboard
  4. Full and deep integration of Cloud Analytics.  Linux does not have as deep of integration as SmartOS does.
  5. SmartOS is still UNIX so your typical LAMP stack works the same way.
  6. SmartOS security patching is done by Joyent as the maintainer of the OS.  Patching of Linux would be your responsibility
  7. SmartOS machines can come preloaded with LAMP stack and has a large repository of additional packages precompiled.
  8. Many GNU tools come loaded to give it the ease of use that Linux has.

My Objective:
Setup a web server. My goal is to migrate from Windows Server running Visual Basic .net web pages to a Linux based platform. I’m freeing my dependency on Microsoft products one day at a time. Yeah! We all will get there when ready, right?

I will discuss each of these:
ssh Connection
Apache Web Server
Tomcat 6
Tomcat Auto Startup/Shutdown
– mod_jk Connector
– MySQL Database Server
– MySQL Workbench
– Website Setup
– SFTP Connection

Useful Links to use during Setup

  • Joyent Wiki
    http://wiki.joyent.com/display/jpc2/JoyentCloud+Home
    This is the wiki provided by Joyent. It provides updated information that pertains to the SmartOS machines.
  • Joyent Administration Settings
    https://my.joyentcloud.com/
    The administration control panel for billing, server credentials, and SSH keys.
  • Virtual/Webmin login
    MY.PUBLIC.IP.ADDRESS:10000
    The virtualmin control panel is located on port 10000 of your public IP address provided by Joyent or any domain name you have pointed to your Joyent Server.

Terms that might be useful:

Here are a couple of terms that you might find beneficial. These terms are specific to Joyent Servers and configurations (im not trying to insult you).

ip address:
Joyent provides two IP addresses. One is the private and the other is public. These can be found in your Administration Settings (my.joyentcloud.com). Login to account settings, click “Machines” Tab, click on your smart machine to view the details. You will see both public and private IP addresses. Your private IP address will start with 192.168.xxx.xxx. The other is your public IP address.

private ip address:
The private IP address is for internal use such as connecting to a dedicated database server, mail server, etc. If you only purchased one server; I dont believe you will be using the private IP address.

public ip address:
The public IP address is the IP address used for pointing all websites you manage. This is also used in SSH connections, MySQL workbench connections, and SFTP connections.

Server reboot.
There are two ways to reboot your server on a Joyent machine. You can reboot from the Joyent Administration control panel (my.joyentcloud.com). Login to your Joyent control panel, navigate to Machine Details and click the “reboot” button. You can update the status by clicking the “refresh status” button as well.

The second option is when logged in a bash shell prompt. This is the better option of the two. This is a graceful reboot. Finish editing any files and get to the point where you are ready for server to reboot.Type:

sudo shutdown -y -i6 -g0

Apache reboot.
To reboot Apache Web Server on Joyent Server. See Apache HTTP Server Control Interface Docs or use one of the commands below:
Reboot Apache:

sudo apachectl restart

Stop Apache:

sudo apachectl stop

Start Apache:

sudo apachectl start

Setup Tomcat on Solaris 11

February 6, 2012 Leave a comment

Here are my steps for installing Tomcat 6 on Solaris 11 server. Begin by securely logging into the server via SSH with administrative control. I am able to login using “admin” user. Admin user has ability to perform most operations without being root. I have chosen to install Tomcat 6 with java 6. I was fortunate to have Apache Web Server already installed when my machine was imaged.

ssh admin@MyIPAddress

Part 1: Find Java on the server

Check Java Version:
java -version

This command simply checks the version of Java. For example, my output looks like:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Find Java Location:
find / -name java 2>/dev/null

This command searches the file system for files with the name java in it. All other output is sent to null. So only the results you are interested in are printed to the terminal screen. I find where java is located on my server:

/opt/local/java/sun6/bin/java

therefore, JAVA_HOME=/opt/local/java/sun6

Confirm Java Location:
For fun, confirm this is correct by running the java -version command using the absolute path. Since the java binary should be located in the bin directory we should be able to check the version and get the output. If successful, we have what we are looking for. This step probably isn’t necessary. Its nice to have the confirmation.

/opt/local/java/sun6/bin/java -version

The results are:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Write down the path to our java directory. We will add this to the Manifest entry later as an environment variable.

Download Tomcat 6

Now download Tomcat 6.
Using firefox browser: go to Tomcat website and pick a download location. Here is one for example: http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

Copy the link. Return to SSH terminal and wget to download the compressed zipped tarball file. Type wget command. Right click and paste the url.

wget http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

The apache-tomcat-6.0.35.tar.gz tarball should be in the user home directory.

Checksum – validate the download
Verify your download has not been tampered with using the checksum. I will use the md5 encryption key. The checksum keys are found beside your binary download link on the tomcat website. For example, when running the md5sum command; we should have a matching checksum value.

md5sum apache-tomcat-6.0.35.tar.gz

The output from the command above is:

171d255cd60894b29a41684ce0ff93a8  apache-tomcat-6.0.35.tar.gz

When comparing this against the checksum value saved in the md5 link on the tomcat website we see these match. So it is safe to install software on our server.

Extract and move tomcat directory to permanent location
Its time to move tomcat directory to a meaningful location. Note I am new to Linux and Solaris so I may take additional (and unnecessary) installation steps. For example, I extract and move the tomcat directory as root user. Then I change the ownership of the directory. This may be an extra step. That is ok with me at this time. Please do as you see fit.

Different sources on the Internet say to put tomcat directory here or there. I chose to put in with java directory. I figure its just a location. You chose what makes sense to you please.

I will store in the directory: /opt/local/java

sudo mv apache-tomcat-6.0.35.tar.gz /opt/local/java/apache-tomcat-6.0.35.tar.gz

Verify it moved:

cd /opt/local/java; ls;

Extract it.

sudo tar xzvf apache-tomcat-6.0.35.tar.gz

The switches for the tar command are:
x – Extract the contents of the archive.
z – Decompress the files using gzip utility.
v – Verbose, display the output of stdout so you can see what is happening.
f – Filename, specifices that we are providing a file name.

Rename directory:
Once extracted, rename the directory to something meaningful. I choose tomcat6.

sudo mv apache-tomcat-6.0.35 tomcat6; ls

The tomcat directory should now be /opt/local/java/tomcat6.

Create Tomcat User and Group

Now its time to create the tomcat user who belongs to the tomcat group.

Create a tomcat group:

groupadd tomcat

Create a tomcat user:

useradd -s /bin/bash -g tomcat -m tomcat

The switches for the useradd command are:
s – Specifices the absolute pathname to the shell used for the user account.
g – Specifies a new primary group for the user account.
m -Specifies that a home directory should be created for the user account.

Assign a password to tomcat user:

passwd tomcat

To edit the tomcat user settings using /etc/passwd file:

sudo vi /etc/passwd

Change ownership of Tomcat directory:

Go to the directory where tomcat6 is stored. I am logged in as admin so i will run sudo commands to change ownership (chown and chgrp).  Note the -R switch is used to change permissions recursively throughout the tomcat6 directory tree.

cd /opt/local/java
sudo chown -R tomcat6 tomcat
sudo chgrp -R tomcat6 tomcat

Tomcat is ready.

Verify Tomcat Server is running:

Turn on Tomcat 6:
sudo /opt/local/java/tomcat6/bin/startup.sh

If you’ve setup environment variable for CATALINA_HOME:

sudo $CATALINA_HOME/bin/startup.sh

Immediate output might resemble:

sudo sh startup.sh
Using CATALINA_BASE:   /opt/local/java/tomcat6
Using CATALINA_HOME:   /opt/local/java/tomcat6
Using CATALINA_TMPDIR: /opt/local/java/tomcat6/temp
Using JRE_HOME:        /opt/local
Using CLASSPATH:       /opt/local/java/tomcat6/bin/bootstrap.jar

View in browser: http://localhost:8080.

To shutdown Tomcat Server.

sudo sh shutdown.sh

Now its time to create a service to start/stop Tomcat Server when the Joyent Server is rebooted.