linux系统lampp运行环境使用pthreads PHP扩展出错? 400 报错
想问下在linux服务器上,lampp运行环境,想使用php多线程,需要使用pthreads PHP扩展,直接安装pthreads-master,提示需要开启-enable-maintainer-zts,需要php重新编译
./configure --prefix=/opt/lampp/include/php --with-config-file-path=/opt/lampp/include/php/etc --with-mysql=/usr/include/mysql --with-mysqli=/usr/bin/mysql_config --with-inconv-dir --with-freetype-dir=/opt/lampp/bin --with-jpeg-dir=/opt/lampp/bin --with-png-dir=/opt/lampp/bin --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/opt/lampp/bin --with-gd --enable-ge-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts
出现错误:configure: error: Cannot find MySQL header files under /usr/include/mysql.
Note that the MySQL client library is not bundled anymore!
用find / -name mysql.h
有两个/usr/include/mysql/mysql.h
/opt/lampp/include/mysql.h
这两个都试了下,都不行cannot find mysql,求解决~
另外想问下在lampp运行环境下,开启pthreads PHP扩展有没有什么其他的方法~
./configure --prefix=/opt/lampp/include/php --with-config-file-path=/opt/lampp/include/php/etc --with-inconv-dir --with-freetype-dir=/opt/lampp/bin --with-jpeg-dir=/opt/lampp/bin --with-png-dir=/opt/lampp/bin --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/opt/lampp/bin --with-gd --enable-ge-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --enable-maintainer-zts
--with-mysql=/usr/include/mysql
--with-mysqli=/usr/bin/mysql_config
给你换成了以下参数,你那参数需要先安装mysql,环境中要由mysql开发库才行。
--enable-mysqlnd
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--enable-pdo
--with-pdo-mysql
另外开启pthreads PHP扩展,扩展也依赖pthreads库,linux一般有
######回复 @mickelfeng : 安装pthreads-master路径,不过make的时候还有一个错误,就是 ./classes/pool.h:330: error: too few arguments to function 'zend_hash_apply' make: *** [php_pthreads.lo] Error 1 帮我再看下~终于快弄好了~我这小笨脑袋~谢谢~######你编译的时候可能没加这个参数 ,还有就是看是不是你编译的那个版本######回复 @mickelfeng : 再问下哈~为嘛我php重新编译后,打开phpinfo,找不到enable-maintainer-zts,是什么情况哈~是缺少了什么吗?求解答######echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf /sbin/ldconfig 加入 /usr/local/lib 后ldconfig 这样再配置就没有错误了~谢谢哈~######--enable-opcache=no 替换成这样######把mysql的改成这样 --with-mysql=/opt/lampp/include --with-mysqli=/opt/lampp/bin/mysql_config
还是出现can't find mysql
来个大神帮我解决下哈~谢谢了~一直都是在win下编程的,现在给我个liunx服务器代码放上去需要
pthreads PHP扩展,求解决啊 @Tuesday,@梦想岛 ,@mickelfeng 来帮忙看下哈~
|
--enable-mysqlnd
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--enable-pdo
--with-pdo-mysql
另外开启pthreads PHP扩展,扩展也依赖pthreads库,linux一般有
安装pthreads-master路径错了,现改成了
cd pthreads-master
/opt/lampp/include/php/bin/phpize
./configure --with-php-config =/opt/lampp/include/php/bin/php-config
不过现在还有一个错误,就是./classes/pool.h:330: error: too few arguments to function \u2018zend_hash_apply\u2019
make: *** [php_pthreads.lo] Error 1
我再看看~终于快弄好了~我这小笨脑袋~
######回复 @mickelfeng : :https://github.com/krakjoe/pthreads和http://pecl.php.net/package/pthreads######回复 @kuangkuang1 : qq: 446838006######要不你给我个qq号或者微信号,我加下你~可以给你截图看下~不过我手机信号也有点屏蔽~估计会比较慢~谢谢哈~######回复 @mickelfeng : 还是不行啊~呜呜~还是 make: *** [php_pthreads.lo] Error 1 这个错误~并且make 有好多的error~ 我用了几个的 pthreads包了 是不是我要在php.ini里添加神马东西~我用的php是5.5.30######回复 @kuangkuang1 : 跟这个没有关系。这个是线程安全。disabled也可以用。###### --enable-mysqlnd
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--enable-pdo
--with-pdo-mysql
另外开启pthreads PHP扩展,扩展也依赖pthreads库,linux一般有
安装pthreads-master路径错了,现改成了
cd pthreads-master
/opt/lampp/include/php/bin/phpize
./configure --with-php-config =/opt/lampp/include/php/bin/php-config
不过现在还有一个错误,就是./classes/pool.h:330: error: too few arguments to function \u2018zend_hash_apply\u2019
make: *** [php_pthreads.lo] Error 1
我再看看~终于快弄好了~我这小笨脑袋~
回复 @mickelfeng : 呜呜~现在还是用不了pthreads,想再问下哈~phpinfo下
Configuration File (php.ini) Path /opt/lampp/etc
Loaded Configuration File /opt/lampp/etc/php.ini
extension_dir /opt/lampp/include/php/lib/php/extensions/no-debug-zts-20121212/ /opt/lampp/include/php/lib/php/extensions/no-debug-zts-20121212/
这个目录也是对的~在/opt/lampp/etc/php.ini这个.ini文件里面改的extension_dir=/opt/lampp/include/php/lib/php/extensions/no-debug-zts-20121212/
extension="pthreads.so" 我真心的不知道我哪个地方还错了哈~求再指点下~感谢~
--enable-mysqlnd
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--enable-pdo
--with-pdo-mysql
另外开启pthreads PHP扩展,扩展也依赖pthreads库,linux一般有
放假了几天,今天刚上班哈~@mickelfeng大师傅,我又重新编译了php,出现了下面的提示,是需要做什么吗?
Wrote PEAR system config file at: /opt/lampp/include/php/etc/pear.conf
You may want to add: /opt/lampp/include/php/lib/php to your php.ini include_path
/root/php-5.5.30/build/shtool install -c ext/phar/phar.phar /opt/lampp/include/php/bin
ln -s -f phar.phar /opt/lampp/include/php/bin/phar
你没安装成功。
PHPDIR/phpize
./configure --with-php-config=/PHPDIR/bin/php-configmake install
vi /PHPDIR/etc/php.ini
添加:
extension = "pthreads.so"
<?php class test_thread_run extends Thread { public $url; public $data; public function __construct($url) { $this->url = $url; } public function run() { if(($url = $this->url)) { $this->data = model_http_curl_get($url); } } } function model_thread_result_get($urls_array) { foreach ($urls_array as $key => $value) { $thread_array[$key] = new test_thread_run($value["url"]); $thread_array[$key]->start(); } foreach ($thread_array as $thread_array_key => $thread_array_value) { while($thread_array[$thread_array_key]->isRunning()) { usleep(10); } if($thread_array[$thread_array_key]->join()) { $variable_data[$thread_array_key] = $thread_array[$thread_array_key]->data; } } return $variable_data; } function model_http_curl_get($url,$userAgent="") { $userAgent = $userAgent ? $userAgent : 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 5); curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); $result = curl_exec($curl); curl_close($curl); return $result; } for ($i=0; $i < 100; $i++) { $urls_array[] = array("name" => "baidu", "url" => "http://www.baidu.com/s?wd=".mt_rand(10000,20000)); } $t = microtime(true); $result = model_thread_result_get($urls_array); $e = microtime(true); echo "多线程:".($e-$t)."\n"; $t = microtime(true); foreach ($urls_array as $key => $value) { $result_new[$key] = model_http_curl_get($value["url"]); } $e = microtime(true); echo "For循环:".($e-$t)."\n"; ?>######运行phpize提示这样的错误: cannot find config.m4. Make sure that you run '/usr/bin/phpize' in the top level source directory of the module 这个php重新编译的~好像一直是重新安装的失败啊~######
你没安装成功。
PHPDIR/phpize
./configure --with-php-config=/PHPDIR/bin/php-configmake install
vi /PHPDIR/etc/php.ini
添加:
extension = "pthreads.so"
<?php class test_thread_run extends Thread { public $url; public $data; public function __construct($url) { $this->url = $url; } public function run() { if(($url = $this->url)) { $this->data = model_http_curl_get($url); } } } function model_thread_result_get($urls_array) { foreach ($urls_array as $key => $value) { $thread_array[$key] = new test_thread_run($value["url"]); $thread_array[$key]->start(); } foreach ($thread_array as $thread_array_key => $thread_array_value) { while($thread_array[$thread_array_key]->isRunning()) { usleep(10); } if($thread_array[$thread_array_key]->join()) { $variable_data[$thread_array_key] = $thread_array[$thread_array_key]->data; } } return $variable_data; } function model_http_curl_get($url,$userAgent="") { $userAgent = $userAgent ? $userAgent : 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 5); curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); $result = curl_exec($curl); curl_close($curl); return $result; } for ($i=0; $i < 100; $i++) { $urls_array[] = array("name" => "baidu", "url" => "http://www.baidu.com/s?wd=".mt_rand(10000,20000)); } $t = microtime(true); $result = model_thread_result_get($urls_array); $e = microtime(true); echo "多线程:".($e-$t)."\n"; $t = microtime(true); foreach ($urls_array as $key => $value) { $result_new[$key] = model_http_curl_get($value["url"]); } $e = microtime(true); echo "For循环:".($e-$t)."\n"; ?>
大师父,我又重新安装了一下:./configure --prefix=/opt/lampp/include/php --with-config-file-path=/opt/lampp/include/php/etc --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-inconv=/opt/lampp/lib --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-ge-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --with-apxs2=/opt/lampp/bin/apxs --enable-maintainer-zts
安装完成后,再cp php.ini-production /opt/lampp/include/php/etc/php.ini
php重新编译完成了~呼呼,终于弄好了~感谢哈~@mickelfeng
######使用mysql的时候会出错~需要把新的php.ini里面的这三项:mysql.default_socket = pdo_mysql.default_socket= mysqli.default_socket = 都设置为 mysql.sock(或mysqld.sock)的具体路径~ 完美~终于解决啦~版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。