Поиск по блогу

суббота, 30 мая 2015 г.

Устанавливаем Phantomjs на Debian (Kali) так, чтобы потом установить Casperjs

На моент написания поста последняя версия Casperjs соответствовала предыдущему релизу Phantomjs. Так что мне пришлось искать в репозитории версию phantomjs-1.9.8-linux-i686 и устанавливать ее. Здесь подробный лог установки. Надо запомнить прием создания символической ссылки ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

How to install PhantomJS on Ubuntu
Downloads
PhantomJS 1.9 Release Notes
New to PhantomJS? Install it and read the quick start guide.
Install and configure PhantomJS
CasperJS can be installed PhantomJS 1.8.2 or greater, but less than 2.0. Installation instructions can be found here

Плохая новость 1 - для установки под Linux требуется большое количество dev пакетов

Среди большого количества мануалов по установке я выбра How to install PhantomJS on Ubuntu. Но просмотреть пришлось несколько. Во всех иодин и тот же перечень необходимых библиотек. Процесс проверки и доустановки из моей консоли я скопировал в приложение "Предварительная установка пакетов для стэка Phantomjs" в конце этого поста. Начинать надо с него.

Плохая новость 2 - ставить надо не последнюю версию

Все вот из-за этой строчки в инструкции на сайте Casperjs CasperJS can be installed
PhantomJS 1.8.2 or greater, but less than 2.0. Installation instructions can be found here

Поэтому не ставим последню (сегодня) вторую версию, а ищем репозиторий Downloads. Находим в репозитории версию 1.9.8

In [ ]:
root@kali:/home/kiss/Downloads# cd ~

Далее отвлечемся от процесса установки и обратим внимание на изящный прием работы в консоли. Вот адрес ссылки, которую надо использовать для скачивания на 32-разрядный Linux

In [ ]:
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2

Просто скачать пакет - это скучно, мы повторим понт автора How to install PhantomJS on Ubuntu

In [ ]:
root@kali:~# export PHANTOM_JS="phantomjs-1.9.8-linux-i686"

Отметим прием $PHANTOM_JS.tar.bz2 - мы задали переменную, в которой соержится имя без расширения, а расширение можно дописать вот таким простым способом:

In [ ]:
root@kali:~# wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
--2015-05-30 11:15:17--  https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2
Resolving bitbucket.org (bitbucket.org)... 131.103.20.168, 131.103.20.167
Connecting to bitbucket.org (bitbucket.org)|131.103.20.168|:443... connected.
HTTP request sent, awaiting response... 302 FOUND
Location: https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2?Signature=XlukguRKcWLedEwN%2F5025QoPCYI%3D&Expires=1432974737&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-1.9.8-linux-i686.tar.bz2%22 [following]
--2015-05-30 11:15:19--  https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2?Signature=XlukguRKcWLedEwN%2F5025QoPCYI%3D&Expires=1432974737&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-1.9.8-linux-i686.tar.bz2%22
Resolving bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)... 54.231.18.201
Connecting to bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)|54.231.18.201|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13517724 (13M) [application/x-tar]
Saving to: `phantomjs-1.9.8-linux-i686.tar.bz2'

100%[====================================================================================================>] 13,517,724  1.36M/s   in 9.8s    

2015-05-30 11:15:30 (1.31 MB/s) - `phantomjs-1.9.8-linux-i686.tar.bz2' saved [13517724/13517724]

root@kali:~# 

Распакуем тут же

