No ssl on php commandline - php

I have a php script that works perfectly on the browser BUT it has this error on windows command line.
I have ssl enabled in php config and from what I gather it works for browser but not command line but I don't understand the difference between these two (neither is windows service I belive). Basicly I don't know what to do about it and I need to run the script from commandline, then create .bat file (in order to start windows scheduler - like cron under linux).
I have windows Xp and Xampp. Please help.

As mentioned in comment above. Php in command line uses different php.ini config.

Related

PHP is not working on Windows after I completely installed it

I am trying to setup php 5.5.12 on my Windows server 2008 R2
I found this good tutorial that walks you step by step
http://www.youtube.com/watch?v=WUoqkPJEp4Y
After completing every step everything seems to be fine.
I created a file called phpinfo.php and put the following code into and placed it on c:/inetpub/wwwroot
<?php php_info(); ?>
But when I got localhost/phpinfo.php or http://127.0.0.1:80/phpinfo.php I get a 404 error. I do not know why it is not working. when I execute the following from commands from the command line it looks like it is working and I get many output with no error.
cd c:/php
php -i
In addition to the instruction, I added the following to the registry of windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"
Can someone tell me what else do I need to make get php up and running on windows?
This is what is using port 80 on my server
To use localhost or 127.0.0.1 you need apache installed on your system too.
You can download xampp or wamp they both come with PHP, MySql & Apache installed in them.

PHP shell_exec cannot find environment variable

I have added this line PATH DEFAULT=${PATH}:~/bin/ to the ~/.pam_environment
This allows me to call ffmpeg from command line without path which is obviously in ~/bin/ dir so everything works fine as long as im ussing command line.
But if try to run the exact same command from php all i get is sh: ffmpeg: not found
And the code is
shell_exec("ffmpeg 2>&1");
So from my very little experiance with linux (in this case Ubuntu to be specific) i guess apache has no access to pam_environment or ~/bin
What can i do to make this work?
look at the output of phpinfo(), it has a section with all environment variables it sees. then look at your webserver configuration, maybe it's sanitizing the environment, or maybe the init script which starts your webserver does it.
and is the account the webserver is running under using PAM at all?

cURL not working in Windows Task Scheduler

I've a PHP script that uses cURL to perform certain tasks. At the moment, I have the script running every 10 minutes. This is what I'm running via Windows Task Scheduler.
C:\wamp\bin\php\php5.4.3\php.exe -f C:\wamp\www\autoscripts\index.php
However, for some reason, whenever the argument quoted above is run through the command line, I get the error "Fatal error: Call to undefined function curl_init()". The script works perfectly when I access it via the browser. Is there any reason why PHP isn't able to access the cURL extension via the command line?
Most likely running from command line does not use any ini file that loads the extensions. Open phpinfo() from the browser, copy path to loaded ini file and change your task to:
C:\wamp\bin\php\php5.4.3\php.exe -c "C:\path\to\php.ini" -f C:\wamp\www\autoscripts\index.php
Figured it out. Basically, on WampServer, there are TWO php.ini files that you need to be aware of.
C:\wamp\bin\php\php5.4.3\php.ini
C:\wamp\bin\apache\apache2.2.22\bin\php.ini
Forgot that the command line uses a different ini file than the web server. :(

interfacing OpenCV with php

I have an executable file developed using opencv library in cpp and c also. I want to execute it from my website hosted on localhost using a php script.
The problem i'm facing is that, the executable code opens a window(kind of gui, opened using namedWindow) when called from terminal but it doesn't do that when called from the embedded php script.
For execution i have tried exec, system but all these failed.
to be more clear : name of executable -> my_cv_gui, name of phpscript(page) ->abcd.php
#terminal if i type "./my_cv_gui" ... window opens.
# terminal, if itype "php abcd.php" window opens
abcd.php is part of my website. In web browser if i open "http://...../abcd.php", window DOESNOT open. Although other things in the executable work perfectly.
My system configuration
OS : ubuntu 12.04 x64
XAMPP for Linux 1.7.7
Apache 2.2.21
PHP 5.3.8
Opencv 2.4.1
Any solutions??
The php code is as follows
<?php
$output=shell_exec("gst-launch v4l2src device=/dev/video0 ! 'video/x- raw-yuv,width=640,height=480,framerate=30/1' ! ffenc_flv ! flvmux streamable=true ! queue ! filesink location=/home/dev/my.avi > /dev/null &");
var_dump($output);
?>
Two things you should always remember when you are working with apache.
File/Folder Permission. Using which the apache is running.
MIME type should be added to apache to run any kind of multimedia components. Like here it's flv. Then try running the php code and try fixing it. I will check in my server if that works for me. Will update you.
Biswadip.

Warning: exec(): Unable to fork in PHP

I'm using php 5 apache on windows server 2008, I have disabled IIS.
I m using exec command in my PHP script and it was working fine
but today I got an error:
Warning: exec(): Unable to fork
I gave permissions to cmd.exe in C:\Windows\System32 folder
but this did not fix the problem.
Specifically which permissions did you give to who?
Probably not to the right user..
Run this php script:
echo 'Script is executed by: ' . get_current_user() . getmygid();
It will tell you which user is running the PHP scripts and therefore which user to grant permissions to cmd.exe.
In 64-bit windows (e.g server 2008), theres a folder named c:\windows\syswow64, that contains all executables/dll, that are required by a 32 bit app. installed on your 64-bit machine.
Make sure your required 32-bit .exe/dll etc is placed in that folder.
if you cant find it there you will have to put a 32-bit version of the required .exe/dll
there.So this can used by yopur app/process.
Now when your 32-bit application/process executes, windows will automatically redirect your process to execute required app in syswow64 folder.
Hopefully that should resolve your compatibility issue.
I had this problem myself, but was eventually able to resolve it. The problem was due to how I had accidentally set cmd.exe to "Run as Administrator" by default. I say "accidentally" as I thought I was only setting the compatibility settings of a shortcut on my task bar, but it turned-out it was setting the compatibility of the .exe itself. Anyhow, I disabled this by deleting the registry key here:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
After doing this, everything started working again.

Categories