I am currently trying to enable cURL on my EC2 server (free tier).
I have installed php5_curl and I am able to run curl through php via SSH.
I am using the following file to see whether cURL has been installed correctly.
testCurl.php
<?php
function _iscurlsupported() {
if (in_array ('curl', get_loaded_extensions())) {
return true;
}
else {
return false;
}
}
if (_iscurlsupported()) {
echo "cURL is supported\n";
}
else {
echo "cURL isn't supported\n";
}
?>
The command via ssh: php testCurl.php displays that curl is supported.
The command when I access it through a brower displays that curl ISN'T supported.
I have checked the php.ini file located in php5/apache2 (the php.ini file that the browser loads (tested through another script)) and the extension is no where to be found.
I have checked the "extensions_dir" directory located on my server and the curl.so file is located there.
I am unsure why I am unable to run curl when accessing my script via the browser.
Any help would be greatly appreciated.
Cheers,
jt234
Note: If you require any more information please ask.
My problem is similar (if not the same as) Unable to use PHP curl on amazon ec2 free tier but the issue hasn't been resolved.
In the end of your php.ini file add the line:
extension=curl.so
if you want to find where it is located you can run over SSH:
$ locate curl.so
it should be in something close to: /usr/lib/php5/20090626+lfs/curl.so
Related
The php function yaml_emit_file() is not working. I have installed and included the php_yaml.dll in my php.ini file restarted the server but still when I use this function, I get this error (when I run composer):
Call to undefined function RS\composer\yaml_emit_file()
Okay so a little about the background:
PHP version 7.1.7 & Composer version 1.5.1
I am using this function in a ScriptHandler.php file which is invoked when Composer is run. In this script I have a function buildModuleList which is called on post-update-cmd event of Composer. Everything else in the code is working fine.
I am in doubt that maybe I am using this function in wrong context or something like that.
Here is the code snippet where I am using yaml_emit_file() (Providing this just for reference, tell me if am using it the wrong way!):
if (!$fs->exists($moduleListFile)) {
$fs->touch($root.'/profiles/thunder/modulelist.yml');
$fs->chmod($root . '/profiles/thunder/modulelist.yml', 0666);
if(!empty($moduleList)){
$createyml= yaml_emit_file($moduleListFile, $moduleList);
if (!$createyml){
$io->writeError('<error>Cannot create modulelist.yml</error>');
}
}
$io->write('Success: Created new modulelist.yml', $newline= TRUE);
}
else{
$fs->file_put_contents($moduleListFile, $installedPackage, FILE_APPEND);
$io->write('Success: Module entry in modulelist.yml', $newline= TRUE);
}
i hope this help someone i test it on
Windows 10
XAMPP v3.2.4
PHP 8.0.2
Download the latest YAML DLL Package from : https://pecl.php.net/package/yaml
Unzip the files
Move the php_yaml.dll file to xampp/php/ext folder
Open your php.ini in xampp/php add a new line extension=php_yaml.dll, save and exit
Restart your XAMPP Servers
make a PHP file put into
<?php
phpinfo();
?>
Search the string yaml on the page. If it says Enabled then your YAML Extension is working.
After running the httpd by using the command service httpd restart, but I am unable to run the project locally. While running the project, it displayed the PHP code. Can you please help me to solve the issue? This is the PHP code:
<?php// allow testing from the upgrade page before the site is upgraded.if (isset($_GET['__testing_rewrite'])) {
if (isset($_GET['__elgg_uri']) && false !== strpos($_GET['__elgg_uri'], '__testing_rewrite')) {
echo "success";
}
exit;}require_once(dirname(__FILE__) . "/engine/start.php");$router = _elgg_services()->router;$request = _elgg_services()->request;if (!$router->route($request)) {
forward('', '404');}
Check the HTTP config and error log. The PHP module is not loaded any longer, or the .php extension (or whatever extension you've used) isn't associated with the PHP module any longer.
Until you give us more details, that's all we can answer with.
What can I do if I turn on the access but still get php errors?
Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in ------------- on line 40
Warning: file_get_contents(http://finance.google.co.uk/finance/info?client=ig&q=NASDAQ:MSFT) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in --------------- on line 40
try
ini_set("allow_url_fopen", 1);
if (ini_get("allow_url_fopen") == 1) {
echo "allow_url_fopen is ON";
} else {
echo "allow_url_fopen is OFF";
}
print ini_get("allow_url_fopen");
or you can try a different method
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$return = curl_exec($ch);
curl_close ($ch);
return $return;
}
$string = curl('http://www.example.org/myfile.php');
Try to add this code to your .htaccess file:
php_value allow_url_fopen On
if using wamp php.ini are two folders C:\wamp\bin\apache\apacheVersion\bin and C:\wamp\bin\php\phpVersion so make setting allow_url_fopen=on in both files
it took me 3 days to figure it out.
Decided to post this in case you have a similar situation like me.
In my case, I am using a shared hosting setup and I was trying to install composer and then slim framework.
From CPanel I had Php 7.2 selected and phar and json enabled.
But from SSH shell when I would run composer commands it would say phar and json extensions are not installed. Moreover the php version was 5.6.
php --ini
or
php -v
then I checked all aliases on SSH to see which PHP was binded
alias
So I learnt that SSH shell PHP version has nothing to do with front-end cpanel php.
bothe are completely separate setups.
now to update my php version for shell I aliased php to php72 folder via shell command.
Then the problem was how to enable phar and json libraries. So I passed them in my command to use those libraries when executing my composer.phar scripts.
$ php -d extension=phar.so -d extension=json.so composer.phar require slim/slim:4.0.0
You can also change the default PHP for your SSH by updating the .bash_profile and define the alias in their for php as;
alias php='your php folder path'
the .bash_profile file will be in the root directory of your user folder if you FTP it. CPanel file explorer doesn't show hidden or other types of files. It only shows certain extension files.
And it finally worked and installed my slim framework.
I hope this helps those who are struggling.
Peace!
Proud Pakistani
How can I check whether the server is able to handle SOAP requests at run time ?
I need to verify it before my script is executing.
You can use:
if (extension_loaded('soap')) {
// Do things
}
http://php.net/manual/en/function.extension-loaded.php
From SSH you can run:
php -i | grep Soap
that will return something like:
Soap Client => enabled
Soap Server => enabled
In PHP to check whether SOAP enabled or not use built in function class_exists():
var_dump(class_exists("SOAPClient"));
It also could be user to check any of modules classes.
in the command line type the following:
>> php -r 'echo (extension_loaded("soap")?"LOADED\n":"not loaded\n");'
Hmm... I'm new and I'm bad :
I tried this in a "test.php" file.
<?php
if (extension_loaded('soap'))
{
echo phpinfo();
}
else //will redirect to sth else so you know it doesn't work
{
header("Location: http://localhost/index.html");
die();
}
?>
And I saw myself looking at a "phpinfo()" page with a paragraph called : "soap".
Sorry for the misinterpretation.
To install SOAP :
Check your "php.ini" file, look for "extension".
You should find a line :
extension=php_soap.dll or ;extension=php_soap.dll
";" means it's commented.
Uncomment it.
If you didn't find the line, then put it there.
extension=php_soap.dll
Make sure the dll file actually is in the default folder php/ext.
If it isn't, check on phpinfo() is your version is VC6, VC9 of VC11, go to the php download page : http://windows.php.net/download#php-5.6 and get the correspondant version of php zip file.
Steal their "php_soap.dll" from their /ext folder and put it in yours.
You're all set!
Restart your servers, then go to your phpinfo() test page to check if it works.
Good luck.
Note :
phpinfo() simple test.php file :
<php
echo phpinfo();
?>
in a php file :
<?php
echo phpinfo();
?>
and then look for SOAP and you will see if SOAP is installed and enabled
EDIT : be careful with other solutions using php CLI (Command Line Interface), because you don't have the same php.ini used for the CLI and for your web server (for example apache). Thus it may differ.
Then if you use apache and you want to see if soap is enabled, it's better to indicate the apache php.ini file in the command line, for instance :
php -c /etc/php/apache2/php.ini -i | grep Soap
PEAR packages are not listed in phpinfo(), so if "soap" doesn't appear on your "test.php" page, it's normal !
You can use the phpinfo script to see is SOAP is installed.
http://[your-domain.com]/phpinfo.php
I've a development computer, which runs under windows.
For a project, I've to make a php website which has to connect to an Ingres database server.
So I installed wamp, I installed ingres(server and client, on my local machine).
I added the library that I found on their site(php_ingres.dll) in the C:\wamp\bin\php\php5.3.5\ext folder, and I added a line "extension=php_ingres.dll" in the configuration file.
I shutdown wamp and restarted it, and I restarted the server, I see now a check mark in the wamp menu, indicating that php_ingres is now activated. But when I go to the welcome page of the server, I don't see this extension as loaded. If I go on the php info page, I don't see any Ingres entry in the Configure Command.
I just can't found any post/tutorial/... which indicating how to do this operation, so any help would be appreciated!
Thank you!
Edit: I made a small test to see if I can connect to an Ingres database:
<?php
$link = ingres_connect("localhost", "demodbtest", "demodbtest") or die("Connexion impossible");
echo "Connexion réussie";
$result = ingres_query($link,"select * from airline");
while ($row = ingres_fetch_array($result)) {
echo $row["al_iatacode"]; // utilisation du tableau associatif
echo $row["al_name"];
echo $row["al_ccode"]; // utilisation du tableau à indices numériques
echo "</br>";
}
ingres_close($link);
?>
And I get this error:
( ! ) Fatal error: Call to undefined function ingres_connect() in
C:\wamp\www\tests\index.php on line 2
Some information on my installation:
I've a windows 7 pro 32bits
Wampserver 2.1 ( http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1e-x32.exe/download )
Apache 2.2.17
PHP 5.3.5
Ingres 10.1.0 Community edition( downloaded here: http://esd.ingres.com/product/Community_Projects/Ingres_Database/Windows_32-Bit/Ingres_10.1_Build_121/ingres-10.1.0-121-gpl-win-x86-NoDoc.zip/http )
PHP drivers downloaded here: http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver
To practically test if the extension was loaded you can as well call one of it's functions. If the extension was loaded, you should not get a fatal error for a missing function. That's perhaps one of the quickest checks.
Another check is to make use of extension_loaded *PHP Manual** which will give you a list of all loaded extensions. See the PHP Manual link above for more info.
The configure line
The configure line will not show the ingres extension because it has not been compiled in. That's perfectly alright because you load it as an extension (.dll) so it's not part of php.exe. This is why you don't see it in the configure line.
Locating ingres on the phpinfo() page.
On the phpinfo()-page use the search function inside your browser (often CTRL+F) and try to locate the word ingres. You should locate a section that displays the extensions default settings if it has been loaded.
The following is an example screenshot for the xdebug extension. This might look similar for ingres:
Image from: Launching xdebug in Eclipse stuck at 57% - How to trouble-shoot?
Double check your extension_dir setting as well as the actual php.ini file being used. Calling php.exe -i from the command line might not give the same output if executing phpinfo() in a script via Apache (or IIS). In fact http://www.wampserver.com/en/faq.php says there are 3 potential php.ini scripts.
The problem is that I wasn't having the ingres client installed locally, so it appears that this lib cannot works without it