In [ ]:
root@kali:~# tar xvjf $PHANTOM_JS.tar.bz2
phantomjs-1.9.8-linux-i686/
phantomjs-1.9.8-linux-i686/bin/
phantomjs-1.9.8-linux-i686/bin/phantomjs
phantomjs-1.9.8-linux-i686/third-party.txt
phantomjs-1.9.8-linux-i686/ChangeLog
phantomjs-1.9.8-linux-i686/LICENSE.BSD
phantomjs-1.9.8-linux-i686/README.md
phantomjs-1.9.8-linux-i686/examples/
phantomjs-1.9.8-linux-i686/examples/loadurlwithoutcss.coffee
phantomjs-1.9.8-linux-i686/examples/ipgeocode.coffee
phantomjs-1.9.8-linux-i686/examples/imagebin.coffee
phantomjs-1.9.8-linux-i686/examples/weather.coffee
phantomjs-1.9.8-linux-i686/examples/echoToFile.coffee
phantomjs-1.9.8-linux-i686/examples/rasterize.coffee
phantomjs-1.9.8-linux-i686/examples/netsniff.coffee
phantomjs-1.9.8-linux-i686/examples/useragent.js
phantomjs-1.9.8-linux-i686/examples/fibo.js
phantomjs-1.9.8-linux-i686/examples/printenv.coffee
phantomjs-1.9.8-linux-i686/examples/arguments.coffee
phantomjs-1.9.8-linux-i686/examples/countdown.js
phantomjs-1.9.8-linux-i686/examples/colorwheel.js
phantomjs-1.9.8-linux-i686/examples/netlog.coffee
phantomjs-1.9.8-linux-i686/examples/tweets.coffee
phantomjs-1.9.8-linux-i686/examples/netsniff.js
phantomjs-1.9.8-linux-i686/examples/seasonfood.js
phantomjs-1.9.8-linux-i686/examples/walk_through_frames.js
phantomjs-1.9.8-linux-i686/examples/run-qunit.js
phantomjs-1.9.8-linux-i686/examples/hello.js
phantomjs-1.9.8-linux-i686/examples/pagecallback.js
phantomjs-1.9.8-linux-i686/examples/sleepsort.js
phantomjs-1.9.8-linux-i686/examples/pagecallback.coffee
phantomjs-1.9.8-linux-i686/examples/rasterize.js
phantomjs-1.9.8-linux-i686/examples/serverkeepalive.js
phantomjs-1.9.8-linux-i686/examples/technews.js
phantomjs-1.9.8-linux-i686/examples/printheaderfooter.coffee
phantomjs-1.9.8-linux-i686/examples/pizza.coffee
phantomjs-1.9.8-linux-i686/examples/render_multi_url.coffee
phantomjs-1.9.8-linux-i686/examples/imagebin.js
phantomjs-1.9.8-linux-i686/examples/direction.coffee
phantomjs-1.9.8-linux-i686/examples/sleepsort.coffee
phantomjs-1.9.8-linux-i686/examples/countdown.coffee
phantomjs-1.9.8-linux-i686/examples/unrandomize.coffee
phantomjs-1.9.8-linux-i686/examples/detectsniff.js
phantomjs-1.9.8-linux-i686/examples/simpleserver.js
phantomjs-1.9.8-linux-i686/examples/run-jasmine.coffee
phantomjs-1.9.8-linux-i686/examples/stdin-stdout-stderr.coffee
phantomjs-1.9.8-linux-i686/examples/arguments.js
phantomjs-1.9.8-linux-i686/examples/version.coffee
phantomjs-1.9.8-linux-i686/examples/module.coffee
phantomjs-1.9.8-linux-i686/examples/printheaderfooter.js
phantomjs-1.9.8-linux-i686/examples/postserver.coffee
phantomjs-1.9.8-linux-i686/examples/follow.js
phantomjs-1.9.8-linux-i686/examples/server.js
phantomjs-1.9.8-linux-i686/examples/phantomwebintro.js
phantomjs-1.9.8-linux-i686/examples/netlog.js
phantomjs-1.9.8-linux-i686/examples/stdin-stdout-stderr.js
phantomjs-1.9.8-linux-i686/examples/module.js
phantomjs-1.9.8-linux-i686/examples/ipgeocode.js
phantomjs-1.9.8-linux-i686/examples/render_multi_url.js
phantomjs-1.9.8-linux-i686/examples/run-jasmine.js
phantomjs-1.9.8-linux-i686/examples/post.coffee
phantomjs-1.9.8-linux-i686/examples/walk_through_frames.coffee
phantomjs-1.9.8-linux-i686/examples/page_events.js
phantomjs-1.9.8-linux-i686/examples/post.js
phantomjs-1.9.8-linux-i686/examples/outputEncoding.js
phantomjs-1.9.8-linux-i686/examples/direction.js
phantomjs-1.9.8-linux-i686/examples/features.coffee
phantomjs-1.9.8-linux-i686/examples/weather.js
phantomjs-1.9.8-linux-i686/examples/seasonfood.coffee
phantomjs-1.9.8-linux-i686/examples/pizza.js
phantomjs-1.9.8-linux-i686/examples/universe.js
phantomjs-1.9.8-linux-i686/examples/tweets.js
phantomjs-1.9.8-linux-i686/examples/serverkeepalive.coffee
phantomjs-1.9.8-linux-i686/examples/phantomwebintro.coffee
phantomjs-1.9.8-linux-i686/examples/detectsniff.coffee
phantomjs-1.9.8-linux-i686/examples/version.js
phantomjs-1.9.8-linux-i686/examples/waitfor.js
phantomjs-1.9.8-linux-i686/examples/features.js
phantomjs-1.9.8-linux-i686/examples/child_process-examples.coffee
phantomjs-1.9.8-linux-i686/examples/child_process-examples.js
phantomjs-1.9.8-linux-i686/examples/printmargins.coffee
phantomjs-1.9.8-linux-i686/examples/unrandomize.js
phantomjs-1.9.8-linux-i686/examples/page_events.coffee
phantomjs-1.9.8-linux-i686/examples/server.coffee
phantomjs-1.9.8-linux-i686/examples/useragent.coffee
phantomjs-1.9.8-linux-i686/examples/loadspeed.js
phantomjs-1.9.8-linux-i686/examples/simpleserver.coffee
phantomjs-1.9.8-linux-i686/examples/colorwheel.coffee
phantomjs-1.9.8-linux-i686/examples/postserver.js
phantomjs-1.9.8-linux-i686/examples/technews.coffee
phantomjs-1.9.8-linux-i686/examples/fibo.coffee
phantomjs-1.9.8-linux-i686/examples/printenv.js
phantomjs-1.9.8-linux-i686/examples/injectme.js
phantomjs-1.9.8-linux-i686/examples/follow.coffee
phantomjs-1.9.8-linux-i686/examples/printmargins.js
phantomjs-1.9.8-linux-i686/examples/modernizr.js
phantomjs-1.9.8-linux-i686/examples/loadurlwithoutcss.js
phantomjs-1.9.8-linux-i686/examples/waitfor.coffee
phantomjs-1.9.8-linux-i686/examples/movies.coffee
phantomjs-1.9.8-linux-i686/examples/echoToFile.js
phantomjs-1.9.8-linux-i686/examples/injectme.coffee
phantomjs-1.9.8-linux-i686/examples/hello.coffee
phantomjs-1.9.8-linux-i686/examples/scandir.coffee
phantomjs-1.9.8-linux-i686/examples/run-qunit.coffee
phantomjs-1.9.8-linux-i686/examples/movies.js
phantomjs-1.9.8-linux-i686/examples/outputEncoding.coffee
phantomjs-1.9.8-linux-i686/examples/scandir.js
phantomjs-1.9.8-linux-i686/examples/loadspeed.coffee
root@kali:~# 

