On Windows, to run the PHP web server from the command prompt I type:
php -s localhost:80800 -t public
And I get this error:
Could not open input file : localhost:8080
And yet cmd php test.php will echo the text. Why?
It was just the capital S.
php -S localhost:8888 -t public
Now I can see the page in a browser.
I had to cd to the right directory ...and public has an index.php file.
It will work without using XAMPP/WAMP or any other external server, as PHP has its own server inbuilt. You have done a mistake in typing s in php -s localhost:80800.
This command will work - php -S localhost:80800.
"s" in the command will be capital, not small...
You can not run localhost using native PHP. You need a web server like CAMP or WAMP and configure the port while installing this software.
It sounds like you are running PHP as a CLI (command-line interface).
As stated, there are WAMP stacks to install and configure. I would suggest looking online for one of the many tutorials. To install one, they will take you through the process as well as some of the advanced configuration to secure the installation from unwanted outside access.
PHP itself is not a web server, hence why you cannot just write php -s localhost:8080 -t public.
You will need to have a corresponding web server, e.g. Apache, and link this with your PHP, allowing PHP to process the files that Apache will serve on its server.
You may want to use XAMPP to do this, since it is an easy-to-use bundle for Apache, MySQL (a database system), and PHP.
Download it on its website.
try php -S localhost:8080 It's Will work but capital S not The Small one i mean
Related
On a shared server with ffmpeg installed above the webspace. Example: /home/username/ffmpeg/ffmpeg which is the full address all the way down to the executable.
The problem is that php cannot find ffmpeg using the -verson option. We tried using mod rewrite to a php file in the public_html webspace which then includes the ffmpeg address above the webspace. But that did not work.
I have never dealt with ffmpeg installed this way, its always been installed in /usr/bin/ or /usr/local/bin .
is there a htaccess or php ini command to tell php where ffmpeg is installed?
how does php suppose to access ffmpeg installed in this way, it is installed as an alias?
Thanks so much :)
As php and ffmpeg are separate things, there's no guarantee that your host will allow php to run ffmpeg, however here are some things you can try:
You can check if web server's user (which php runs as) can "see" any ffmpeg executables in its path by running:
<?php echo shell_exec("which ffmpeg"); ?>
If the output is empty, ffmpeg isn't in the path of the web server's user. In this case you still might be able to run it, if you know the path of the executable.
Also if you run:
<?php phpinfo(); ?>
That will tell you if php is running in safe mode. If it is, your web host may have locked down php's ability to do potentially dangerous things such as executing shell commands.
Change Permission of binaries files (ffmpeg.exe and ffprobe.exe) to 0744.
See image sample here:
I have a php file with an exec() function that executes some unix commands when I do this: php file.php on terminal, but now I need to do the same from URL on the browser, that is: localhost/file.php
So, how can I achieve this?
It sounds like you need a web server. It's a huge topic so it can't be covered here.
However. If you just want to run a simple PHP server, try
$ php -S localhost:8000
From the root directory of your PHP application. It should be accessible in your browser by going to localhost:8000. Or to make it accessible on any interface:
$ php -S 0.0.0.0:8000
Note that this only work for newer versions of PHP (>=5.4).
Thanks for your answers. The problem was that the files which I used in the commands inside exec() were outside of the /var/www/html directory and apache was complaining about permissions and after I had to give them permissions with the chown command.
I'm trying to launch unoconv using exec in php. It works with apache2, but not with nginx.
I've already checked my php.ini and disable_functions not contain exec in both apache2 and nginx php.ini files.
I'm not familiar with unconv, but I've had a similar problem with porting my server from Apache to nginx and exec.
nginx + php-fpm have a bare minimal $PATH set compared to apache, and it's likely your unoconv is not on that path.
You could try modifying your PATH settings, but a better way would be to specify the absolute path of unoconv
You can find the absolute path by using
which unoconv
You should also re-direct the error output to stdout, so you can see exactly why unoconv isn't starting
exec("/path/to/unoconv -param0 -param1 2>&1", $output);
print_r($output); //this should give failure reason
Check out this post : PHP exec() does not run all commands
As said in this post :
The problem is that you're running notify-send from a service. Notify-send is a desktop-oriented program which interacts with the display. But nginx runs without being attached to a display.
Imagine, for example, that there are 3 people logged on to the computer at the same time, all with different displays. When notify-send runs, it wouldn't know which display to send the notification to.
Where can I write the following command
i am following the developer tutorial for simple hello world script here
google_appengine/dev_appserver.py --php_executable_path=pathto-php-cgi path-to-your-app
When I run application in google app launcher I get a error message . I have WAMP install and it is running fine.
The path specified with the --php_exectuable_path flag () does not exist.
Php path - c:\php\php-cgi.exe
I also met this problem, and it has been solved.
for example,
if your PHP folder is E:/sam/php/
if your PHP site folder is F:/mysite/facebook/
if your dev_appserver.py is under E:/whatever/
I'm not sure how to change googleapplauncher.exe configurations, instead, you have to use cmd instead. I think this exe has config files but I did not find it. Open the command window and go to folder E:/whatever/ to run "python" command under this folder.
Type in:
python dev_appserver.py --php_executable_path=E:/sam/php/php-cgi.exe F:/mysite/facebook/
NOTE: REMEMBER to type "php-cgi.exe"
use slash
I dont know which is the name of the file in Windows, but i just have that problem, the full path from / for your php-cgi54.exe including the fullname of the file and then the full path from / of your folder.
I also run it like admin so check if your cmd or terminal was open with admin rights.
#Chander if you have wamp running you need to select a different listening port for app engine by typing the command: --port=9999 for example.
Here's what worked for me:
Open your cmd, make sure you're in the same directory as your sdk.
Type: "google_appengine/dev_appserver.py" --port=9999 --php_executable_path="fullpath\php-cgi.exe" "helloworld/"
If you have another local server like xampp or wamp,make sure you use the --port command to select another listening port as shown above.
Press enter and you should have your helloworld script working.
Could anyone please tell me how to run a php file locally on my system.
Currently I am using a server to run files.
I know both php & Apache to be installed.
I need to see out put of this program, for example:
<?php
$a=5;
$b=10;
$c=$a+$b;
print $c;
?>
Can you please tell how I can run these files of if I need anything more.
php have a easy way to run a light server:
first cd into php file directory, then
php -S 127.0.0.1:8000
then you can run php
You have to run a web server (e.g. Apache) and browse to your localhost, mostly likely on port 80.
What you really ought to do is install an all-in-one package like XAMPP, it bundles Apache, MySQL PHP, and Perl (if you were so inclined) as well as a few other tools that work with Apache and MySQL - plus it's cross platform (that's what the 'X' in 'XAMPP' stands for).
Once you install XAMPP (and there is an installer, so it shouldn't be hard) open up the control panel for XAMPP and then click the "Start" button next to Apache - note that on applications that require a database, you'll also need to start MySQL (and you'll be able to interface with it through phpMyAdmin). Once you've started Apache, you can browse to http://localhost.
Again, regardless of whether or not you choose XAMPP (which I would recommend), you should just have to start Apache.
In short:
Install WAMP
Put this file to C:\wamp\www\ProjectName\filename.php
Go to browser: http://localhost/ProjectName/filename.php
I just put the content in the question in a file called test.php and ran php test.php.
(In the folder where the test.php is.)
$ php foo.php
15
If you have apache running, put your file in server folder for html files and then call it from web-browser (Like http://localhost/myfile.php ).
Running PHP script directly in browser:
Here are all steps (in short) to run PHP program in XAMPP
Step 1: First of all, open the Apache Friends website, The download and install XAMPP for Windows.
Step 2: Open the XAMPP Program Control Panel and start “Apache Web Server”.
(NB: If your PHP scripts need MySQL database to work, Start “MySQL” service as well)
Step 3: Create a new folder inside “htdocs” folder. For example: “php-project”
Path looks like: C:/xampp/htdocs/php-project/
Step 4: Open any text editor and create a new file and write a simple PHP program then Save it with .php extension as “example.php”.
Path looks like: C:/xampp/htdocs/php-project/example.php
<?php
echo “Hello Level 5 Developers”;
?>
Step 5: Go to the browser and type “localhost/php-project/example.php” in the address bar and press enter then it gets executed.
Step 6: After that, you can see the output of your first PHP program like this:
Hello Level 5 Developers
3 easy steps to run your PHP program is:
The easiest way is to install MAMP!
Do a 2-minute setup of MAMP.
Open the localhost server in your browser at the created port to see your program up and runing!