PHP (5.6.11-1 on Debian Strech/sid) does not allows me to run two instaces of cli.
I've tried to execute following script two times. First script runs normally.
Second one is locked until first one is killed.
#!/usr/bin/env php
<?php
$i = 0;
while (++$i) {
var_dump($i);
sleep(1);
}
Do you know what may be reason of that strange behaviour?
Edit: Issue does not occur on other machines. (?)
Edit: Is there something in configuration files of php, that could do that?
Issue was caused by something wrong in configuration (still does not know what was it be).
aptitude purge php5 php5-cli
aptitude install php5 php5-cli
Configuration purging helped.
Related
Problem:
I am wanting to use php-cli scripts to quickly start, restart, or stop Apache 2.4 as well as MariaDB 10.5 on Windows 10. Several years ago, I did this while running Debian:
#!/usr/bin/php
<?php
system('sudo /etc/init.d/apache2 start');
system('sudo /etc/init.d/mysql start');
I would then execute the file by typing something similar to 'php -f .server.start' where .server.start was the name of the file containing the above php code. I have had some luck getting this to work by opening a command line, changing directories to C:\Path\to\Apache24 and using
<?php
system('httpd -k start');
The issue with this is I still have to navigate to that directory to make this work. The purpose is then defeated as I could simply type httpd -k start || stop || restart. I am using this machine at home for a dev box. There are times when I am interrupted for lengthy spans of time and I feel that I need a simple and quick way to shutdown both Apache and MariaDB with a command or two while I am away from my desk.
Perhaps PHP isn't the best solution here? It's what I know and am comfortable with, though, if there are other methods, such as with a batch file, I would be willing to accept any comments/feedback/direction. I have scoured the web trying to get this task done.
I tried to update my PHP version on my mac but I am facing some issues
When i use cURL it freezes and it will never complete the download on the terminal:
This is the cURL command that I am running is: curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
I tried to download a package manually but I can't extract it or even know how to install it.
You can use home-brew for installation / https://medium.com/#romaninsh/install-php-7-2-on-macos-high-sierra-with-homebrew-bdc4d1b04ea6 , I find it quite better then managing with Mac OS build in PHP
I don't have enough details so I will go in blind guess here.
First judging by screenshot it is stuck on downloading. For how long it was frozen? Maybe you didn't wait enough.
When you downloading the source what you need to do is:
Assuming you downloaded package with name php-7.2.6.tar.gz from PHP Official website.
Execute command tar xzf php-7.2.6.tar.gz from command line. (assuming you are in the same directory as file). It will unpack it in directory called php-7.2.6.
Enter the directory with command cd php-7.2.6.
Enter in terminal ./configure. It will take a while, so make sure to get some coffee.
After ./configure finished, execute command make. This will take a while as well, so you might get a sandwich.
Once command finished executing the last step will be executing command make install. It will be quicker than others, don't worry. After that you will be able to execute php command.
Optional Run make test to make sure everything is fine.
PHP has been installed, HOORAY!
Hope that helped, have a nice day. And if I answered your question, please mark it 'Answered`.
The problem is actually in PHP script run by php-fpm 5.6 which is installed from MacPorts.
PHP code system('echo $PATH')
when run by php-fpm it returns
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
when run by php cli in bash it returns
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin
system executes command in sh not bash, but MacPorts adds
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
to ~/.profile and php-fpm is run by nobody not my current user, so that export does not affect php-fpm.
I know I can add that PATH from export to /etc/profile or to /etc/paths.
But which way in safer in case of MacPorts. I don't want to break native OS X functionality or cause conflicts with MacPorts.
EDIT:
changing /etc/profile or /etc/paths does not actually help, system still does not see programs in /opt/local/bin/:
sh: mysql: command not found
You are on the right path (see what I did there?)
Editing /etc/paths is the solution, but you're not just looking for /opt/local/bin/. The mysql binary is (assuming MySQL 5.5) stored in /opt/local/lib/mysql55/bin/mysql. There are a number of such paths in MacPorts:
/opt/local/bin/
/opt/local/sbin/
/opt/local/apache2/bin/
/opt/local/lib/mysql55/bin/
/opt/local/lib/php/pear/bin/
The only thing that worked is setting env[PATH] in /opt/local/etc/php56/php-fpm.conf to the result of echo $PATH
I have been tried for few hours and nearly 1 day to try with this but I failed to make it
I want to run the cron file every 10 minutes and I searched for so many tutorials but I don't know why it is not working. Anyone here who experienced in Webmin scheduled cron job can give me any suggestions?
Have you got PHP-CLI installed on your webmin server? If not, you can install it using:
sudo apt-get install php7.0-cli
sudo apt-get install php5-cli
Either of the commands will work, however it depends on the PHP version you are currently using.
Once installed it will allow you to run PHP command through the command line. Your CRON Job should look simlar to this:
php /var/www/example.com/public_html/crons.php
I haven't had time to test the code, however it should work.
Another solution worked for me was adding complete URL of the file preceding by the 'GET' keyword instead of running it as a php script.
Example:
GET 'https://www.example.com/crons.php'
A file named test.html contains:
hello
It takes a few milliseconds to respond.
A file named test.php contains:
hello
This one takes a few seconds to respond. They're both the same code and contain no actual PHP code. The file extension is the only difference!
I'm loading both via http://localhost/test.html or php
Is there any common snafu in the server settings that I missed? I'm using the standard Ubuntu 11.04, Apache2, PHP5 configuration.
Your help is appreciated... let me know what other details you need.
Well even if there is no actual php code in your php file its getting sent to the php parser by apache because of its extension.
This probably slows it by a few miliseconds and on your system might be more.
Like others have pointed out you probably have some module that is taking too much time. But about your original question my answer stands. Even without code your php file is getting parsed by php.
If you want to get an idea what is going on try the following:
sudo -i
stop apache2
. /etc/apache2/envvars
apache2 -k start -X &
strace -u www-data -tt -ff -o /tmp/strace $(ps -o "-p %p" h -u www-data) &
man strace to find out what it does and don't forget to apache2 -k stop and start apache2 when you are done :) Remember you are all-powerful as root so come out ASAP.
Try adding an .htaccess file and also doing a sudo apt-get install php-apc to see how an Opcode cache works. The next stage is to strart downloading the source and matching this up to what is happening in the system trace. Enjoy.
Even though there's no PHP code, it is being parsed as PHP. The problem could exist with Apache's configuration / installed modules, or possibly if you have a bunch of (or any one problematic) enabled module(s) in PHP.