Теперь всю папку переместим в /usr/local/share

In [ ]:
root@kali:~# mv $PHANTOM_JS /usr/local/share

root@kali:~# ls
Desktop  phantomjs-1.9.8-linux-i686.tar.bz2

И создадим символьную ссылку (symlink) на исполняемый файл в директории /usr/local/bin

In [ ]:
root@kali:~# ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Напрашивается сравнение с переменной PATH в Windows, ... теперь Фантом дожен запустится даже из пространста имен этой notebook

In [1]:
!phantomjs --version
1.9.8
In [2]:
!ln --help
Usage: ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
  or:  ln [OPTION]... TARGET                  (2nd form)
  or:  ln [OPTION]... TARGET... DIRECTORY     (3rd form)
  or:  ln [OPTION]... -t DIRECTORY TARGET...  (4th form)
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
When creating hard links, each TARGET must exist.  Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent directory.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]      make a backup of each existing destination file
  -b                          like --backup but does not accept an argument
  -d, -F, --directory         allow the superuser to attempt to hard link
                                directories (note: will probably fail due to
                                system restrictions, even for the superuser)
  -f, --force                 remove existing destination files
  -i, --interactive           prompt whether to remove destinations
  -L, --logical               make hard links to symbolic link references
  -n, --no-dereference        treat destination that is a symlink to a
                                directory as if it were a normal file
  -P, --physical              make hard links directly to symbolic links
  -s, --symbolic              make symbolic links instead of hard links
  -S, --suffix=SUFFIX         override the usual backup suffix
  -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create
                                the links
  -T, --no-target-directory   treat LINK_NAME as a normal file
  -v, --verbose               print name of each linked file
      --help     display this help and exit
      --version  output version information and exit

The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

Using -s ignores -L and -P.  Otherwise, the last option specified controls
behavior when the source is a symbolic link, defaulting to -P.

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

Report ln bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'ln invocation'

Приложение. Предварительная установка пакетов для стэка Phantomjs

