PHP is not working on Windows after I completely installed it - php

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.

Related

Why are my .php files failing to be interpreted as php?

I have recently installed ubuntu 20.04 w/ apache2 on an Oracle VM running linux. I have followed the following guides line by line to set these up as well as php 8.1:
https://www.youtube.com/watch?v=YtH9D2SqBqA
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-22-04
I have an example file I am trying to test: my_ip/test.php where my_ip is the ip address of my virtual machine.
The code in test.php is:
<?php
$x =2;
$y =2;
echo ($x + $y);
echo "<h1>This is a test.</h1>";
?>
This is being displayed onscreen # my_ip/test.php:
This is a test."; ?>
My current interpretation is that this page is being parsed as an html file. I have done an hours worth of googling and tampering with config files but nothing worked, I ended up reverting all changes to config files so as not to prevent potential fixes provided here from working.
If it's relevant, I am accessing my linux vm server through putty.
On a side note, I have tried aliasing my server so that I can refer to it with a different address and not have to explicitly write my ip address but have failed. Can anyone point me in the direction of a guide that could help with this? I have tried following this guide line by line: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-22-04
however I am not able to successfully use http://your_domain. I simply get Server Not Found.
I tried following the aforementioned guides line by line, and was expecting my server's behavior to mimic that displayed in the guide's however my php files are not being executed properly. Also, I cannot refer to my server by its alias.
Resolution: Followed Ubuntu's PHP installation instructions for apache here https://assets.ubuntu.com/v1/2a3819f0-ubuntu-server-guide-2023-02-19.pdf
I believe I did NOT install the apache php module, despite installing php 8.1.
Running this command:
sudo apt install php libapache2-mod-php
resolved the issue and I am able to run php files now.

die() is not stopping code from executing

the problem is in the following:
echo 'Hello...';
die('I died...');
echo 'HAHAHA!!!';
on the web browser it is executing the echo after the die().
on the CLI stops on the die() and does not shows the echo as expected.
My Specs:
PHP 7.4 (FPM)
web server Nginx (also tried with apache with the same result)
Also I had a time long a test server on windows and it was exiting the script when exit or die was called, but somehow on the debian test server is not doing that.
is there something I am missing?
do you guys have any tip?
Thanks in advance....
Update on 2022-07-27 :
script:
Browser output:
CLI output
I've updated the PHP version (same happening):
#MarkusZeller yes is disabled the opcache:
still not working...
but somehow on the windows server under php7.4.26 runs the script with the expected die
The development environment is windows with Debian 11 (WSL2) I have also tried it yesterday on a test machine I have in my home with base Debian 11 installed and it has the same issue. Same thing with the Debian 11 test server at work.
#YourCommonSense the script is the same. Here is the nginx path config:
Solution:
The cause of the problem was on the extension php-uopz. After installing every extension individually and testing after every install, the behavior only happens after this extension is activated. Hope this helps in case anyone runs into the same issue.

XAMPP not interpreting PHP code + Errors

First things first, when I open and run XAMPP this shows up
The issue is, when I try and open a .php file it doesn't work it simply just shows the code WITHIN the php file, the php itself does not work.
I have downloaded and uninstalled XAMPP 3 times today.
Any ideas?
This is a rookie mistake, Make sure the URL says localhost/index.php and not file:///C:/...
To fix the problem you need to change xampp port from 80. Normaly 81 works just fine.
Follow these steps to change the XAMPP server port number:
1) Stop the XAMPP server, if it is running already.
2) Open the file [XAMPP Installation Folder]/apache/conf/httpd.conf.
3) Search for: "Listen 80"
4) Change to (Example): "Listen 81"
5) Search : ServerName (Update this too)
6) Save
7) Restart XAMPP server and you are done.
Note:
Now your url is: www.localhost:81
You should just try reinstalling the operating system as well as xampp over again. My answer takes into consideration that you have already tried installing xampp three times. If you have a Mac just restart holding the command and r keys and then wait for the recovery center to come up. Then select reinstall osx. This requires internet. If you have windows there might be an install disk that came with the system and try reinstalling from the disk.
Problem is that port 80 is being used by some other application. If you have installed skype it would skype. We can manually change the port used by skype for that check the answer for this SO question How to solve WAMP and Skype conflict on Windows 7?
You can also make sure which appication is using port 80 by checking this SO question How to find which program is using port 80 in Windows?

No ssl on php commandline

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.

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.

Categories