How to install Firefox on a VPS through command line?

2.3k Views Asked by At

I need to make use of Firefox for web scraping. I am using WWW::Mechanize::Firefox. So I will need to install Firefox and Mozrepl however I am installing on a vps that does not have a GUI desktop environment and I am running into problems that Firefox requires a GUI/graphics driver.

The perl script will be run with a cronjob.

How can I do this?

1

There are 1 best solutions below

2
On

From the documentation (WWW::Mechanize::Firefox::FAQ):

Do I Need An X Session To Run Firefox?

Yes.

If you run a unixish operating system, like OSX or Ubuntu or some other Linux distribution, then Firefox will connect to your X server and display a window there. If you do not want Firefox to actually display on your monitor, many people have had success by running Firefox on another X server separate from the main X server, like Xvfb.

Personally, I would prefer to have a "headless Firefox" that does not need a windowing environment. So far, I am unaware of this actually existing.

So yes, you need to have an X session available. Enable XForwarding, with ssh, so you can view the remote GUI desktop on your local machine. Then install Firefox via package management, then install MozRepel within Firefox. Once this is done ensure the MozRepel plugin is enabeled. Then use cpan to install the rest:

cpan WWW::Mechanize::Firefox