1. 程式人生 > >OSX中php多程序安裝pcntl

OSX中php多程序安裝pcntl

php實現多程序,原始檔:

<?php


$pid = pcntl_fork();
if($pid == -1){
	die('could not fork');
}else{
	if ($pid) {
		var_dump('parent:'.$pid);
		exit('parent');
	}else{
		var_dump('child:'.$pid);
		exit('child');
	}
}

?>


但執行提示出錯:

[email protected]:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so, 9): image not found in Unknown on line 0
PHP Fatal error:  Call to undefined function pcntl_fork() in /usr/local/webdata/andy/php/duojincheng/pcntl.php on line 4
PHP Stack trace:
PHP   1. {main}() /usr/local/webdata/andy/php/duojincheng/pcntl.php:0

[email protected]:/usr/local/webdata/andy/php/duojincheng$

這是因為我們本機的php環境中沒有pcntl.so擴充套件,所以我們下面來為php安裝此擴充套件:

首先了解下自己本機系統中的php-config在哪裡:

Last login: Sun Sep 28 17:04:12 on ttys002

[email protected]:~$ sudo find / -name php-config

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/bin/php-config

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

/Users/andy/Downloads/php-5.4.30/scripts/php-config

/usr/bin/php-config

/usr/local/bin/php-config

/usr/local/Cellar/php54/5.4.30/bin/php-config

[email protected]:~$ ll /usr/bin/php-config

-rwxr-xr-x  1 root  wheel  3672  9 22 09:37 /usr/bin/php-config*

[email protected]

:~$ ll /usr/local/bin/php-config 

lrwxr-xr-x  1 andy  admin  37  7  1 13:04 /usr/local/bin/php-config@ -> ../Cellar/php54/5.4.30/bin/php-config

[email protected]:~


檢視/usr/bin/php-config:

  1 #! /bin/sh

  2 

  3 SED="/usr/bin/sed"

  4 prefix="/usr"

  5 datarootdir="/usr/php"

  6 exec_prefix="${prefix}"

  7 version="5.4.30"

  8 vernum="50430"

  9 include_dir="${prefix}/include/php"

 10 includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"

 11 ldflags="  -L/BinaryCache/FreeType/FreeType-18~1619/Root/usr/local/lib"

 12 libs="-lresolv  -lz -lexslt -ltidy -lresolv -ledit -lncurses -lldap -llber -liconv -liconv -lpng -lz -ljpeg -lcrypto -lssl -lcrypto -lcurl -lbz2 -lz -lpcre -lcrypto -lssl -lcrypto -lm  -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lxml2 -lfreetype -lz -lxml2 -lnetsnmp -lcrypto -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxslt"

 13 extension_dir='/usr/lib/php/extensions/no-debug-non-zts-20100525'

 14 man_dir=`eval echo /usr/share/man`

 15 program_prefix=""

 16 program_suffix=""

 17 exe_extension=""

 18 php_cli_binary=NONE

 19 php_cgi_binary=NONE

 20 configure_options=" '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/Library/Server/Web/Config/php' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--disable-cgi' '--with-curl=/usr' '--enable-dba' '--enable-ndbm=/usr' '--enable-exif' '--enable-fpm' '--enable-ftp' '--with-gd' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--enable-gd-native-ttf' '--with-icu-dir=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-libedit=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-readline=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex=/usr'"

 21 php_sapis=" apache2handler cli fpm"

 22 

 23 # Set php_cli_binary and php_cgi_binary if available

 24 for sapiin$php_sapis;do

 25 case$sapiin

 26   cli)

 27 php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"

 28     ;;

 29   cgi)

 30 php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"

 31     ;;

 32 esac

 33 done

 34 

"/usr/bin/php-config" [readonly] 90L, 3672C


檢視/usr/local/bin/php-config:

1 #! /bin/sh

  2 

  3 SED="/usr/local/Library/ENV/4.3/sed"

  4 prefix="/usr/local/Cellar/php54/5.4.30"

  5 datarootdir="/usr/local/Cellar/php54/5.4.30/php"

  6 exec_prefix="${prefix}"

  7 version="5.4.30"

  8 vernum="50430"

  9 include_dir="${prefix}/include/php"

 10 includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"

 11 ldflags=" -L/usr/local/opt/zlib/lib -L/usr/local/opt/jpeg/lib -L/usr/local/opt/libpng/lib -L/usr/local/Cellar/freetype/2.5.3_1/lib -L/usr/local/Cellar/libpng/1.6.10/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/unixodbc/lib"

 12 libs="  -lz -lexslt -lresolv -ledit -lncurses -lldap -llber -liconv -liconv -lintl -lpng -lz -ljpeg -lcrypto -lssl -lcrypto -lcurl -lbz2 -lz -lcrypto -lssl -lcrypto -lm  -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lxml2 -lfreetype -lz -lbz2 -lpng16 -lodbc -lodbc -lxml2 -lnetsnmp -lcrypto -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxslt "

 13 extension_dir='/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525'

 14 man_dir=`eval echo /usr/local/Cellar/php54/5.4.30/share/man`

 15 program_prefix=""

 16 program_suffix=""

 17 exe_extension=""

 18 php_cli_binary=NONE

 19 php_cgi_binary=NONE

 20 configure_options=" '--prefix=/usr/local/Cellar/php54/5.4.30' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.4' '--with-config-file-path=/usr/local/etc/php/5.4' '--with-config-file-scan-dir=/usr/local/etc/php/5.4/conf.d' '--with-iconv-dir=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-soap' '--enable-wddx''--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-mbregex' '--enable-bcmath' '--enable-calendar' '--with-zlib=/usr/local/opt/zlib' '--with-ldap' '--with-ldap-sasl=/usr' '--with-xmlrpc' '--with-kerberos=/usr' '--with-gd' '--enable-gd-native-ttf''--with-freetype-dir=/usr/local/opt/freetype' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-png-dir=/usr/local/opt/libpng' '--with-gettext=/usr/local/opt/gettext' '--with-snmp=/usr' '--with-libedit' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--mandir=/usr/local/Cellar/php54/5.4.30/share/man' '--with-mhash' '--with-curl' '--with-bz2=/usr' '--disable-debug' '--with-openssl=/usr' '--with-xsl=/usr' '--with-apxs2=/usr/sbin/apxs' '--libexecdir=/usr/local/Cellar/php54/5.4.30/libexec' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl'"

 21 php_sapis=" apache2handler cli cgi"

 22 

 23 # Set php_cli_binary and php_cgi_binary if available

 24 for sapiin$php_sapis;do

 25 case$sapiin

 26   cli)

 27 php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"

 28     ;;

 29   cgi)

 30 php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"

 31     ;;

 32 esac

 33 done

 34 

 35 # Determine which (if any) php binary is available

 36 if test "$php_cli_binary"!= "NONE";then

 37 php_binary="$php_cli_binary"

 38 else

 39 php_binary="$php_cgi_binary"

 40 fi

 41 

 42 # Remove quotes

 43 configure_options=`echo$configure_options|$SED -e"s#'##g"`

 44 

 45 case "$1"in

 46 --prefix)

 47 echo$prefix;;

 48 --includes)

 49 echo$includes;;

 50 --ldflags)

 51 echo$ldflags;;

 52 --libs)

 53 echo$libs;;

 54 --extension-dir)

 55 echo$extension_dir;;

 56 --include-dir)

 57 echo$include_dir;;

 58 --php-binary)

 59 echo$php_binary;;

 60 --php-sapis)

 61 echo$php_sapis;;

 62 --configure-options)

 63 echo$configure_options;;

 64 --man-dir)

 65 echo$man_dir;;

 66 --version)

 67 echo$version;;

 68 --vernum)

 69 echo$vernum;;

 70 *)

 71   cat << EOF

 72 Usage: $0 [OPTION]

 73 Options:

 74   --prefix            [$prefix]

 75   --includes          [$includes]

 76   --ldflags           [$ldflags]

 77   --libs              [$libs]

 78   --extension-dir     [$extension_dir]

 79   --include-dir       [$include_dir]

 80   --man-dir           [$man_dir]

 81   --php-binary        [$php_binary]

 82   --php-sapis         [$php_sapis]

 83   --configure-options [$configure_options]

 84   --version           [$version]

 85   --vernum            [$vernum]

 86 EOF

 87 exit1;;

 88 esac

 89 

 90 exit0



可以看出應該是/usr/local/bin/php-config 而不是 /usr/bin/php-config ,後者好像是個模板之類的東西。

然後我們就可以去編譯php得到php的擴充套件pcntl :

[email protected]:~/Downloads/php-5.4.30/ext/pcntl$ phpize

Configuring for:

PHP Api Version:         20100412

Zend Module Api No:      20100525

Zend Extension Api No:   220100525

[email protected]:~/Downloads/php-5.4.30/ext/pcntl$ ./configure --with-php-config=/usr/local/bin/php-config 

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables... 

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... i386-apple-darwin13.4.0

