Cannot run Gearman worker - undefined symbol: ZVAL_NEW_ARR - php

I have installed Gearman on my system and when I run php --info | grep gearman I've got
php --info | grep gearman
gearman
gearman support => enabled
libgearman version => 1.1.19.1+ds
Also, I have added in php.ini - extension=/usr/lib/php/20210902/gearman.so
lsof -i tcp:4730 shows that it is running
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gearmand 297767 root 10u IPv4 1211167 0t0 TCP localhost:4730 (LISTEN)
When I try to run a worker I've got:
php: symbol lookup error: /usr/lib/php/20210902/gearman.so: undefined symbol: ZVAL_NEW_ARR
Workers/clients are the basic ones from the Gearman page. Worker:
<?php
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction("reverse", "my_reverse_function");
while ($worker->work());
function my_reverse_function($job)
{
return strrev($job->workload());
}
?>
Client
<?php
$client= new GearmanClient();
$client->addServer();
print $client->do("reverse", "Hello World!");
?>
Can anyone help here?

Related

why git clone in php can execute with cli but fpm not

I want to execute a git command in my php script. And this is my script demo.php.
<?php
exec("ssh -v > log1.txt 2>&1");
exec('git clone git#github.com:xxx/xxx.git >log.txt 2> &1',
$out,$ret);
?>
When I execute this:
php demo.php
It clones the target project. However, when I execute it through fpm by typing the url in the browser, it sends the request to nginx, then nginx transfer this request to fpm.
type url: localhost:port/demo.php
Now it comes into trouble and the output is as below:
log1.txt
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-J [user#]host[:port]] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
[user#]hostname [command]
It seemed that this script executed by fpm and ssh has already been installed.
However log.txt is as below:
Cloning into '/home/geek/xxx/phpStudy/idl'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
It seemed that it can't find the ssh command when executing git clone from this file.
I can do it with cli, and I can execute ssh command with fpm, but I cannot run ssh with git clone and fpm. This question has tortured me for serveral days. I will appreciate any advice.
I have solved this trouble. The solution as below and hope help others who encounter this trouble.
The fpm can listen several ports and there is a pool configuration file about every port. In this configuration pool there is a directive:
;env[PATH] = /usr/local/bin:/usr/bin:/bin
So the environment variable PATH of fpm maybe different with os, that is to say some command we can use in shell may not be found in fpm.
Finally, I solve this question through amend env[PATH]

Artisan Error: Failed to listen on localhost:8000

I'm having a problem starting my Laravel installation. Whenever I type in the terminal php artisan serve, I get this error:
Failed to listen on localhost:8000 (reason:une tentative d'access un
α socket de maniere interdite par ses autorisation d'access a 0t0
tent0e)
What's the problem, and how can it be fixed?
img problem http://i.imgur.com/rOt3Lat.png
it's working now I just changed the listen port from 8000 to 8888 or any other port your services didn't use it
php artisan serve --port="8888"
Fixing Error: Failed to listen on localhost:8000 (reason: Address already in use)
List processes with php in it
ps -ef | grep php
Example output
501 **9347** 393 0 1:29PM ttys000 0:00.21 php artisan serve
501 9351 **9347** 0 1:29PM ttys000 0:02.01 /usr/local/php5-5.6.14-20151002-085853/bin/php -S localhost:8000 .../laravel/server.php
501 9781 393 0 1:56PM ttys000 0:00.00 grep php
Then kill the process
kill -9 9347
Are there any other services running on port 8000?
You can use this command on Windows:
netstat -aon | more
or on Linux / OSX
sudo netstat -plnt
to see what services are running. Then disable the service that is running on port 8000 or use another port.
List process using ps -ef | grep php
Then below only works for me
kill -9 9347
which is a force kill of the process
501 9347 393 0 1:29PM ttys000 0:00.21 php artisan serve
Option 2:
If above not works, Change the default laravel serve port number if you can, like
php artisan serve --port=8088
8000 is the default port. Use instead of :
php artisan serve --port=8005
It is because something already running on that port and you can change the port by command itself, by running following command
php artisan serve --port 8001
Use killall -9 php and if you want to close other services use killall -9 node or killall -9 mysql
When php artisan serve command given, below mentioned problem occured.
macridmi1109#Ridmis-MacBook-Pro kcnk % php artisan serve
Laravel development server started on http://localhost:8000/
[Thu Aug 6 11:31:10 2020] Failed to listen on localhost:8000 (reason: Address already in use)
Then try this line of code,
macridmi1109#Ridmis-MacBook-Pro project_laravel % ps -ef | grep php
Result will be,
501 66167 1 0 11:24am ttys002 0:00.77 /usr/bin/php -S localhost:8000
/Users/macridmi1109/Documents/Laravel/project_laravel/server.php
501 66268 64261 0 11:31am ttys002 0:00.00 grep php
Finally run the below code and, then again php artisan serve
macridmi1109#Ridmis-MacBook-Pro project_laravel % kill 66167
SOLUTION EXPLAINED BELOW
I use the command, ps -ef | grep php. After that, you will be able to find Process ID. After recognising the correct Process ID, use this command kill 66167 (kill "Process ID"). Then try php artisan serve. This worked for me.
Happy Coding😊
For me, it was silly mistake. I have installed php in new machine but php.ini was missing. So, I have created php.ini file from php.ini-production file and then php artisan serve command worked fine as expected.
for me php -S localhost:8080 from the terminal in vs code will sometimes crash, but still be running in the background.
-9 to force kill did it for me
thanks #hemss
I did
php -S localhost:8080
[Wed Dec 12 13:48:03 2018] Failed to listen on localhost:8080(reason: Address already in use)
then I..
sudo netstat -plnt
find the process running on port 8080
tcp 2 0 127.0.0.1:8080 0.0.0.0:* LISTEN 10312/php
then force kill it..
kill -9 10312
I get
[1] + 10312 killed php -S localhost:8080
then restart...
php -S localhost:8080
best way if you 8000 port is busy or you have more one project running is run your project in new port such as 8088 or another free port.
php artisan serve --port=8088
The solution I found a problem we face several times in Ubuntu.
*Failed to listen on 127.0.0.1:8000 (reason: Address already in use)*
What we do, we change the port, right?
This problem can be solved also in few seconds following below steps.
1. Open Terminal
2. **sudo su**
3. **netstat -plnt**
_find the process running on port 8080_
4. **kill -9 PROCESSNUMBER**
For more details, see my blog, click here
If you have all your configurations ok in the .env file then you should:
Use the answer from mayorsanmayor in this post to kill all php processes.
Then php artisan config:clear
Finally, php artisan serve
Good luck!

Error file heroku-php-apache2 : using apachectl instead of httpd in ubuntu

I'm trying to run locally the app from "Getting Started with PHP on Heroku" manual. My OS is Ubuntu 14.04. I had to change "httpd" command in "heroku-php-apache2" file by apachectl to continue. But finally I get this fail:
Action '-D NO_DETACH -c Include /home/{{user}}/php-getting-started/vendor/heroku/heroku-buildpack-php/conf/apache2/heroku.conf' failed.
17:58:40 web.1 | The Apache error log may have more information.
17:58:40 web.1 | Process exited unexpectedly: httpd
The line is ( sleep 2; httpd -D NO_DETACH -c "Include $httpd_config" || true; echo "httpd" >&3; ) 3> $wait_pipe &
I just change httpd by apache2ctl.
Any workaround?

Stopping in-built php server on Mac Mavericks - Livecode

I'm developing something in Livecode and I have been experimenting with using Mavericks own in-built php server. I started the server by sending the following command through shell...
php -S localhost:8000
This enabled PHP to run successfully through localhost:8000/
However, I can not work out how to stop/disable PHP now in order to continue testing starting it - when I previously started PHP through the terminal I was able to do ctrl+c to stop php running but since I do not yet know how to do this through my app I get this error instead...
Failed to listen on localhost:8000 (reason: Address already in use)
Anybody know how I can stop it either via the terminal or through my Livecode app? Attempts to stop it through the terminal using just ctrl+c do not work
open a terminal and type:
ps -ef | grep php
it will list the php process with the pid (process id)
something like
$ ps -ef | grep php
501 14263 14133 0 10:25AM ttys001 0:00.21 php -S localhost:8000
501 14355 14265 0 10:25AM ttys002 0:00.00 grep php
The note the number for the line that lists your php process, the second column is your pid
in the example the process id us 14263, kill it:
$ kill 14263
do another ps
$ ps -ef | grep php
501 14358 14265 0 10:26AM ttys002 0:00.00 grep php
$
The process should not be listed anymore

Using Reactphp for sockets in PHP, port stops listening

I'm developing an iOS app that has a chat system included (using these instructions). The api runs on a LAMP server, so I used ReactPhp instead of Twisted for python as socket handler to communicate between client/server and server/client.
This is the code I'm using for the file socket.php
<?
require 'vendor/autoload.php';
$port = 1337;
$host = '127.0.0.1';
$app = function ($request, $response) {
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end('Hello '.time()."\n");
};
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$http = new React\Http\Server($socket, $loop);
$http->on('request', $app);
echo 'Server running at http://'.$host.':'.$port."\n";
$socket->listen($port, $host);
$loop->run();
?>
Then I just run this on the terminal:
php socket.php
The issues:
It works fine, but... if I close the terminal (or stop the process with ctrl+Z), the port stops listening. How do I get the socket to listen all the time from the moment Apache starts?
After closing the terminal (case 1), if I try running php socket.php again, I get this message: Could not bind to tcp://127.0.0.1:1337: Address already in use - If the port is already in use, then why am I unable to access it after closing the terminal?
What happens is, when you close the terminal session, you kill the process, unless you run it as a daemon.
Nohup to the rescue!
From Wikipedia:
nohup is a POSIX command to ignore the HUP (hangup) signal. The HUP
signal is, by convention, the way a terminal warns dependent processes
of logout.
Output that would normally go to the terminal goes to a file called
nohup.out if it has not already been redirected.
If on Debian-based system (i.e. Ubuntu):
sudo apt-get install nohup
If on Fedora-based system (i.e. Centos):
sudo yum install nohup
Then, run your PHP script like this:
nohup php socket.php &
This will solve your problem #1, which will in turn solve #2 as well.
If the process you just launched as a daemon writes anything to stdout, you can see that by running cat nohup.out from the folder where you executed the aforementioned nohup php ... command.
It seems that php thread still running. From terminal:
ps -ef | grep php
Output:
501 7286 3848 0 10:09AM ttys002 0:00.08 php socket.php
Kill thread:
kill 7286
Update for Nino:
The second issue can happend using nohup command too.

Categories