Unable to open .php file on browser using http://localhost/dirname - ubuntu-16.04

On Ubuntu 16.04 when I try to open .php file on browser using http://localhost/vish+all it show blank page and a word 'yes' written on it . And due to this I am unable to acess php file on browser.
And I have php7.0 installed on it. What does word 'yes' means.
And how can I find solution for this?

You must need to verify if the php is a index.php and if is inside the command echo 'yes';
because echo <--- prints any character.
Example:
<?php
echo 'yes';
?>
also check your php.ini and check if your short_open_tag=On is ON because if is not your code will not work instead of
Also try to remove "+" from your directory or try to upload a new php called info.php and copy inside there the following code
<?php
phpinfo();
?>

Related

PHP script works from browser but not from Windows Server Task Scheduler or from CMD/PS

I have this simple script called webcam.php to acquire some screenshot from webcams
<?php
$d=date('YmdHis');
$url = 'http://xxx:40801/snap.jpeg?'.$d;
$img = 'camera_east.jpg';
echo file_put_contents($img, file_get_contents($url));
$url = 'http://xxx:40802/snap.jpeg?'.$d;
$img = 'camera_west.jpg';
echo file_put_contents($img, file_get_contents($url));
echo $d;
?>
and if I call http://xxx/webcam.php from browser, everything's OK:
I find the two pictures in the folder, and the script returns the length of the files and the timestamp as echoes.
I tried to make this script to be executed by the windows scheduler, but although it returns 0x0 the pictures are not updated.
(I tried also unlinking the images, and also using curl but nothing changes)
Then I tried to run the PHP script from command line (also from PowerShell):
something like:
C:\Program Files\PHP\v7.2\php.exe -f C:\\webcam.php
but again, although it seems working, since it returns the length of the two files and the timestamp, the pictures are not updated and if I add unlink command, files are not cancelled:
Clearly folder has all permissions...
I've not big experience in PHP... :-(
what can be wrong?
Thanks!
obviously from cmd/ps/scheduler requires the full path,
while from browser can accept relative path

phpinfo() is working and echo is not - Why would this be?

Obviously I was looking to do something else but as it wasnt working, I have stepped back to a very fundamental test:
<?php
phpinfo();
?>
<?php
echo "Test";
?>
Can anybody give me any ideas as to why the first script works, and the second doesnt. Nothing else in the file, just one or the other! A .php extension.
Not sure why I am having to iterate over this - thanks alot phaberest!
The resolution in the suggested duplication talked about having a php file extension - well this has a php file extension. On the other points that #rene pot, put forward - phpinfo() is outputting, so yes there is php installed on the server. I am not using localhost but servername.co.uk/phpinfo.php

Can't gzip my mysqldump on the command line windows

I'm trying to make a back up of my MySQL db and zip the file.
Every time I try to run this command...
C:\wamp\bin\mysql\mysql5.5.24\bin\mysqldump.exe -u usernam -ppassword db_name | gzip > sites\www.site.com-local\backups\backup-date.sql.gz
All I get is an error saying "'gzip' is not recognized as an internal or external command, operable program or batch file'
I've used the following resources hoping they would help but have done nothing
http://www.zigpress.com/2009/04/09/enabling-gzip-on-wamp/
http://dnhome.wordpress.com/2011/10/06/apache-wampserver-enable-compression-gzip/
http://www.dewebbouwmeester.nl/enabling-gzip-on-wamp/
All say the same thing but nothing happens.
Could someone please shine some light on what i am doing wrong?
I had this same problem myself with WAMP.
All you need to do is:
Download gzip.exe from here: http://www.gzip.org/#exe
Place gzip.exe in your PHP folder
That is telling you that gzip is nowhere your system can find. You can blame however you installed gzip.
Check the value of your $PATH environment (or system) variable. Then install a copy of gzip in one of those directories.
Yes, you have to put zip.exe in your wamp folder, like wamp/bin/mysql/[your mysql version]/bin.
Find or install gzip locally. After that directly in PHP folder create just gzip.bat file, specify the fully qualified path to existing gzip binary file and save.
For example:C:\git\bin\gzip.exe
It's not necessary to place gzip.exe in your PHP folder.

HTML form action ends up downloading perl file instead of executing it

I have been trying to run a simple perl-cgi script on windows 7. This is a simple HTML form with an OK button where clicking on OK button displays some text. But clicking the OK button on the HTML page, instead of executing and displaying perl file's output, the browser starts downloading the script. I have added handler in httpd.conf
AddHandler cgi-script .pl
But this doesn't help. I added the ExecCGI option in the httpd.conf but that didn't help either.
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
Here is the perl script being used:
#!C:\Perl\bin\perl
use CGI;
print "Content-type: text/plain","\n\n";
print "<html>","\n";
print "<head>\n\t<title>Server Information Ready</title>\n</head>","\n";
print "<body>","\n";
print "<h1>Server Information</h1>","\n";
print "</body></html>","\n";
And here is the html file:
<html>
<head><title>Server Information</title></head>
<body bgcolor="#EEAA55">
<h3>Please click OK to get the server information</h3>
<hr><pre>
<form action="http://localhost/cgi-bin/ctest/pranav1a.pl" method="post">
<input type="submit" value="OK">
</form>
</hr></pre>
</body>
</html>
I have tried this on chrome, IE and Mozilla. Mozilla and chrome start the perl file download, but IE just displays some weird content on clicking the OK button. How can I make the browser display output of file execution rather than starting the script download ?
PS: I have tried to use shebang line as '#!c:/Perl/bin/perl' which doesn't seem to work either. I am able to see the perl script's output when executed from cmd prompt.
Found the solution: in my case I was using 'localhost' in form action instead of 'localhost:8080'.
<form action="http://localhost:8080/cgi-bin/pranav1a.pl" method="post">
How about the +ExecCGI option? Try the + in front of it.
In addition, these is usually a problem with understanding suexec2 (not sure whether suexec2 applies to a Windows platform):
Read the whole page over there. Such problems are not fixable when you do not understand the gross limitations enforced by suexec. Common errors are:
wrong permissions on suexec2 executable.
CGI script is located in wrong location.
Have you worked through apache.org/docs/2.2/howto/cgi.html#troubleshoot yet?
Thanks Scavokovich.
In my case the following line was commented out in the httpd.conf file.
#LoadModule cgi_module /opt/freeware/lib64/httpd/modules/mod_cgi.so
Uncommenting it, and restarting apache allowed the CGI script to run instead of open as a text file.

How to write php so that the correct file can be downloaded over linux command line?

So basically i have a problem where the user will send a request to test.php?getnextfile=1, and i need to process the request and figure out what is the next file in line to be downloaded, and deliver it to the user. The part that i'm stuck on is how to get the correct filename to the user (the server knows the correct file name, user doesn't).
Currently i've tried to use wget on the test.php?getnextfile=1, and it doesn't actually save with the correct filename. Also tried to header redirect to the correct file, and that doesn't work either.
Any ideas?
Thanks a lot!
Jason
Since Jul 2010, this is impossible in default wget configuration. In process of fixing security bug, they switched "trust-server-names" option off by default. For more information, see this answer:
https://serverfault.com/questions/183959/how-to-tell-wget-to-use-the-name-of-the-target-file-behind-the-http-redirect
In your php script you need to set the 'Content-Disposition' header:
<?php
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="myfile.zip"');
readfile('myfile.zip');
?>
Use curl instead of wget to test it.
curl --remote-name --remote-header-name http://127.0.0.1:8080/download