checking host system type... i386-apple-darwin13.4.0

checking target system type... i386-apple-darwin13.4.0

checking for PHP prefix... /usr/local/Cellar/php54/5.4.30

checking for PHP includes... -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib

checking for PHP extension directory... /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525

checking for PHP installed headers prefix... /usr/local/Cellar/php54/5.4.30/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

checking for gawk... no

checking for nawk... no

checking for awk... awk

checking if awk is broken... no

checking whether to enable pcntl support... yes, shared

checking for fork... yes

checking for waitpid... yes

checking for sigaction... yes

checking for getpriority... yes

checking for setpriority... yes

checking for wait3... yes

checking for sigprocmask... yes

checking for sigwaitinfo... no

checking for sigtimedwait... no

checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no

checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm

checking whether ln -s works... yes

checking how to recognize dependent libraries... pass_all

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking dlfcn.h usability... yes

checking dlfcn.h presence... yes

checking for dlfcn.h... yes

checking the maximum length of command line arguments... 196608

checking command to parse /usr/bin/nm output from cc object... ok

checking for objdir... .libs

checking for ar... ar

checking for ranlib... ranlib

checking for strip... strip

checking for dsymutil... dsymutil

checking for nmedit... nmedit

checking for -single_module linker flag... yes

checking for -exported_symbols_list linker flag... yes

checking if cc supports -fno-rtti -fno-exceptions... yes

checking for cc option to produce PIC... -fno-common

checking if cc PIC flag -fno-common works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes

checking dynamic linker characteristics... darwin13.4.0 dyld

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

creating libtool

appending configuration tag "CXX" to libtool

configure: creating ./config.status

config.status: creating config.h

[email protected]:~/Downloads/php-5.4.30/ext/pcntl$ make && make install

/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=compile cc  -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/pcntl.c -o pcntl.lo 

mkdir .libs

 cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/pcntl.c  -fno-common -DPIC -o .libs/pcntl.o

/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=compile cc  -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/php_signal.c -o php_signal.lo 

 cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/php_signal.c  -fno-common -DPIC -o .libs/php_signal.o

/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=link cc -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o pcntl.la -export-dynamic -avoid-version -prefer-pic -module -rpath /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules  pcntl.lo php_signal.lo 

cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/pcntl.so -bundle  .libs/pcntl.o .libs/php_signal.o  

dsymutil .libs/pcntl.so || :

creating pcntl.la

(cd .libs && rm -f pcntl.la && ln -s ../pcntl.la pcntl.la)

/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=install cp ./pcntl.la /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules

cp ./.libs/pcntl.so /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules/pcntl.so

cp ./.libs/pcntl.lai /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules/pcntl.la

----------------------------------------------------------------------

Libraries have been installed in:

   /Users/andy/Downloads/php-5.4.30/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 `DYLD_LIBRARY_PATH' environment variable

     during execution

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'.

Installing shared extensions:     /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/

[email protected]:~/Downloads/php-5.4.30/ext/pcntl$ cd /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/

[email protected]:/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525$ ll

total 400

drwxr-xr-x  4 andy  admin     136  9 28 18:53 ./

drwxr-xr-x  3 andy  admin     102  7 23 15:51 ../

-rw-r--r--  1 andy  admin  172732  7 23 15:51 apc.so

-rwxr-xr-x  1 andy  admin   26928  9 28 18:53 pcntl.so*

[email protected]:/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525


然後我們就可以到後面的這個目錄去尋找我們的擴充套件檔案pcntl.so,然後我們把這個so檔案copy一份兒到我們系統的php擴充套件目錄中去就可以了。

目前的情況是這個目錄恰巧就是我們本地php版本的擴充套件目錄,所以就不用mv了。(後話:這是因為我們引用了php-config,目錄當然統一了 >< ,我當時不知道)

然後我們要到php.ini中去修改檔案加入:

 849 extension=/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so

(

這裡我們用的時絕對路徑,是因為這不是php預設的擴充套件載入路徑,我本地php擴充套件的預設載入路徑是:

/usr/lib/php/extensions/

比如我本地載入mssql.so在這裡:

/usr/lib/php/extensions/no-debug-non-zts-20100525/mssql.so

)

然後重啟apache伺服器,即可。

pcntl

pcntl support enabled


現在我們來執行最開始的指令碼,執行了兩次,結果如下:

[email protected]:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
string(11) "parent:5576"
string(7) "child:0"
[email protected]:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
string(11) "parent:5619"
parentstring(7) "child:0"
[email protected]:/usr/local/webdata/andy/php/duojincheng$