In [ ]:
root@kali:/home/kiss/Downloads# apt-get update
Hit http://dl.google.com stable Release.gpg
Hit http://dl.google.com stable Release                            
Hit http://dl.google.com stable/main i386 Packages                                                                        
Ign http://dl.google.com stable/main Translation-en_US                                                                                      
Hit http://http.kali.org kali Release.gpg                 
Ign http://dl.google.com stable/main Translation-en
Ign http://dl.google.com stable/main Translation-en_GB                
Hit http://security.kali.org kali/updates Release.gpg                 
Hit http://http.kali.org kali Release           
Hit http://security.kali.org kali/updates Release
Hit http://http.kali.org kali/main Sources       
Hit http://security.kali.org kali/updates/main i386 Packages     
Hit http://http.kali.org kali/non-free Sources                                         
Hit http://security.kali.org kali/updates/contrib i386 Packages                        
Hit http://http.kali.org kali/contrib Sources                                          
Hit http://security.kali.org kali/updates/non-free i386 Packages                       
Hit http://http.kali.org kali/main i386 Packages                 
Hit http://http.kali.org kali/non-free i386 Packages             
Hit http://http.kali.org kali/contrib i386 Packages              
Ign http://security.kali.org kali/updates/contrib Translation-en_US                                                                          
Ign http://security.kali.org kali/updates/contrib Translation-en                                                                             
Ign http://security.kali.org kali/updates/contrib Translation-en_GB                                                                          
Ign http://security.kali.org kali/updates/main Translation-en_US                                                                             
Ign http://security.kali.org kali/updates/main Translation-en                                                                                
Ign http://http.kali.org kali/contrib Translation-en_US                                                                                      
Ign http://security.kali.org kali/updates/main Translation-en_GB                                                                             
Ign http://http.kali.org kali/contrib Translation-en                                                                                         
Ign http://security.kali.org kali/updates/non-free Translation-en_US                                                                         
Ign http://http.kali.org kali/contrib Translation-en_GB                                                                                      
Ign http://security.kali.org kali/updates/non-free Translation-en                                                                            
Ign http://http.kali.org kali/main Translation-en_US                                                                                         
Ign http://security.kali.org kali/updates/non-free Translation-en_GB                                                                         
Ign http://http.kali.org kali/main Translation-en                                                                                            
Ign http://http.kali.org kali/main Translation-en_GB                                                                                         
Ign http://http.kali.org kali/non-free Translation-en_US                                                                                     
Ign http://http.kali.org kali/non-free Translation-en                                                                                        
Ign http://http.kali.org kali/non-free Translation-en_GB                                                                                     
Reading package lists... Done                                                                                                                
root@kali:/home/kiss/Downloads# apt-get install build-essential chrpath libssl-dev libxft-devapt-get install build-essential chrpath libssl-dev libxft-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libxft-devapt-get
E: Unable to locate package install
root@kali:/home/kiss/Downloads# apt-get install build-essential 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
build-essential set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@kali:/home/kiss/Downloads# apt-get install chrpath libssl-dev libxft-devapt-get install build-essential chrpath libssl-dev libxft-devReading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libxft-devapt-get
E: Unable to locate package install
root@kali:/home/kiss/Downloads# apt-get install chrpath libssl-dev build-essential chrpath libssl-dev libxft-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
libxft-dev is already the newest version.
libxft-dev set to manually installed.
libssl-dev is already the newest version.
libssl-dev set to manually installed.
The following NEW packages will be installed:
  chrpath
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.6 kB of archives.
After this operation, 86.0 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.kali.org/kali/ kali/main chrpath i386 0.13-2 [13.6 kB]
Fetched 13.6 kB in 5s (2,378 B/s)  
Selecting previously unselected package chrpath.
(Reading database ... 431624 files and directories currently installed.)
Unpacking chrpath (from .../chrpath_0.13-2_i386.deb) ...
Processing triggers for man-db ...
Setting up chrpath (0.13-2) ...
root@kali:/home/kiss/Downloads# install build-essential chrpath libssl-dev libxft-dev
install: target `libxft-dev' is not a directory
root@kali:/home/kiss/Downloads# install build-essential chrpath libssl-dev 
install: target `libssl-dev' is not a directory
root@kali:/home/kiss/Downloads# apt-get install build-essential chrpath libssl-dev libxft-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
chrpath is already the newest version.
libxft-dev is already the newest version.
libssl-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@kali:/home/kiss/Downloads# apt-get install libfreetype6 libfreetype6-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libfreetype6 is already the newest version.
libfreetype6 set to manually installed.
libfreetype6-dev is already the newest version.
libfreetype6-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@kali:/home/kiss/Downloads# apt-get install libfontconfig1 libfontconfig1-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libfontconfig1 is already the newest version.
libfontconfig1 set to manually installed.
libfontconfig1-dev is already the newest version.
libfontconfig1-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@kali:/home/kiss/Downloads# ^C


Посты чуть ниже также могут вас заинтересовать

Комментариев нет:

Отправить комментарий