1 (07.05.2014 14:17:17 отредактировано Drugpunker)

Всем здравствуйте.

Создал тему, надеясь хотя бы здесь найти ответ на вопрос:
"Как заставить работать функции типа pcntl_fork"  (на php и Apache, соответственно)

ОС у меня Linux Mint 16 Petra


Установка PHP выполнялась методом

 Консоль:
$ apt-get install php5-dev

Далее делал следующее:

Установил библиотеку CLI

 Консоль:
$ apt-get install php5-cli

Скачал архив с http://www.php.net/releases/, соответствующий моей версии php
Разархивировал в папку /php
 Консоль:
$ cd php/ext/pcntl
$ phpize
$ ./configure
$ make
$ echo "extension=pcntl.so" > /etc/php5/mods-available/pcntl.ini

Во всех php.ini закомментировал ;disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited..."

Но ничего не выходит:

Fatal error: Call to undefined function pcntl_fork() in...

На Linux пришлось перейти именно из-за отсутствия этой функции для Windows.
Делал как описано в мануале.

Прошу расскажите, как собрать PHP с pcntl или ссылку дайте?
На форумах и вообще в webe всё одно и тоже и не работает.

И как вообще правильно LAMP собирать? Может есть секреты какие, мануалы (развёрнутые)?
Linux под разработку хочу оставить.
Задавал подобный вопрос на тематических форумах по PHP - толка ноль...

2 (07.05.2014 14:41:13 отредактировано -=Serj=-)

Drugpunker,

# make install

видимо забыли.

Drugpunker пишет:

И как вообще правильно LAMP собирать?

А зачем его собирать?

Да, у меня Ubuntu.
Нет, не глючит.

3

