Magento: Installing on a debian server

To install magento on a fresh server use the following.

  • Install apache, mysql and PHP5 “$ apt-get install apache2 mysql-server php5 php5-mysql php-soap php5-mcrypt php5-curl php5-gd”
  • Edit the vhost config for the apache site [/etc/apache2/sites-enabled/000-default]
    • Verify that “AllowOverride” is set to All for the magento directory
  • Make sure that mof_rewrite is loaded; use “$ a2enmod rewrite” and then reload apache2
  • Edit /etc/php5/apache2/php.ini
    • “memory_limit” [the manual says] no less than 256Mb (preferably 512)
    • “max_execution_time” [this is the max time that a script may be left running] SOAP requests take time, so make suer it is at a reasonable time
    • “upload_max_filesize” Set this to a size that is reasonable depending on what you plan to upload (manuals might be large)
    • “post_max_size” Set this to a size that is reasonable depending on what you plan to post (manuals might be large); also make sure that the value and the modifier is correct (so that it says 8M and not just 8 for instance)
    • “display_errors” Set to Off
    • “log_errors” Set to On
    • “error_log” Set to a file that you will be able to find [if you wish to have it in a subdir; create that as root and give it permissions as apache log dir]
  • download magento (lastest version from magento
  • Upack it (I choose bzip2 format) “$ tar -jxvvf magento-downloader-1.3.2.1.tar.bz2” and make sure the files gets put in the directory you wish
  • Some directories have to be writable to the webserver (and all subdirectories, where there are)
    • var
    • var/.htaccess
    • app/etc
    • media
  • If you are using the downloader installation
    • “$./pear mage-setup .”
    • “$./pear install magento-core/Mage_All_Latest”
    • “$rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*”
  • Create database and database user [this is to do it manually via mysql console]
    • “$mysql -uroot -p”
    • “mysql> create database magento;”
    • “mysql> use mysql;”
    • “mysql> INSERT INTO user (Host,User,Password) VALUES (‘localhost’, ‘magento’, PASSWORD(‘password’));”
    • “mysql> GRANT ALL ON magento.* TO ‘magento’;”
    • “mysql> FLUSH PRIVILEGES;”
    • “mysql> exit”
  • Go to the webserver and complete the installation
  • If you get stuck on the configuration page [that you get back to it even after adding correct information]:
    • Check “AllowOverride” in the apache config.
    • Check “post_max_size2 in the php.ini [also check so that the value is either absolute or has a modifier; 8 means 8 bytes while 8M means 8Mb]

ubuntu: what version is installed?

The quick way is to run “lsb_release -a”

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 9.10
Release:        9.10
Codename:       karmic

Or just read the info from /etc/lsb-release

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"

It is also possible to check the file “/etc/issue”

$ cat /etc/issue
Ubuntu 9.10 \n \l

From X check out System->about.

Forcing a fsck at next reboot

Sometimes you wish to make fsck run at the next time (after the computer is powered up/rebooted).
This can be achieved by

Passing F to shutdown

By passing the option “F” to shutdown it will force a file system check at the next boot up.

shutdown -rF now

By creating a /forcefsck file

If the file “/forcefsck” exists then a fsck is forced at boot up.

touch /forcefsck

Turning off auto fsck at boot time

A Linux machine will auto check the file system if the last shutdown was unclean (the system was powered off before the file system was unmounted) or if it has passed to much time since the last check.

This can be turned off in a few ways, here are some.

[never check] From /etc/fstab

If the sixth option is not 0 (or missing) then fsck will do automatic checking, so change the sixth option to a 0.
As root edit the /etc/fstab (use your favorite text editor or vi).

/dev/sda1		/home/files			ext3	defaults	0 0

[never check] By passing arguments via GRUB

It is possible to pass the option fastboot to the kernel at boot time, this will also prevent fsck from running at boot time.
Edit /boot/grub/menu.lst (use your favorite text editor or vi) [might also be called /etc/grub.conf]
So an example of this would look like

title           Debian GNU/Linux, kernel 2.6.26-1-686
root            (hd0,0)
kernel          /vmlinuz-2.6.26-1-686 root=/dev/mapper/root-root--volume ro fastboot
initrd          /initrd.img-2.6.26-1-686

[only skip once] By passing options to shutdown

If you only wish to bypass the automatic testing of the file system once, but keep the automatic settings saved you can use the shutdown command with the option “f”.
For instance to reboot without checking

shutdown -rf now

unqualified host name ([something]) unknow; sleeping for retry

sendmail expects to the machine to have a FQDN (fully qualified domain name).

If it does not have that (type “hostname” to check what name the machine has) sendmail will complain about this and take a loot of extra time trying to find it.

To use a FQDN edit “/etc/hosts” and change [something] to [something.yourdomain.com] and this will go away. Updating “/etc/hostname” at the same time might be a good idea; don’t forget to run “/bin/hostname -F /etc/hostname” after updating /etc/hostname.

sudo: no tty present and no askpass program specified

This error message will occur if sudo is not able to ask for the password (no tty is present) (like for instance when trying to sudo rsync).

One solution to this is to add the line “Defaults visiblepw” to the /etc/sudoers file.

[Todd C. Miller Todd.Miller at courtesan.com said on sudo-users: Recent versions of sudo will refuse to prompt for a password if no tty is present, since it is not possible to turn off echo in this case. You can restore the old behavior with a line like above]

How to search recursively the files of a given directory [Grepdir]

A guy called Chris Karakas has made a very nice script to search through all files in a directory (and all subdirectories).

The original can be downloaded from http://www.karakas-online.de/downloads/grepdir and saved as /usr/local/bin/grepdir. If chmoded a+x then it can be used by all.

A note on ubuntu: I had to change the “/bin/sh” to “/bin/bash” in order to get it working (it was complaining about “/usr/local/bin/grepdir: 16: Syntax error: “(” unexpected”).

Update: A updated version that should read the shell automatically from the export list can be downloaded from http://www.f15ijp.com/wp-content/uploads/2010/08/grepdir

Synergy – Problem with international chars (keys)

When using synergy and a non us keyboard layout there is sometimes problems with the chars not being sent correctly (chars that are not on the us layout or in a different location).

I know that others have this problem as well, but the solution that I have found to work for me – so far – is very simple.

Just using force reconnect from the server makes this problem go away 😉