I am currently working on a REST API in PHP. Therefore I set up XAMPP on my Windows 10 PC and so far it is working as intended.
To access a REST-Endpoint I would have to open https://<PC IP>/Api/ExampleEndpoint. Now ExampleEndpoint is saved in the Variable $_GET["_url"] and i can see the Content of that Endpoint in my Browser.
Now i tried the same on an Apache2 Webserver on my Raspberry PI, but when accessing the same Endpoint in the Browser (https://<RASP-IP>/Api/ExampleEndpoint) i get an 404 Not Found - The requested URL /Api/server was not found on this server. If i explicitly provide the Parameter as a GET Variable in the URL (https://<RASP-IP>/Api?_url=ExampleEndpoint) it works as intended.
Is there a possibility to use the same URL Syntax as it worked for XAMPP on Windows?
PC: Win10, XAMPP, PHP7.3.3
Raspberry PI: Debian Stretch, Apache2 Webserver, PHP 7.0.33-0+deb9u3
Related
I have a local Apache server using XAMPP which runs on port 80 and uses a local PHP file.
In the browser I can open this file from localhost/test/test.php and localhost:80/test/test.php.
I also have a react-native app, and it starts an NPM server on port 8081.
In this app I want to make a request to the local PHP file, but when I make the request it returns a 404 error.
I understand that it happens because the NPM server doesn't know about the local Apache server so I want to understand how to combine them.
Thanks.
don't write 'localhost/test/test.php'
You have to write with your ip, like this => '192.16x.x.x/test.php/'
I wrote a following short script in PHP:
<?
$s = socket_create(AF_UNIX,SOCK_STREAM,0);
socket_connect($s,"/tmp/tmpsock");
socket_write($s,"test");
socket_close($s);
>
I user this code to connect to a simple server that prints everything it receives onto terminal output.
The script works fine when I opened it from terminal using php index.php, however I want it to be a part of a webapp, and I try to run it on apache2 server opening the index.php page in web browser (on server of course). The script doesn't work then - the socket_connect function returns nothing, the error description is "Success()" and the message doesn't appear on server.
I use Ubuntu 16.04, Apache 2.4 and PHP 7.0
I installed LAMP from unixmen.com, but I am not able to run the php script using localhost. It says:
Not Found The requested URL /html/testphp.php was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80
Note! My apache server works fine.
Have you started your lampp server?
terminal command is
sudo/opt/lampp/lampp start
provided that is where lampp is installed.
Also the url should be http://localhost/name_of_your_project/testphp.php
first question: this file is first .php what executed in new serve?
case yes: make sure your server is started:
sudo/opt/lampp/lampp start
verify permission in your file.
or
try access using IP 127.0.0.1
http://127.0.0.1
your directory html are sub \var\www\html ?
try move to one level up
Regards
we just migrated our production server to a new host (dedicated servers). And now we are unable resolve domain names from PHP pages when loaded from Apache. However, it works fine when we execute the php page from the command line.
For example, the following PHP code returns the IP address when executed from command line but fails when page is loaded in browser thru Apache.
$ip = gethostbyname('www.google.com');
echo $ip;
Any thoughts? We are running Apache 2.4 on Windows Server 2012.
Thanks for your help.
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.