Делал по многочисленным инструкциям.
Везде было [*]make[/*]
.....?

4

Покажите вывод

php -m | grep pcntl

Если выведет pcntl, значит оно у вас уже есть.

Drugpunker пишет:

Fatal error: Call to undefined function pcntl_fork() in...

apache перезагружали после исправления конфигов?
И какой из php.ini исправляли? Они разные для apache и cli

5

$ php -m | grep pcntl
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/pcntl.so' - /usr/lib/php5/20121212/pcntl.so: cannot open shared object file: No such file or directory in Unknown on line 0
pcntl

Все php.ini уже исправил

6

phpinfo()

Additional .ini files parsed
    /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-gd.ini, /etc/php5/apache2/conf.d/20-json.ini,          /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/pcntl.ini

7

Таки не хватает make install
Это не совсем правильное решение, как и использование pcntl_* в рамках apache в принципе. Я бы подумал, точно ли оно вам надо именно в таком виде.

Цитата из http://www.php.net/manual/en/intro.pcntl.php

Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.

8

Нужен демон на php.

Других вариантов не вижу.
Или смотрю не туда?

9

А вы саму библиотеку скопировали в директорию разшырений php?

Trouble  in WINDOWS reboot, trouble in UNIX be root.

10

А где она находится?

11

Если в Lib, то нет

12

Drugpunker пишет:

Нужен демон на php.

Других вариантов не вижу.
Или смотрю не туда?

Демон по идее должен запускаться через php-cli (там функции pcntl_* у вас должны работать), а не mod_php, тогда все норм. Если уж нужно запускать именно через web, то как вариант:

exec('php /path/to/daemon.php');

PS Программист из меня так себе, так что стоит погуглить этот вопрос.

13

neol пишет:

Демон по идее должен запускаться через php-cli

Каким образом это происходит?Как запускается?

14

Drugpunker пишет:

cd php/ext/pcntl

ТС покажыте но листинг этой директории

Trouble  in WINDOWS reboot, trouble in UNIX be root.

15

Drugpunker пишет:

Каким образом это происходит?Как запускается?

Введите в консоли
php /path/to/script.php
это будет запуск из cli (command line interface).
Совсем правильно будет сделать запуск через используемую систему инициализации (initd, upstart, systemd, etc)

16 (07.05.2014 15:34:50 отредактировано Drugpunker)

neol пишет:

Таки не хватает make install

+ открыть спойлер

 Консоль:
~/php/ext/pcntl $ make test && make install

Build complete.
Don't forget to run 'make test'.

PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0
PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0

=====================================================================
PHP         : /usr/bin/php
Warning: Module 'pcntl' already loaded in Unknown on line 0

PHP_SAPI    : cli
PHP_VERSION : 5.5.3-1ubuntu2.3
ZEND_VERSION: 2.5.0
PHP_OS      : Linux - Linux Drugpunker-PC 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64
INI actual  : /home/drugpunker/php/ext/pcntl/tmp-php.ini
More .INIs  : 
CWD         : /home/drugpunker/php/ext/pcntl
Extra dirs  :
VALGRIND    : Not used
=====================================================================
TIME START 2014-05-07 11:29:30
=====================================================================
FAIL Test pcntl wait functionality [tests/001.phpt]
FAIL pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
FAIL pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
FAIL Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
FAIL pcntl_alarm() [tests/pcntl_alarm.phpt]
FAIL pcntl_exec() [tests/pcntl_exec.phpt]
FAIL pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
FAIL pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
FAIL Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
FAIL Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
FAIL Test pcntl_get_last_error() [tests/pcntl_get_last_error.phpt]
FAIL pcntl_signal() [tests/pcntl_signal.phpt]
FAIL pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
FAIL pcntl_wait() [tests/pcntl_wait.phpt]
FAIL Closures as a signal handler [tests/signal_closure_handler.phpt]
=====================================================================
TIME END 2014-05-07 11:29:35

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   42
---------------------------------------------------------------------

Number of tests :   15                15
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   15 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    5 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test pcntl wait functionality [tests/001.phpt]
pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
pcntl_alarm() [tests/pcntl_alarm.phpt]
pcntl_exec() [tests/pcntl_exec.phpt]
pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
Test pcntl_get_last_error() [tests/pcntl_get_last_error.phpt]
pcntl_signal() [tests/pcntl_signal.phpt]
pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
pcntl_wait() [tests/pcntl_wait.phpt]
Closures as a signal handler [tests/signal_closure_handler.phpt]
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.    You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: y

Please enter your email address.
(Your address will be mangled so that it will not go out on any
mailinglist in plain text): drugpunker@gmail.com

Posting to http://qa.php.net/buildtest-process.php

Thank you for helping to make PHP better.
Installing shared extensions:     /usr/lib/php5/20121212/
cp: cannot create regular file '/usr/lib/php5/20121212/#INST@12102#': Permission denied
make: *** [install-modules] Ошибка 1

17

И приветиде ещё листинг вот этой директории

 Консоль:
ls -l usr/lib/php5/20121212

Trouble  in WINDOWS reboot, trouble in UNIX be root.

18

make install нужно запускать из под рута. У вас команда копирования готовой библиотеки не отработала

Drugpunker пишет:

cp: cannot create regular file '/usr/lib/php5/20121212/#INST@12102#': Permission denied

Скопируйте ручками из под рута.

Trouble  in WINDOWS reboot, trouble in UNIX be root.

19

kisil пишет:

И приветиде ещё листинг вот этой директории
Консоль
ls -l usr/lib/php5/20121212

Нет такой директории...

20

А такая есть. Ну не всёже копипастите

 Консоль:
ls -l /usr/lib/php5/20121212

Trouble  in WINDOWS reboot, trouble in UNIX be root.

21 (07.05.2014 15:44:38 отредактировано Drugpunker)

kisil пишет:

Скопируйте ручками из под рута.

Под рутом:

+ открыть спойлер

 Консоль:
~/php/ext/pcntl $ sudo make test && make install
/bin/bash /home/drugpunker/php/ext/pcntl/libtool --mode=install cp ./pcntl.la /home/drugpunker/php/ext/pcntl/modules
libtool: install: cp ./.libs/pcntl.so /home/drugpunker/php/ext/pcntl/modules/pcntl.so
libtool: install: cp ./.libs/pcntl.lai /home/drugpunker/php/ext/pcntl/modules/pcntl.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /home/drugpunker/php/ext/pcntl/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /home/drugpunker/php/ext/pcntl/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0
PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0

=====================================================================
PHP         : /usr/bin/php
Warning: Module 'pcntl' already loaded in Unknown on line 0

PHP_SAPI    : cli
PHP_VERSION : 5.5.3-1ubuntu2.3
ZEND_VERSION: 2.5.0
PHP_OS      : Linux - Linux Drugpunker-PC 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64
INI actual  : /home/drugpunker/php/ext/pcntl/tmp-php.ini
More .INIs  : 
CWD         : /home/drugpunker/php/ext/pcntl
Extra dirs  :
VALGRIND    : Not used
=====================================================================
TIME START 2014-05-07 11:41:09
=====================================================================
FAIL Test pcntl wait functionality [tests/001.phpt]
FAIL pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
FAIL pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
FAIL Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
FAIL pcntl_alarm() [tests/pcntl_alarm.phpt]
FAIL pcntl_exec() [tests/pcntl_exec.phpt]
FAIL pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
FAIL pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
FAIL Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
FAIL Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
FAIL Test pcntl_get_last_error() [tests/pcntl_get_last_error.phpt]
FAIL pcntl_signal() [tests/pcntl_signal.phpt]
FAIL pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
FAIL pcntl_wait() [tests/pcntl_wait.phpt]
FAIL Closures as a signal handler [tests/signal_closure_handler.phpt]
=====================================================================
TIME END 2014-05-07 11:41:13

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   42
---------------------------------------------------------------------

Number of tests :   15                15
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   15 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    4 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test pcntl wait functionality [tests/001.phpt]
pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() [tests/002.phpt]
pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK [tests/003.phpt]
Bug #47566 (return value of pcntl_wexitstatus()) [tests/bug47566.phpt]
pcntl_alarm() [tests/pcntl_alarm.phpt]
pcntl_exec() [tests/pcntl_exec.phpt]
pcntl_exec() 2 [tests/pcntl_exec_2.phpt]
pcntl_exec() 3 [tests/pcntl_exec_3.phpt]
Test function pcntl_fork() by calling it with its expected arguments [tests/pcntl_fork_basic.phpt]
Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson [tests/pcntl_fork_variation.phpt]
Test pcntl_get_last_error() [tests/pcntl_get_last_error.phpt]
pcntl_signal() [tests/pcntl_signal.phpt]
pcnt_signal_dispatch() [tests/pcntl_signal_dispatch.phpt]
pcntl_wait() [tests/pcntl_wait.phpt]
Closures as a signal handler [tests/signal_closure_handler.phpt]
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.    You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: y

Please enter your email address.
(Your address will be mangled so that it will not go out on any
mailinglist in plain text): drugpunker@gmail.com

Posting to http://qa.php.net/buildtest-process.php

Thank you for helping to make PHP better.
Installing shared extensions:     /usr/lib/php5/20121212/
cp: cannot create regular file '/usr/lib/php5/20121212/#INST@12755#': Permission denied
make: *** [install-modules] Ошибка 1

22

kisil пишет:

А такая есть. Ну не всёже копипастите

+ открыть спойлер

 Консоль:
$ ls -l /usr/lib/php5/20121212
итого 680
-rw-r--r-- 1 root root 109968 апр.   4 05:23 gd.so
-rw-r--r-- 1 root root  39736 авг.   8  2013 json.so
-rw-r--r-- 1 root root  47872 окт.  16  2013 mcrypt.so
-rw-r--r-- 1 root root 151168 апр.   4 05:23 mysqli.so
-rw-r--r-- 1 root root  56304 апр.   4 05:23 mysql.so
-rw-r--r-- 1 root root 135056 апр.   4 05:23 opcache.so
-rw-r--r-- 1 root root  36008 апр.   4 05:23 pdo_mysql.so
-rw-r--r-- 1 root root 113984 апр.   4 05:23 pdo.so

23

Нет pcntl в библиотеке  ak

24

Во верно. Теперь зайдите вот в эту директорию

 Консоль:
/home/drugpunker/php/ext/pcntl/modules/

Скопируйте pcntl.so в директорию с разширениями php
 Консоль:
cp  pcntl.so /usr/lib/php5/20121212/pcntl.so

Поправте конфиг  ПХП как в мануале. перезапустите апач и потом аж
 Консоль:
php -m | grep  pcntl

Trouble  in WINDOWS reboot, trouble in UNIX be root.

25

ТС ну как там дела. Я проделал так же как и вы тока без make install, я библиотеку ручками копировал, и у меня  phpinfo() показывает

pcntl support    enabled
Trouble  in WINDOWS reboot, trouble in UNIX be root.

26

Ура, ошибка в логах Apache пропала.

СПАСИБО ОГРОМНОЕ.

Теперь снесу и установлю заново...чтобы закрепить

27

kisil пишет:

pcntl support    enabled

сейчас посмотрю тоже

28

kisil пишет:

ТС ну как там дела. Я проделал так же как и вы тока без make install, я библиотеку ручками копировал, и у меня  phpinfo() показывает

pcntl support    enabled

А под какой шапкой смотреть, что-то не нашёл?

29

Та на странице что загрузилась в браузере просто Ctrl+F  и ищите строку "pcntl"

Trouble  in WINDOWS reboot, trouble in UNIX be root.

30

Всё нашёл, работает.

Короче надо мануал самому написать, многим полезно будет...