I've gotten trouble around the error "Couldn't resolve host '...'".
I have also researched through many topics and couldn't find the workaround.
First time, same the code, I could do curl without no problem. But today it suddenly stopped working. Here were my attempts
Same the code in my localhost, curl worked fine.
In my server CentOs 6 (using Cpanel Whm), my structure of directories looks like following
public_html
-YiiWebsiteFolder
-curl_test.php
I could run curl to same URL in curl_test.php without the problem, it worked fine. It also worked even I put the curl_test.php inside the YiiWebsiteFolder, so problem wouldn't not be the permission.
But if I run same code to call curl through Yii (YiiWebsiteFolder), ran it in Yii controller and action, it would raise the error 'Couldn't resolve host ...'.
(my URL rewrite is very normal, my site URL looks like "mydomain.com/index.php/test/myaction" )
So I guessed the cause could be Yii, was not DNS problem like some help topics said.
http://forums.cpanel.net/f34/file_get_contents-couldnt-resolve-host-name-120065.html
Couldn't resolve host and DNS Resolution failed
Both Yii config main.php files of my local machine and my server are same.
Edited: I have found this guy who had same problem like me
cURL doesn't work when it's used in a PHP application and running > through a web browser
cURL doesn't work when it's used in a PHP application and running
through a web browser. However, that same PHP page with cURL, when run
via the terminal, does what it's supposed to do and fetches the
information that I want
But he has found it out the problem is the DAEMON array, but I don't use Apache DAEMON (even I don't sure what it is).
I have tried all of possible solutions such as restarting my network and my apache to change the order when they started, modify etc/resolv.conf / (add or remove 12.0.0.1 and try some public DNS)
service network stop
service network start
service network restart
/sbin/service httpd stop
/sbin/service httpd start
I've spent many hours to troubleshoot the problem but no succeed at all.
Any help is really appreciated.
This does not solve your specific problem but I thought I should post to say I had the same problem in that PHP cURL could not resolve any host name when the PHP script was run from a web browser but the same script run from the terminal command line worked fine (i.e. cURL resolved host names to return the expected response). In my case it was resolved with the following:
/sbin/service httpd stop
/sbin/service httpd start
Related
When I was looking at Azure, there was an option to restart IIS from the web-based control panel: according to a friend of mine, the interface is just calling powershell scripts on the backend. My current VPS provider offers the same thing, restarting the web server from a web page.
I've tried
echo Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "& {iisreset}"');
but get "Access Denied."
I've tried
echo Shell_Exec ('command.exe appcmd stop site "that_website"');
and it doesn't throw an error, but it doesn't work either.
Here's the goal: occasionally, PHP will go toes up (Fast-CGI process has stopped working) and my phone rings. I'd like to give the client the option to press a button and restart their site. What permissions do I need, and/or what code would do that?
I can get appcmd work when I modify your code to
echo Shell_Exec ('appcmd.exe stop site "website"');
If you want to do something like iireset with powershell in PHP, just try to change IIS manager->site node->basic settings->connect as-> specific user-> try to replace it to a domain administrator account.
But it is not recommended to do this operation in a PHP application.
When you are facing access denied error, try to use process monitor to troubleshooting this kind of issue.
https://learn.microsoft.com/en-us/sysinternals/downloads/procmon
Here is what the control panel looks like
But the output over here seems like it's working??
So far I've tried a whole bunch of terminal commands to force it to start and none of them have worked so far. Then I tried reinstalling but the same problem. I tried changing the port but that didn't work either.
When I run php files in the htdocs folder it works fine though, but phpMyAdmin doesn't connect.
This is error I get when trying to connect to phpMyAdmin
Having just spent hours on this problem, the following answer helped me:
"If the problem is not a busy port you can also try the following: select "show debug information" in the XAMPP config panel. you will find this option in config panel enable this option and click save it will display the files that are being executed, like when starting Apache you'll be shown something like "Executing "c:\xampp\apache\bin\httpd.exe". If you run the same command in cmd prompt it will clearly display the error with file name and line number.
All you need to do is to find the respective file dig in the code and resolve it.Your problem will be [may be] solved."
First my english might be bad so if you understand what I mean but the sentence is not correct feel free to edit my post, and if you don't understand I'll try my best to explain better.
I installed XAMMP on my MyBook Air version 10.11.5. I can launch the application but in "Manage servers" when I press the "Start all" button all the status switched from "Stopped" to "Starting" and then return to "Stopped" after about 20 seconds. Here is the application log :
Starting MySQL Database...
Starting Apache Web Server...
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd started
Starting ProFTPD...
Checking syntax of configuration file
/Applications/XAMPP/xamppfiles/proftpd/scripts/ctl.sh : proftpd started
Two things here : the MySQL database doesn't send anything in return and it seem that for the log the servers are running. So maybe it was only a display problem on the "Manage servers" tab so I tried to go to the adress http://localhost but nothing.
After a lot of research and try the only topic who gives me what I want is this one : MySQL Database won't start in XAMPP Manager-osx
The command sudo /Applications/XAMPP/xamppfiles/bin/mysql.server startworks perfectly. So now I can start the MySQL server only. The I noticed something, here is the terminal log :
MacBook-Air:~ user$ sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Starting MySQL
. SUCCESS!
You can see I had to enter my session password. So my questions are simple :
Could the password be the problem for the XAMPP Manager ?
i.e. the manager try to launch the servers but encounter the password request and then failed to launch the servers.
If it's the case how can I give to XAMPP the access so the manager can launch on is own the servers without needed to use the terminal ?
Is there any command like the one below to launch also the PHP server if I can't fix the Manager problem ?
I promise I did research on this topic but I find nothing about this specific password (I was often redirected on starting session password...).
Thank you for reading and maybe for answering !
Yes because thats not the right way to start XAMPP.
You should do the following instead cd to your xampp application folder, there should be a executable file called xampp. The gui application is not that good, I've had various problems with it, I think the best thing to do is to start it via terminal.
The password is not the problem, its asking because it requires admin privileges to run it. Thats why you're using sudo.
Run the following command:
sudo ./xampp start
You can find the list of all xampp terminal commands by typing the following:
./xampp -h
For example you can start different 'modules' of the application separately e.g to start just apache.
sudo ./xampp startapache
I hope this helps.
Could it be something broken with the installer?
I had the same issue, but after downgrading to 7.0.5 everything works fine on El Capitan.
I'm using WAMP. In the past weeks I struggled a lot to make php and curl work behind a corporate proxy, finally I did it: Apache behind corporate proxy
The problem is that now I can't make them work at home! (of course initially they were working at home without proxy). When I run a CURL command from php I get the following error: Curl error: Failed to connect to localhost port 3128
I removed all the environment variable https_proxy and http_proxy, on apache I removed the "proxy_module", on IE I removed the proxy, now when I run the following command there are no results:
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"
It seems that CURL is taking the proxy configuration from somewhere in the environment variable, in fact if I add the applicative code:
curl_setopt($ch,CURLOPT_PROXY, '');
then everything is working fine (but I don't want to change the applicative code). Where else can I look for the proxy confing?
Thanks very much
First, I read some threads by people with similar problems but all answers didn't go beyond export DISPLAY=:0.0 and xauth cookies. So here is my problem and thanks in advance for your time!
I have developed a little library which renders shelves using OpenGL and GLSL.
Last few days I wrapped it in a php extension and surprisingly easy it works now.
But the problem is it works only when I execute the php script using the extension from commandline
$php r100.php(i successfuly run this from the http user). The script is in the webroot of apache and if I request it from the browser I get ** CRITICAL **: Unable to open display in apache's error_log.
So, to make things easier to test and to be sure that the problem is not in the library/extension, at the moment I just want to start xmms with following php script.
<?php
echo shell_exec("xmms");
?>
It works only from the shell too.
I've played with apache configuration so much now that I really dont know what to try.
I tried $xhost + && export DISPLAY=:0.0
In the http.conf I have these
SetEnv DISPLAY :0.0 SetEnv XAUTHORITY /home/OpenGL/.Xauthority
So my problem seems to be this:
How can I make apache execute php script with all privileges that the http user has, including the environment?
Additional information:
HTTP is in video and users groups and has a login shell(bash).
I can login as http and execute scripts with no problem and can run GUI programs which show up on display 0.
It seems that apache does not provide the appropriate environment for the script.
I read about some difference between CLI/CGI but cant run xmms with php-cgi too...
Any ideas for additional configuration?
Regards
Sounds bit hazard, but basically you can add even export DISPLAY=:0.0 to apache start-up script (like in Linux /etc/init.d/httpd or apache depending distro).
And "xhost +" need to be run on account which is connected to local X server as user, though I'm only wondering how it will work as php script should only live while apache http request is on-going.
Edit:
Is this is kind of application launcher?, you can spawn this with exec("nohub /usr/bin/php script.php &"); .. now apache should be released and php should continue working in background.
In your console, allow everyone to use the X server:
xhost +
In your PHP script, set the DISPLAY variable while executing the commands:
DISPLAY=:0 glxgears 2>&1