Setting Up Amazon's AMTU on a Linux Server

This is post is now quite old and the the information it contains may be out of date or innacurate.

If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub

Amazon helpfully supply a java package called AMTU which does the grunt work of the XML integration for Amazon marketplace. With AMTU you can easily update products, stock levels, prices and also grab order info etc.

Being based on Java, AMTU can run on pretty much any operating system. It uses a “hot folder” system so integration with client systems is as simple as dropping files into certain folders.

There are some good instructions for setting up AMTU on windows. That’s great if you want to run it on your desktop (or a windows server if you are that way inclinded…. :-) ). However if you are one of my clients you are running a Linux server and need it setting up on there.

Unfortunately the documentation for AMTU on Linux is pretty lightweight. This blog post aims to help out anyone struggling with getting AMTU working on their server.

Before you start. Open up the README file (just download the package to your local machine). Have a quick read through and then understand that the README is simply wrong. It is a guide at best, but not strict instructions. They definitely haven’t made it easy for us.

Speaking to Amazon about this, it is apparent that AMTU was developed by someone who is no longer around to support it. They have released it as open source software and basically left us to it. They are not willing to support it themselves.

Here’s my instructions:

1. Log into SSH as root on your server. Using your favourite SSH client. If you use linux you can just use the terminal, definitely my favourite way of handling SSH.

2. Navigate to the root folder that you want to install AMTU to.

cd /opt

3. Download the AMTU Files


mkdir amtu

cd amtu

wget http://freefr.dl.sourceforge.net/sourceforge/amtu/amtu-linux-1.0.9.tar.gz

4. Unpack the Archive


tar -xvf amtu-linux-1.0.9.tar.gz

5. Edit the config files

<strong>5.1</strong> Find your JAVA_HOME

This may change depending on what version of Linux you are using. If you are not sure then use the following command to find out:

```

cat /etc/issue


	The following command will show you which Java version you are running. If you are it doesn't work then it looks like you don't have Java installed. Please see <a href="#aa"><b>Apendix A</b></a> for Java install instructions.
	
	```
 java -version
You need to find out the exact path for java. You can use this command:

```

find / -name java

	
	This will display a few lines. There is usually only one Java folder though with the others being symlinks (shortcuts kind of ) to the Java folder.
	
	<strong>5.2 Edit the Install.sh File</strong>
	
	First get into the AMTU folder:
	
	```
 cd /opt/amtu/
Now make sure you have your path to the JRE noted down somewhere and open up the install.sh for editing. For me the path is /usr/bin/java

```

vi install.sh

	(vi is a text editor for linux. If you are not familiar with it simply search for "vi common commands or something like that).

	Now go to the top of the file and add a new line. Replace /usr/bin/java with your own path to Java.
	
	```

	export JAVA_HOME=/usr/bin/java
	

6. Run the Install Script

First we need to make the install script executable.

 chmod a+x install.sh

Now run the install script.

./install.sh

7. Configure AMTU

This is where it gets interesting. AMTU is installed, but you haven’t given it any kind of information regarding your Amazon account so how will it be able to connect to your specific account??

You need to use the configure.sh script to do this. For me this wouldn’t work until I edited it and ran it manually. There is a configure.sh in the root amtu folder, however all this seems to do is run the configure script in the service folder.

Lets go straight to the service folder and get that one working.


cd /opt/amtu/service/bin

vi configure.sh

In this file they are mixing up the JAVA_HOME variable and appending /bin/java to it. I’m not really sure why they would do this.

First of all try running the script


./configure.sh

If you get an error like:

./configure.sh: line 3: /bin/java: No such file or directory

Then you will need to edit the file. For me to get it to work I had to remove the following:

$JAVA_HOME/bin/java

and simply replace it with my path to Java which is:

/usr/bin/java

Then run the script again and it will ask you a bunch of questions. For most questions the default answers seem fine to me. You will need to know your SMTP details. You will want to log into your seller central account as well so that you can copy relevant details from there.

If it is all successful you should get a message similar to the following:

Please standby while your account details are verified... Ping was successful Updating configuration... done! To alter this configuration, please use the Configuration Utility in the directory you installed this application. Exiting Application

8. Starting the AMTU and Monitor services To start the amt and amt_monitor services you need to manually start them. You can also check the status of these processes.

First get into the bin folder


cd /opt/amtu/service/bin

check status


./amt status

./amt_monitor status

If they are not started simply run the start commands


./amt start

./amt_monitor start

Running these two commands should have created some folders in your DocumentTransport folder. To check this out simply go to the folder and check


cd /opt/amtu/DocumentTransport

ls

You should see a folder called logs and a folder called production. The production folder contains our Hot Folder for sending files up to Amazon.

7. Set up symlinks Once everything is working nicely, you will probably want to create symlinks from folders accessible by PHP.

Navigate to the place that PHP can access and which you would like to place a symlink to the production/outgoing folder. Then use the following command - replace the details as necessary


cd /home/path/to/php/accessible

ln -s /opt/amtu/DocumentTransport/production/outgoing my_amtu_symlink_folder_name

8. Test it Out All you need to do to test it out is to drop a file into the /opt/amtu/DocumentTransport/production/outgoing folder (or the symlink to this folder that you have just created). Then wait 5 minutes (cup of tea time) and come back. Now browse through the production folders. If the file is in the /sent folder then your upload has worked OK. If it is in the /failed folder then something has gone wrong.

If like me it didn’t work (surprise surprise) then you need to examine the log files to find out what the problem is. The best log to look in to start with is the audit_log.


cd /opt/amtu/DocumentTransport/logs
vi amtu_audit.log

To go to the bottom of the file use the vi shortcut ```shift +[g]

As for figuring out exactly why AMTU doesn’t like your feed file, I leave that bit to you.


Appendix

A. Install Java

These are instructions for a CentOS Linux install. Your Linux might be a different flavour. Simply search around for instructions for your specific setup.

A.1 Download JRE

Go <a href="http://java.sun.com/javase/downloads/index.jsp">to the Java downloads page</a>
Find the link to the Linux Java JRE bin. (For CentOS you need the rpm version). Copy the link to your clipboard

[code]
cd opt
wget {link from clipboard for JRE download}

	This will download the file. However as it is accessed via a script, it will give it a crazy long filename. Lets just rename that first. To rename a file with special characters simply wrap the filename in "" otherwise it won't work.

	```

	ls
	
now copy the filename to your clipboard

now paste it into this command 

```

mv “filename from clipboard” jre-rpm.bin


	Now we need to set the file as executable

	```
 chmod a+x jre-rpm.bin
	
Now we install it 

```

./jre-rpm.bin

	This will then flash up a bunch of terms and conditions. Just hold down [return] until you get to the bottom, then type "yes".

	To check its all installed use the command 
	```
 java -version
You should get something similar to the following:

java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)

References installing the latest jre on centos 5 AMTU Homepage AMTU Forum - not much of use in there unfortunately


Tags: amazon marketplacesellercentralamtuxml integration