Install Firefox on Amazon Linux x86_64 Compiling GTK+

Amazon Linux doesn’t offer the Gimp Tool Kit (GTK+) so if you want to run Firefox on an Amazon Linux system, say for Selenium testing, you are left having to compile the system yourself.  Luckily you have found this post.  Create the script below, run it as root and it will build all the components needed for GTK+ and its dependencies for Firefox to run just fine on the system.

vi ./gtk-firefox
chmod 755 ./gtk-firefox
sudo ./gtk-firefox

After you have built the packages, add the /usr/local/bin to your path by updating your .bashrc file.

cat << EOF >> ~/.bashrc
PATH=/usr/local/bin:\$PATH
export PATH
EOF

Here is the gtk-firefox file for your pleasure.

If you are running OSX Mountain Lion or above and cannot get Firefox to run via the SSH -X command, make sure you have XQuartz installed as Apple removed X11 by default.

Edited to make Firefox latest release more reliable. Updated with Gist.

Edit 11/21/2012: Added dbus-glib dependency to gist. Added notes about running on OSX

34 thoughts on “Install Firefox on Amazon Linux x86_64 Compiling GTK+”

      1. Thanks for the comment. I wanted to include the download.mozilla.org link but as you found it isn’t very reliable. Further, for me at least, it always downloaded a Windows client even though I specified Linux. I changed the wget command to be a little more reliable and current. It now points to the latest and recursively gets anything in there ignoring indexes and parent links.

        Note that on the wget command the trailing slash is important otherwise you start getting stuff in the parent directory and end up with whatever language is last that it downloads.

    1. Because as the first sentence in the article states, “Amazon Linux doesn’t offer the Gimp Tool Kit (GTK+) so if you want to run Firefox on an Amazon Linux system, say for Selenium testing, you are left having to compile the system yourself.”

      Have you tried yum install firefox on Amazon linux? It doesn’t work.

      [ec2-user@ip-10-4-178-74 ~]$ uname -r
      3.2.30-49.59.amzn1.x86_64
      [ec2-user@ip-10-4-178-74 ~]$ sudo yum install firefox
      Loaded plugins: priorities, security, update-motd, upgrade-helper
      amzn-main | 2.1 kB 00:00
      amzn-updates | 2.3 kB 00:00
      Setting up Install Process
      No package firefox available.
      Error: Nothing to do

    1. Thanks Pablo. I had the same idea but never posted it. I got lost while considering how to implement a version that would at at least pull the “LATEST” links from the gnome.org sources. Another idea was to just make a continuous build of the packages for everyone so no more compilation. I’ll use your gist but here was mine: https://gist.github.com/3991486

  1. Can you tell me after this set up, where is the .mozilla folder located? I want to use the default file… thanks for your effort to write this up!

    1. Bin,

      By default the .mozilla folder should end up in the user’s home directory that is running firefox. Try looking at your home directory with the command “ls -alt ~”.

      You can also specify a profile location by running “firefox -profile ” where profile path is a directory that you want the profile to be stored in such as ~/mozilla-profile.

      Finally you can also run the profile manager with “firefox -p”. If that doesn’t work or it crashes, try “firefox -p -safe-mode”.

  2. Hi joekiller,

    Thank you for your post. I have followed step to install firefox on AWS EC2 Linux AMI. The installation is success. But, I get this error when I want to run

    XPCOMGlueLoad error for file /usr/local/firefox/libxpcom.so:
    libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
    Couldn’t load XPCOM.

    What should I do?

    Thank you

      1. Hi joe,

        Thanks for reply. You are correct. I need to install dbus-glib. But, after that it shows another “lib” error. I tried to install pango-devel to solve libpangoft. It shows libgtk error then. Anyway, I use Amazon Linux AMI which means I use Redhat 4.4.

      2. First of all, make sure you are on a 64-bit machine. These instructions are for 64-bit only. That aside if you are 64-bit, try rerunning the script and looking for compilation errors.

  3. Got linux firefox window to show up on Mountain Lion (XQuartz) Display. Everything looks great, but it does not take mouse or key board inputs, any ideas what are missing? Thanks.

  4. Hi Joe, thanks for the tutorial. I’ve follow your instruction and after I typed “firefox” in the terminal and got this message below:

    ====================================================================
    (firefox:19443): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback ‘C’ locale.
    Error: cannot open display: localhost:10.0
    ====================================================================

    I’m new to linux, please help me.

    1. I think you are seeing two errors here. The first warning is just a warning so you can ignore it.

      The second indicates that you are doing X forwarding properly. Do a search for xforwarding on your OS.

  5. Joe,
    Very weird question. How long the script would take to execute and finish with average speed internet connection?. I am executed the script some 5 hours back but still it is running. Is something going wrong?

    1. I’m not sure why the internet connection would matter if you are running this on Amazon Linux. If you are running a local OS installing firefox via the package manager might be the easiest.

  6. This script is great, the best solution on the whole world-wide web for sure. I have used it 4 times so far.

    1 little correction I had to make:
    -tar xvf firefox*
    +tar xvf firefox*tar*
    because there is also a firefox-22.0.json file in the download

    Thanks for making my life easier – Maia

  7. Joe,

    Many thanks for your tips. Unfortunately I’m on 32-bit. Could you shed some light on this very briefly?

  8. Using the latest version of the Amazon Linux AMI (2013.09) I was getting this error after running this script:

    XPCOMGlueLoad error for file /usr/local/firefox/libxul.so:
    libasound.so.2: cannot open shared object file: No such file or directory
    Couldn’t load XPCOM.

    Running “yum install alsa-lib-devel -y” fixed it

  9. It looks like Firefox is changing to host on a CDN. The finish() part will give a 404 and fail (even though this was the more reliable and current way to download). Unfortunately, this is no longer true “It now points to the latest and recursively gets anything in there ignoring indexes and parent links.”

    I tried to find the exact equivalent on the CDN. However, “latest” is a directory that still includes the version “firefox-26.0.tar.bz2.” So, the version is still necessary.

    Still, replacing line 42 with the following will put things back on track (at least for version 26.0):

    wget -r –no-parent –reject “index.html*” -nH –cut-dirs=7 http://download-installer.cdn.mozilla.net/pub/firefox/releases/26.0/linux-x86_64/en-US/firefox-26.0.tar.bz2

    I will see if I can make a pull request against the gist.

    1. Thank you! Check other forks of the script as well. Some people have improved it in a number of ways. I’ll update the script with everyone’s improvements sometime in the future… I hope :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s