I have 2 servers running an proprietary software that I can access by an specific port and sending/receiving JSON string.
In both servers, I have apache2 with ITK for each virtual host.
In server "A", I have an PHP script that uses socket to connect to server "A" and "B" to get data and display on webpage. The problem is that PHP can connect only to server "A" (localhsot), but can't connect to server "B". The PHP doesn't show any error (display_errors are on in php.ini) and when I try to get last error from socket (I don't remember the php function right now), I get nothing.
On apache log, I got this error:
Operation not permitted: AH02156: setgid: unable to set group id to
Group 0
There's no firewall blocking between hosts, I can 'telnet' both servers in any direction without any problem. Just PHP doesn't connect to 'external' hsot, just localhost.
The only change in my vhost file is to add itk option:
AssignUserId rpi rpi
So my question is: how to I configure apache-itk to allow my PHP to open external sockets?
I have tried to change LimitUIDRange to "LimitUIDRange 0 0", but no success.
maybe related to the Apache module:
mpm_itk_module
or
AssignUserId
Apache config.
Please see this links:
http://forum.ispsystem.com/showthread.php?t=2917
https://forum.root.cz/index.php?topic=15707.0
I'm trying to solve the same problem.
If you set LimitUIDRange 0 0, that means that only root is allowed, which doesn't make sense. The correct directives would be LimitUIDRange 0 65534 and LimitGIDRange 0 65534. As long as you don't set any hosts to be run as root, this is not any more insecure than default apache. Especialy does it not mean that website users are allowed to change their own user id. However, they will be allowed to run executables with the setuid bit set, like any other normal user.
I am trying to retrieve a network file from an OpenSUSE 13.1 Host to my OpenSUSE 13.2 Webserver, but I don't seem to have any success.
First I check if target directory is a directory:
$path = "\\\\192.168.xxx.xxx\\public";
if(is_dir($path)){ // returns FALSE every time.
return true;
}
In this case the function is_dir() returns FALSE, although the folder exists and has 777 permisions, the IP is correct, and the computer is turned ON.
I have tried all the combinations of formatting the network path, including $path = "smb://192.168.xxx.xxx/public"; witch returns an error
Unable to find the wrapper "smb" - did you forget to enable it when
you configured PHP?
Could someone tell me what I am missing?
Would it work the same through a OpenVPN with my Centos 6 webserver and an Ubuntu 14 host?
PHP has no built-in Samba support on the Linux platform. You will need to mount the remote share (requires superuser-equivalent access) and access its contents like a local filesystem.
I have a script that uses ftp_connect() among other FTP PHP functions for uploading a file.
ftp_connect() works when executed on my local development server for connecting to a remote FTP server. The same script, when executed on the remote server does not work for connecting to the exact same FTP server.
Could somebody please point me in the right direction?
Thanks!
Here is the code:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$server = 'ftp.someserver.com';
$ftpConn = ftp_connect($server);
if(!$ftpConn)
echo 'failed';
else
echo 'success';
No errors are reported.
So if I understand it correctly then the script above is installed on the server that you're trying to access using FTP (ie. the script is opening a local FTP connection)? What's the use? FTP in PHP is only useful to transfer files between 2 servers, you cannot use it to transfer files from the client to the server (since the script is executed on the server).
edit
Something I didn't add in my original comment : you could use a Java FTP applet if you want to transfer files from the client to the server. But be aware of the security issues involved (because the user credentials can be sniffed :p).
Probably firewall issues. On top of that, FTP was not designed with NAT in mind.
Try to login to the production server and use a ftp client to do the same connection.
I do not know the things inside it very well but I want to give my little help.My server is ubuntu Linux with Apache、PHP and MySQL,and my develop env is MAMP on Mac.
I met the problem suddenly and cannot find what happened because it was worked yesterday,I searched many answers and can't solved it.The ftp_connect($ftp_server) only return bool(false),but I can use my FileZilla,interesting,is it?
So I try to connect the server from my command line,like ftp 111.22.333.44,It shows:
500 OOPS: cannot read user list file:/etc/vsftpd/vsftpd.user_list
I login in my ubuntu server, and didn't find the vsftpd directory,and the vsftpd.user_listis in the directory /etc/,still don't know what happened.
So I simply create the directory and copy the file vsftpd.user_list to it.Then I try ftp 111.22.333.44(your IP address) again and it works now.
hope it help someone else.
within PHP (XAMPP) installed on a Windows XP Computer Im trying to read a dir which exists on a local network server. Im using is_dir() to check whether it is a dir that I can read.
In Windows Explorer I type \\\server\dir and that dir is being shown.
When I map a network drive a can access it with z:\dir as well.
In PHP I have that script:
<?php if( is_dir($dir){ echo 'success' } ) ?>
For $dir I tried:
/server/dir
//server/dir
\server\dir
\\server\dir
\\\\server\\dir
and
z:\dir
z:\\dir
z:/dir
z://dir
But I never get success?
Any idea?
thx
I solved it by changing some stuff in the registry of the server as explained in the last answer of this discussion:
http://bugs.php.net/bug.php?id=25805
Thanks to VolkerK and Gumbo anyway!
I love stackoverflow and their great people who help you so incredibly fast!!
EDIT (taken from php.net):
The service has limited access to network resources, such as shares
and pipes, because it has no credentials and must connect using a null
session. The following registry key contains the NullSessionPipes and
NullSessionShares values, which are used to specify the pipes and
shares to which null sessions may connect:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
Alternatively, you could add the REG_DWORD value
RestrictNullSessAccess to the key and set it to 0 to allow all null
sessions to access all pipes and shares created on that machine.`
add RestrictNullSessAccess=0 to your registery.
You probably let xampp install apache as service and run the php scripts trough this apache. And the apache service (running as localsystem) is not allowed to access the network the way your user account is.
A service that runs in the context of the LocalSystem account inherits the security context of the SCM. The user SID is created from the SECURITY_LOCAL_SYSTEM_RID value. The account is not associated with any logged-on user account.
This has several implications:
...
* The service presents the computer's credentials to remote servers.
...
You can test this by starting the apache as console application (apache_start.bat in the xampp directory should do that) and run the script again. You can use both forward and backward slashes in the unc path. I'd suggest using //server/share since php doesn't care about / in string literals.
<?php
$uncpath = '//server/dir';
$dh = opendir($uncpath);
echo "<pre>\n";
var_dump($dh, error_get_last());
echo "\n</pre>";
Try the file: URI scheme:
file://server/dir
file:///Z:/dir
The begin is always file://. The next path segment is the server. If it’s on your local machine, leave it blank (see second example). See also File URIs in Windows.
Yes, I know this is an old post, but I still found it, and if anyone else does...
On Windows, with newer servers, verify the SMB is installed and enabled on the target machine.
I have a big problem opening http://localhost/ on Windows 7 (beta). I installed this os and everything went great; when I installed Wamp I saw that localhost is not working at all. I just see this error:
Failed to Connect
Firefox can't establish a connection to the server at localhost.
in Mozilla and Explorer.
I removed Wamp and after some weeks (that means two weeks from today) I installed NetBeans on Windows 7. I created a test PHP script and when I debug it, I get the same error again. I tried to access it with ip 127.... but still the same. What is the problem?
When i installed NetBeans I installed it in port 8080.
If you installed it on port 8080, you need to access it on port 8080:
http://localhost:8080 or http://127.0.0.1:8080
To fix the port 80 problem do:
From cmd as administrator:
sc config http start= demand (you need a space after the equal sign and not before)
Reboot
Run the command (netsh http show servicestate) as administrator to check that the port 80 is in use
After you have run this command, you can disable http.sys as follows:
net stop http (stop the process)
Sc config http start= disabled (if you want to disable the service forever)
it works for me.
Edit your C:\Windows\System32\drivers\etc\hosts file
Make sure there is an entry that looks like this:
127.0.0.1 localhost
If there is an entry like
:: localhost
Comment it out to look like this
\#:: localhost
This should fix your problem, I've had this problem in the past.
For me, it was skype causing the problem. Once I stopped skype, everything worked. I have 1.7.1 xampp (mysql and apache) running on Windows 7 x64.
It sounds like you have no web server running at all anywhere.
Have you tried enabling IIS and using it to display a basic html file first?
Programs & Features -> Turn Windows Features On/Off -> Internet Information Servcies
Then, place your html file in C:\inetpub\wwwroot\index.html and browse to http://localhost.
Once this works, try to get WAMP/php working. Be careful of port conflicts.
My initial thought is that you are missing an entry in the hosts file. Something like "127.0.0.1 localhost", however, you mention that you are getting a 404 error. That means that the webserver is connecting to your client/browser and responding to the request for a particular webpage.
I'm not familiar enough with Windows 7, however, I'm pretty sure that it does not include a webserver by default. Also, unless you actually code, build and run a webserver application using netbeans you're not going to get the desired response.
When it comes down to it.... your issue is going to be one of the following:
1) you're serving static documents and the webserver is not configured to serve the files from whatever the proper DOCROOT should be. This includes PUBLIC folders in the user's directories. (the basic apache install include a basic homepage)
2) you have a dynamic webserver application where the controller is looking at the application path in order to decide what page to display or what function to execute. (see MVC - Controller). Basically incomplete implementation.
3) yet another configuration error: your website might actually define a virtual domain. (something other than localhost) so when you look for localhost in the URL the server might not be configured to provide a default page.
Uncommenting the following line in host file worked for me,
#127.0.0.1 localhost
Well you are getting a 404, so the web server is running, it just can't find the file.
Check the http.conf file. If it pointing to the right root directory?
If you are using different ports, then check http.conf to see if Apache is listening on the right port, or if apache is redirecting traffic on the port to anther root directory.
Maybe posting your http.conf file might help?
If you're still having this problem, try this:
Edit your hosts file (with elevated privileges)
Uncomment the line "#127.0.0.1 localhost" (ie- remove the #)
Save the file as is. hosts with no extension
In Win7 MS has decided to comment the localhost line with that msg that says it's handled in dns. I'm still not exactly clear what they're getting at, except maybe that they're telling folks to use dns for localhost resolution instead of the hosts file. Probably safer that way, anyway.
Yea, this was a pain for me as well.
So what i did was find the "Start Wampserver", just hit the start button and type it in.
Then right click on it , select properties.
I set it to run in XP servive pack 3 on the capatability tab.
I also checked the box "Run this program as an administrator".
Then I right clicked the WAMPSERVER on the System Tray, and re-started all services.
This worked perfect for me, hope this will help you as well.
Rob
Got any other Programs running ? msn ect... ? some bind to port 8080 then your webserver wouldnt start and would cause a 404 , try binding it to a different port 80 which its default should be
I got a 404 could not connect error then I set wampmanager.exe to run as Xp Sp3 and it seems to be working fine this can be done by
Right Clicking on it
Properties
click tab labled "Compatibility"
Tick Box just undeder "Compatibility
mode"
Select Windows XP (Service Pack 3)
Click Apply then OK
It was Skype interfering for me too. I changed the Skype settings (in Skype go to Tools > options > advanced > Connection and UNCHECK "use port 80 and 443 as alternatives for incoming connections") save then close Skype. I have Win 7 HomePremium 64 bit, had installed Xampp fine with MySQL running fine, but no matter how many times I started Apache (and console showed "Apache started") I still got the "firefox can't establish a connection" error in the browser. After Skype changes were saved, Apache showed the green "Running" and all working now thanks
For me this did the trick at port 80 in the end:
You have to disable the http.sys service manually via the registry:
Launch RegEdit:
Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
Add a new DWORD (32-bit) value
Name it ‘NoRun’ not including the quotes
Double click the new property
In the Value data field type ’1' not including quotes and click OK
Re-boot your computer
You should now find that Apache will start on port 80!
Have you try the iis? Go to Control Panel->Programs and Features->Turn Windows features on or off (side bar). Try installing or reinstalling the Internet Information Service. I've a windows 7 with iis, with .net and php, and it works great...
you have to install the service, go to wamp->Apache->Service->Install service, then a command prompt window will pop up, then press enter, and after a few seconds go to the same route Services-> and click Start/Resume service, and you ready
I had the exact same issue, and the solution is what someone has already said:
In the taskbar, click on the WAMP icon.
Go to Apache-->Service-->Install Service
Then go back by clicking and selecting Apache-->Service-->Start/Resume Service
This will allow the localhost function to work (keep in mind I had already changed the host file located under c:\windows\system32\drivers\etc to remove the # from the 127.0.0.1 line)
If you need to edit that file still, you need to right click on it and select Properties. Then go to the Security tab, and click the Advanced button. You then need to select the Users, click Edit and select "Full Control". This will enable you to edit it.
That being said, you need to ALSO install the MySQL service following the same procedure.
MySQL-->Service-->Install Service
Then go back by right clicking yet again and selecting MySQL-->Service-->Start/Resume Service.
And that should fix it all up in Windows 7!
Before installing Wamp, go to controlpanel=> Adminstrative tools => IIS Manager and turn off the IIS server. Install wamp and everything works fine. When IIS is on it also uses port 80. You can go through a lot of changing the ports and permissions for wamp but I have found this the quickest and easiest method of getting wamp to run successfully.
Try adding the following tags in the wwwroot folder web.config file. These tags should be added as a child of the configuration tags as below.
-configuration-
--system.webServer--
---validation validateIntegratedModeConfiguration="false" ---
--/system.webServer--
-/configuration-
Maybe Skype or other Application is using port 80.
This you can check in
Tools->Settings->Advanced->Connection
See the above solutions are very good.But whenever you get this 404 eroor,first see this.I am sure the problem will be solved...
Just go to httpd.conf file by clicking wamp server symbol in bottom right taskbar-Apache->httpd.conf... or c:\\wampt\\bin\\apache\\apache2.2.1\\conf\\httpd.conf and approximate on line no 46 you will find "Listen 80"...just make sure it is written "80" after Listen...if it not then change it to 80...And your problem will be solved...
Assuming there is no problem doing a lookup on localhost (to 127.0.0.1), you need to make sure your server is listening to 127.0.0.1.
netstat works in both windows an UNIX. You probably need "netstat -a" to display listeners.