To test this out further I created a script called 'console' and made it executable. The contents of the script were the following:
#!/usr/bin/env php
<?php
var_export(file_put_contents('test.txt', 'data'));
exit;
The output of the var_export was always 4 - yet if I deleted test.txt and ran the script again a file was only written when once every 10 seconds or so.
I'm running this script on PHP 5.5.9 on a Ubuntu Server 14.04 VM. I do not have the Zend Opcache enabled for console usage, and have confirmed that it is indeed disabled while running this script.
Edit: A little more information. Running this script directly on my machine (not in a VM, on Ubuntu Desktop 14.04, with PHP 5.5.9) works fine, it creates the file every time without fail.
To add a little extra information, the particular shared folder that this is using in the VM is mounted via NFS.
Related
I am trying to make a bash script on my server to clear the Grav cache. When I run it from the server, it works fine. But when I run it from my local machine, over SSH, I get an error: You are running PHP 5.6.36, but Grav needs at least PHP 7.1.3 to run. However, php -v on my server returns PHP 7.2.11 (cli) and on my local machine returns PHP 7.1.23 (cli). I do not begin to understand what the problem might be.
In the end, I could not resolve the issue of the different PHP versions, but solved the problem by including the path to the correct PHP version in the server script. So, locally I have ssh jeremygrav#ps589716.dreamhostps.com "bash ./clear.sh" and on the server, the script contains /usr/local/php73/bin/php bin/grav cache --all.
That works fine, although I realise it avoids the problem rather than solving it.
I have a 32 bit executable written in VB6 that uses the ADODB library, this exe is launched by a php script.
If I run the script from the command line ('php.exe /f script.php') everything works, but when the same script is launched from the web server (apache 2.4) there is an 'automation error' in the .exe file when try to create ADODB.Connection.
Local webserver on Windows 7
It is evident that the problem is not ADODB otherwise it would never work, however I spent many hours working on the Apache and php user permissions, but the evidence shows that the user running istance of php that run the script is always the current one.
At this point I have finished the ideas, if someone has some new ones, I will be grateful
Not really a problem. Just curious.
When I run hhvm in cli directly it prints usage. Something that I have to specify php file. But when I run php (which is symbolic link to /usr/bin/hhvm) it just hangs. I have to stop it with ctrl^c. Also when I run a php file, hhvm executes file and returns me to prompt but php executes file and then hangs.
Why would this be happening?
Php works through fast-cgi with nginx with no problems. I think that this is a reason that phpstorm stopped receiving connections from xdebug after I updated hhvm.
P.S. I don't have php installed. Just hhvm and I made link /usr/bin/hhvm -> /usr/bin/php for composer to work.
This is because the HHVM binary is running in PHP mode, where it tries to emulate what the PHP binary does.
In this case, it's not hanging but waiting for input as running php-cli with no arguments causes it to read from stdin, then execute it.
I think I have two PHP installs on my machine. if I run the following command:
which php
my system locates an install at /usr/bin/php. But the php I was using before reconfiguring was running from /usr/local/zend/bin/php
The problem is, I need to run the php in the /usr/local/zend/bin directory, but it looks like the other php is currently running. I tried to find the process and kill it using:
ps -ef | grep php
But it's not listed. My question is how can I specify which version of PHP should be running on my system (CentOS)?
PHP is not a running process, so you won't find it with ps. If you're using it on a web server, it'll usually be loaded as a module within your web server, such as Apache. The binaries you're finding in /usr/bin/php and /usr/local/zend/bin/php are the CLI binaries, so you wouldn't use these with your website anyway.
The version that you're using is going to be the version of the library referenced by your web server. If you're using Apache, you'll want to check Apache's configuration to see which library it points to.
You can also create a small script with <? phpinfo(); ?> in it, then load this from a web page to get detailed information about the version you're running.
I got the 140dev Twitter framework (which uses the Twitter phirehose) manually
running (via the webbrowser on my local wamp server), but I can't
figure out how to run both get_tweets.php and parse_tweets.php as a
background process like with SSH commands:
nohup php script.php > /dev/null &
Some of you started using (the Windows equivalent of) cronjobs, but
this isn't the right way to go. I think this is because of creating
multiple connection (or re-connections) to the Twitter streaming phirehose isn't allowed?
How can I run both PHP scripts (get_tweets.php and parse_tweets.php)
as a background process on my local WAMP server (and later on a VPS)?
Just to clearify:
I am using a WAMP server (first to test a little bit and later to
run it on a VPS)
Using LAMP or any *nix server/system isn't an option (due to time,
experience and lack of skills)
I have searched for solutions (on google and stackoverflow), but they are either not working or not clear enough for me (I am new to this)
Thank you in advance.
Find the php/bin folder where the php.exe is located. Copy the folder path and add it to your PATH environment variable (Follow this for instance to edit your PATH variable.
Once this is done, you'll be able to execute php in the command line from anywhere. Just start php script.php with a command line in the right folder and it should work. There might be some configuration to make so that the php in command line uses WAMP's php.ini.