Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python SimpleHTTPServer with PHP

Tags:

python

php

I used python -m SimpleHTTPServer, but the PHP files don't execute instead they just been downloaded.

I heard about WPHP in an old post. But I don't know how to use it. How I can work with it ?

like image 346
Abderrahmane Avatar asked Sep 02 '12 12:09

Abderrahmane


People also ask

What does python SimpleHTTPServer do?

The SimpleHTTPServer module is a Python module that enables a developer to lay the foundation for developing a web server. However, as sysadmins, we can use the module to serve files from a directory. The module loads and serves any files within the directory on port 8000 by default.

Can PHP run on Apache server?

PHP support can be added to a number of web servers (IIS, Xitami, and so on), but most commonly Apache HTTP Server is used. Click here for information on how to install and configure Apache 2.2. The PHP engine. The supported version is PHP5.

Is python a HTTP server?

You can run python http server on any port, default port is 8000. Try to use port number greater than 1024 to avoid conflicts. Then open your favourite browser and type localhost:9000 . Yeah!


1 Answers

The reason why the Python Webserver sends your PHP files to the brower is likely because it is not configured or able to handle PHP files. See https://serverfault.com/questions/338394/how-to-run-php-with-simplehttpserver

PHP 5.4 has a built-in webserver. You can call it from the command line like this:

php [options] -S <addr>:<port> [-t docroot] 

Example

C:\Users\Gordon>php -S 127.0.0.1:80 -t . PHP 5.4.0 Development Server started at Sun Sep 02 14:20:28 2012 Listening on 127.0.0.1:80 Document root is C:\Users\Gordon Press Ctrl-C to quit. 

Note that if you omit -t PHP will use the current working directory.

like image 111
Gordon Avatar answered Sep 27 '22 19:09

Gordon