TurnKey Linux Virtual Appliance Library

TKLPatch for Magento

adrianmoya's picture


If you're thinking on launching an online store, Magento is one of the most popular options out there. This TKLPatch will convert turnkey core into a complete, feature-rich ecommerce platform ready to begin working on your online store! 


Latest version of Magento (
http and https access configured (admin areas uses https)
setupdomain script to easily set up your domain once you are ready to go live. (Convenience)
Default user: admin 
Default password: turnkey123
To change default settings used during installation, once you got your appliance running, just go to https://your-ip/admin. Log in and you can change the settings in:
System->My Account (User and password)
System->Configuration->General->Locale options (For locale options)
System->Configuration->Currency Setup->Currency Options (For default currency)

What it does

1. Sets Hostname to magento
echo "$HOSTNAME" > /etc/hostname
sed -i "s| \(.*\)| $HOSTNAME|" /etc/hosts
hostname magento
2.Update package information
apt-get update
3. Install required packages
install apache2 php5 mysql-server php5-curl php5-gd php5-mcrypt php5-mysql php-apc postfix php5-cli
4. Extract magento from the previously overlayed tar.gz. (I couldn't find a direct download url for this one). Move it to /var/www
cd /usr/local/src/
tar xzf magento- 
mv magento/ /var/www
5. Create database and user
mysqladmin -u root create magento
mysql -u root <<-END_PRIVS
GRANT ALL PRIVILEGES ON magento.* TO magento@localhost IDENTIFIED BY "magento";
flush privileges;
6. Set some permissions required for installation
chmod 777 /var/www/magento/app/etc/
chmod 777 /var/www/magento/var/
chmod -R 777 /var/www/magento/media/
7. Sets cron job required for some magento features. 
echo "*/5 * * * *  root /usr/bin/php /var/www/magento/cron.php > /dev/null 2>&1" > /etc/cron.d/magento
8. Configure apache sites and modules
a2dissite default default-ssl
a2ensite magento magento-ssl
a2enmod rewrite ssl
9. Stop services
service apache2 stop
service mysql stop

So, when is magento installed?

On firstboot, the server will run a script that installs magento. This is done this way because we leave the installation to generate an encryption key that is used to encrypt passwords and credit card information. So it's important that each installation has it's unique key. If you later need to migrate this installation to other server, you'll need to copy this key to the other server. See magento's documentation for details. To know what's your generated key, just log via ssh and issue the following command:
cat /var/www/magento/app/etc/local.xml | grep key

setupdomain script

The setupdomain script is a script that sets the domain on apache's virtual hosts files so that your installation start working using a FQDN. It also updates the required settings in the magento database. The following is the content of the script:
# Script to setup site domain for magento
# By Adrian Moya

if [ $# != 1 ]; then
  echo "Usage: setupdomain DOMAINNAME"
  echo "Example: setupdomain www.example.com"
sed -r -i "s|ServerName .*|ServerName $1|" /etc/apache2/sites-available/magento
sed -r -i "s|ServerName .*|ServerName $1|" /etc/apache2/sites-available/magento-ssl
mysql -u root -e "UPDATE core_config_data SET value='$DOMAIN' WHERE path='web/unsecure/base_url';" magento
mysql -u root -e "UPDATE core_config_data SET value='$SDOMAIN' WHERE path='web/secure/base_url';" magento
service apache2 reload
echo "Done!"

Known issues:

There seems to be a know issue in magento's admin panel that prevents you from loggin with some browsers. It only happened once in my tests, and the workaround was use firefox to log in. Then I was able to login with chromium (which is my default browser). If you get into this issue, please comment your experience. 

Download Link

Dan Robertson's picture

If you want a direct

If you want a direct download, you could use their svn repository:

svn checkout http://svn.magentocommerce.com/source/branches/1.4

I am not that familiar with SVN though, so I'm not sure if you would want to do anything after that.

Adrian Moya's picture

It can be an svn export


As a checkout leaves undesired .svn directories in each directory. But this method is not recommended as they can commit changes to the repo that can break the patch. Also, they can have some settings targeting the development environment. So its preferably a release file as we can be sure that it won't be changing. But they have some annoying javascript in place preventing to get a direct download url. 

Adrian Moya's picture

This appliance if for turnkey core

You can apply it to turnkey-core-lucid-11rc and is in the process of being converted to an official appliance. Soon there should be a beta of this appliance ready, so if you're not in a hurry, you can simply wait for the official appliance. Else, grab turnkey-core 11RC and apply the patch following the instructions available in the documentation. 

If you need any help, you can ask here in the forums. 

Adrian Moya's picture

No, you must apply the patch with tklpatch

You need to first download turnkey-core-11rc image and then apply the patch attached here with the following procedure:


Sorry is not very easy and straight forward to apply a patch, but as I said before, the patch will soon end up in an official image so that you don't need to do all these steps. 

Review the documentation. Inside the patch there's a overlay directory which is going to be applied automatically when you apply the patch. 

Adrian Moya's picture

You can run the commands directly over ssh

But if you prefer to use webmin, use the Package from APT option. I've never used webmin, I hope it's easy and get the job done. Then try to follow the instructions, yo can also access shellinabox via http://IP:12322 and run the commands there.

Adrian Moya's picture

You can use the file manager on Webmin

To transfer the files to/from the appliance. You'll need to upload the turnkey core iso and later download the patched-iso. 

When you have the pieces in place (the iso and the patch) and you have installed tklpatch, I suggest you log in shell in a box and run the command for patching there. So you can follow what's happening. 

Adrian Moya's picture

Follow the instructions on my previous post

You'll have to:

1.Install Core-Lucid.

2.SSH to the server.

3. apt-get update && apt-get install tklpatch

4. scp a copy of the core iso image to the appliance. OR download one with wget http://url/of/core/appliance

5. wget http://url/of/the/magento/patch

6. tklpatch turnkey-core-lucid.iso magento.tar.gz

7. copy the resulting turnkey-core-lucid-patched.iso to your main system. 

8. Install on a VM to test it. 

There's currently no easier way to do this. Unless you wait to the final release of the appliance. For detailed steps follow the link to the docs. For ways to copy in/copy out the images from the vm, use scp, if you're in windows look for winscp. 

In which step are you in the previous mentioned ones?

Adrian Moya's picture

Please post the output of the command once it's finished

Just to be sure everything went ok. The patch should be named magento.tar.gz so be sure you download it correctly. I suggest you first download it to your PC and the upload it via the file manager to the same folder as the iso. I forgot that it's on rapidshare, so it won't be possible to download it using wget. Sorry about that, this is the only patch that due to it's size (it contains a complete version of magento inside) I had to put on an external repo. 

Adrian Moya's picture

Ok, happy to know you are on your way

That would be the correct size of the file. For joomla you won't need a patch, simply install the turnkey-joomla-11.0RC and you are ready to go. 

Adrian Moya's picture

Use the provided script

L.Arnold, I included an script to make the change of domain (and ip) a breeze. Just log in to the console and run


That should update the magento settings and make it work correctly. 

I hope you don't mind that I'm cleaning this forum thread to remove the messages that are not helpfull for other community members that come to the thread. 

Adrian Moya's picture

You can install the webmin modules

You'll have to do it from the black screen, but it's easy. Log in via ssh. then run:

apt-get update && apt-get install webmin-mysql webmin-apache

That way you'll add those modules to webmin. They should take the default configuration. After that, log in via webmin, and check for the modules. That way you can log into the database through webmin using magento/magento as user/pass.

Jeremy Davis's picture

I'm not sure how Adrian set this one up

But did you run the script from the prompt accessable with SSH? (ie typed the command suggested by Adrian into the 'black screen'?) It should be obvious if it works. If it doesn't, tell us what error it throws up. I'm assuming that you understood that you needed to replace "MYIPORDOMAINNAME" with your actual IP address or domain name. eg:

setupdomain example.com

I'm not 100% sure that Adrian included phpMyAdmin with this device (sorry haven't got time to read the full thread either to find out). If he did, I'd assume that he used the default TKL setup which is to have phphMyAdmin available at https://<ip-address>:12322 (just like Webmin but port 12322 instead of Webmin's 12321). This is where you should find it in the LAMP setup. From memory though, you mention Zend server. In my limited experience with Zend (see my KnowledgeTree patch) it is not currently compatible with phpMyAdmin under Ubuntu (not by default anyway).

If I were you, I'd probably just try to get this running properly on the recommended base (ie TKL Core v11.0RC) and then once you have that all working as expected, then play and tweak etc (eg try patching LAMP, getting phpMyAdmin working, etc). You have a much better chance of working out your problems one-by-one that way and understanding what may be the problem and how to fix it.

Good luck.

Adrian Moya's picture

Not sure what could be

I installed mysql-server from the repos. The bug you post says is for the InnoDB plugin but not the default InnoDB. Anyway, check in the support forums, I think there has been reported an issue regarding InnoDB in the new appliances that maybe could help. 

Jeremy Davis's picture

Just change file permissions.

My reading of the documentation you link to states that to use Magento Connect the preferred way is to temporarily change the permissions on the Magento root folder. The easiest way to do that is to change it to 777 but be aware that while the permissions are set like that anyone who can log into the server can do anything (security risk) - make sure you change it back straight afterwards! You can set file permissions via Filezilla (if you are using it, I imagine WinSCP should be able to do that too) or via Webmin File Manager, or via the commandline like this:

chmod 777 -R /path/to/magento/root/

As stated in the documentation, after you have done your installation/update/whatever you need to return them to '655':

chmod 655 -R /path/to/magento/root/

If you want to go the other route using pear:

I assume that the ./pear referred to in the documentation is a specific version of pear installed with Magento (so I'd guess you didn't need to install pear separately). Probaly best to use the version included with Magento rather than the version you've installed (there are probably different versions and may result in strange things happening).

You need to make sure you are running in the root Magento folder. I suspect you were trying to run the command from the /root folder? (hence not found). Try this:

cd /path/to/magento/root
./pear help

[Edit - hope you don't mind I deleted your other post to tidy up a little]

Jeremy Davis's picture

Make sure you are using SFTP not FTP

It's available form the drop down in the right hand pane of the account manager (or whatever its called - window that comes up when you click the button on the far left of the toolbar).

Jeremy Davis's picture

Changing permissions is a risk but only until you change back

Just don't forget to change them back!

As for your other folders, if possible try to locate the exact files/folders that need access rather than set the whole folder to 777. Also it may be possible to change the ownership to the webserver account (www-data) instead of 777. If you plan on leaving them that way permanently then that would be preferable to 777.

chown www-data:www-data -R /path/to/folder/

This is assuming that Magento runs under the www-data user account (which I'd suspect it does).

Jeremy Davis's picture

Yes do that

If that's what Adrian did in the initial patch, then do that. He is far more knowledgable than me in these things and I would trust his judgement on whether something is an acceptable risk or not.

Also if this is something that is likely to be wanted from time-to-time then it could be worth making it into a script so the process to 'reset' permissions after upgrading/installing could be a single command. May be worthy of addition to the appliance even?

Alon Swartz's picture

Official TurnKey Magento appliance soon to be released

We've already created the official TurnKey Magento appliance, and it will be released along with "part I" of TurnKey 11.0. The images have already been uploaded and are awaiting release, so it should be available for download really really soon.

I'd love to get your feedback on the new appliance as it seems you've got some experience working with the system.

Eric Rosol's picture

cant wait

 i've been working with magento and virtualbox for awhile but i'm new to turnkey. so this is awesome.

Alon Swartz's picture

Appliance available for download

The appliance has already been released and is available for download, though we have yet to create the appliance page for it.

Eric Rosol's picture


Downloaded it this morning... very slick. SOO much better than the VBox, WinXP, WAMP mess I was screwing around with previously. the time this will be saving me is unmeasurable. many thanks

Liraz Siri's picture

Official appliance created

TurnKey Magento was included in TurnKey Linux 11 release (part one), based on Adrian's TKLPatch.

Guest's picture

Use the following to get the latest version

I just whipped up the following to grab the latest version of Magento. I'm a shell script noob (not new to wget, however), but I did test this out and it seems to work fine.


VERSION=$(wget --user-agent="Mozilla/4.0" --tries=20 --timeout=10 --no-directories --verbose -O - http://www.magentocommerce.com/download | sed '/latest stable release/!d' | egrep -o '1\.[5-9]\.[0-100]\.[0-100]')
wget http://www.magentocommerce.com/downloads/assets/$VERSION/magento-$VERSION.tar.gz
tar xzf magento-$VERSION.tar.gz


The regex that I used will only grab four numbers (with dots between), nothing else. The URL to download the latest version is always the same with the exception of the version number, so that shouldn't be an issue. Changing the logic to look for beta, alpha, or release candidates would require an overhaul of the regex that I used, just to be clear.


I can recommend some other changes to increase Magento performance in TKL as well, if anyone is interested. Perhaps an optimization TKLPatch for the Magento TKL is in order. lol.

Guest's picture


I would be really intrested to here your tips pn TKL magento performance incrasing tips please

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)