Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Last active April 2, 2023 09:44
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save stephenharris/90bb468bf80e7f7b02e8b8afe694de4f to your computer and use it in GitHub Desktop.
Save stephenharris/90bb468bf80e7f7b02e8b8afe694de4f to your computer and use it in GitHub Desktop.
Installing a particular version of firefox on Linux.

Installing a particular version of FireFox on Linux

  1. Does an existing version of firefox exist?

    firefox --version
    

    If not, skip to (3).

  2. Install dependency

    sudo apt-get install libgtk2.0-0
    
  3. Download firefox version: FireFox's release archive can be found at https://ftp.mozilla.org/pub/firefox/releases/. You will need to use the appropriate version (typically linux-x86_64, but you can run arch or uname -m to check if your machine is 64 or 32 bit).

    wget https://ftp.mozilla.org/pub/firefox/releases/45.0.2/linux-x86_64/en-GB/firefox-45.0.2.tar.bz2
    # Saving to: ‘firefox-45.0.2.tar.bz2’
    
  4. Extract the binary

    tar xvf firefox-45.0.2.tar.bz2
    
  5. Backup existing firefox directory

    If you have a firefox already installed, back-up the existing version:

    sudo mv /usr/bin/firefox /usr/bin/firefox-backup
    

    and remove the symbolic link

    rm /usr/bin/firefox
    
  6. Move the extracted firefox directory

    sudo mv firefox/ /usr/lib/firefox
    
  7. Create a symbolic link to the firefox binary

    sudo ln -s /usr/lib/firefox /usr/bin/firefox
    
@N1h1l1sT
Copy link

N1h1l1sT commented Sep 9, 2019

On the last step (7. Create a symbolic link to the firefox binary),
I think that the command should be "sudo ln -s /usr/lib/firefox/firefox /usr/bin/firefox".

Also, "rm /usr/bin/firefox" could begin with "sudo" so that copy/pasting it as is always works.

@AlessandroIudicone
Copy link

AlessandroIudicone commented Oct 11, 2021

If someone needs this for a Dockerfile, as October 2021, I did it this way:

ARG FIREFOX_VERSION="XX.YY.ZZ"
RUN apt-get update -qqy \
  && apt-get -qqy --no-install-recommends install firefox \
  && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
  && wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 \
  && apt-get -y purge firefox \
  && rm -rf /opt/firefox \
  && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
  && rm /tmp/firefox.tar.bz2 \
  && mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
  && ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox

...taking inspiration on the Firefox installation part on the selenium/node-firefox Dockerfile.
It works smoothly with Firefox version 93.0 .

@dryu99
Copy link

dryu99 commented Aug 23, 2022

@AlessandroIudicone when I tried running your Dockerfile I got the error: E: Package 'firefox' has no installation candidate. Are you using a specific source for this firefox package?

@AlessandroIudicone
Copy link

Hello @dryu99
I actually don't incur in this error neither using a specific package source.
Trying with an Ubuntu base image, the package is successfully found and installed (although I incur in other errors later through the execution of the Dockerfile script, like "wget not installed" or "bzip2: Cannot exec: No such file or directory").
I tried with an Ubuntu base image using Firefox versions 55.0.3, 93.0 and the latest 103.0.2 .
Which base image are you using ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment