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
export PATH

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

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

      1. Thanks for the comment. I wanted to include the 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
      [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 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:

  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/ 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/ 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

    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 🙂

  10. Still compiling on a micro instance from AWS after 1 hour?!
    If it does work I’ll have to save it as an image…

  11. This method worked perfectly up until today, thank you very much for it! Now for some reason I’m getting following error: “Xvfb: symbol lookup error: Xvfb: undefined symbol: pixman_glyph_cache_create” no matter what I do. Just recreated instance from scratch following these instructions (had to change URL for Firefox) and still getting this error. Any advice?

    1. I’m not sure but I did just update the script for some missing dependencies (AWS is always making their distro lighter) and was able to get everything going using amzn-ami-hvm-2014.09.1.x86_64-ebs (ami-b66ed3de)

      1. Hello Joe, thank you very much for the reply! I just did everything from scratch again (I was on a different zone, so I switched to East to get exactly ami-b66ed3de), and get the same error. Here are the commands I input:
        chmod 777
        sudo sh
        sudo yum install Xvfb
        export DISPLAY=:1
        Xvfb :1 -screen 0 1280x768x24 &

        And the result is:
        Xlib: extension “RANDR” missing on display “:1”.
        Xvfb: symbol lookup error: Xvfb: undefined symbol: pixman_glyph_cache_create
        firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :1.
        [1]+ Exit 127 Xvfb :1 -screen 0 1280x768x24

        I am stuck.

  12. The Screen stucks after many initialization lines.
    Here is the log
    Initializing built-in extension Generic Event Extension
    Initializing built-in extension SHAPE
    Initializing built-in extension MIT-SHM
    Initializing built-in extension XInputExtension
    Initializing built-in extension XTEST
    Initializing built-in extension BIG-REQUESTS
    Initializing built-in extension SYNC
    Initializing built-in extension XKEYBOARD
    Initializing built-in extension XC-MISC
    Initializing built-in extension SECURITY
    Initializing built-in extension XINERAMA
    Initializing built-in extension XFIXES
    Initializing built-in extension RENDER
    Initializing built-in extension RANDR
    Initializing built-in extension COMPOSITE
    Initializing built-in extension DAMAGE
    Initializing built-in extension MIT-SCREEN-SAVER
    Initializing built-in extension DOUBLE-BUFFER
    Initializing built-in extension RECORD
    Initializing built-in extension DPMS
    Initializing built-in extension Present
    Initializing built-in extension X-Resource
    Initializing built-in extension XVideo
    Initializing built-in extension XVideo-MotionCompensation
    Initializing built-in extension SELinux
    Initializing built-in extension GLX
    Xlib: extension “RANDR” missing on display “:1”.

    Please help me

  13. Hi,
    Thanks for GTK 2 as we used your gtk to install firefox 45 but our seleinum driver 2.52.0 is not comatabile with firefox 45 we need to install firefox 47 but as this require GTK 3+ library.

    We are using LInux AMI and cant move to ubuntu due to organisation standards only option left is compile GTK 3 our self at below link

    But we are not able to do that due to some expertise lack in linux

    So can you suggest any script for that that install and compile GTK3 in Amazone AMI to run the firefox 47 version.
    Please respond its urgent

  14. HI Joe,

    Thanks a lot for this script. I have run the script in EC2 and it ran for some time but exited with below error—2018-05-15 11:34:22–
    Resolving (…, 2600:1409:a:595::201c, 2600:1409:a:586::201c
    Connecting to (||:80… connected.
    HTTP request sent, awaiting response… 302 Moved Temporarily
    Location: [following]
    –2018-05-15 11:34:23–
    Resolving (…, 2600:9000:20d3:3200:e:8dab:f807:c041, 2600:9000:20d3:5800:e:8dab:f807:c041, …
    Connecting to (||:80… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2018-05-15 11:34:23 ERROR 404: Not Found.

    tar: firefox*: Cannot open: No such file or directory
    tar: Error is not recoverable: exiting now

    Any help is appreiciated

Leave a Reply to Jorge Cancel reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s