It comes installed because it is easy to install. Someone had to install it and PHP is sure easy for any SysAdmin to get installed. It is easy to start because the PHP folks made it easy to get started.
Look at the steps to get PHP installed versus other languages. Then look at what "Hello World" and a simple form take.
Not much different to getting CGI working. If you need it working well, FastCGI is as much effort as PHP-fpm. SUexec is as much effort as SUPHP.
Any language could supplant PHP in terms of ease of deployment, there's little out there that doesn't have some CGI library to handle the mucky parts.
Not that I am advocating use of CGI for anything non-trivial.
That's really just not true. Installing anything capable of CGI is as easy to install as PHP.
If you want your favorite language to replace PHP, then you have to make it easy for the sysadmin to install (preferably 1 line) and for new programmers to be able to use the language by just uploading a file.
Any other language that has dedicated .INI files to determine its behaviour, maybe. PHP caught on because of "Hello world" in a web browser, and smart people didn't realize the value of novelty.
sudo apt-get install apache2 php5 libapache2-mod-php5
Boom, I just installed PHP5 on Apache on Ubuntu, now I just upload a file to my project root.Let me know when you find any way easier than that.
php5
installs apache, by default.I am not a fan, so I am biased. But I've never quite seen the appeal of such a superficial attribute as "it's already on my cheap server." Are we not programmers? How hard is it, really, to install a JVM, Python, Ruby, Go, or any other platform? It's never taken me more than scarce minutes. To my mind, it seems widespread delirium prioritizing such a non-priority over peace of mind and performance. It's akin to selecting an operating system based on the fonts it ships with.
Most people who start out programming PHP aren't programmers. (I think that's a good thing FWIW.) The ease to non-programmers explains the wide spread which is what the discussion is about.
Nope, I install PHP and then upload a page with PHP embedded and it works. It is not that easy with python. That's why all these hosting accounts had LAMP and not something else.
I'm not discussing headaches, I do nit particularly like PHP. My point is just that Python is not very easy to get started with for beginners.
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if name:
return 'Hello, ' + name + '!'
else:
return "<form><input name='name'></form>"
if __name__ == "__main__":
app.run()
upload into your web server's cgi-bin folder, or have the server configured to exec all *.py files as pythonED> yeah, this is a few more lines of code than PHP and it requires a teeny tiny amount of knowledge about how the web works - and that "takes 5 minutes to get started" vs PHP's "takes 2 minutes to get started" is a big difference for someone who doesn't know what they're doing but wants results immediately :P
EDED> Actually now that I think about it, that's how /I'd/ start a simple webapp as it has the structure in place to grow easily and elegantly -- if you're willing to do things the quick and dirty way, you can go without a framework and just print an HTTP response to stdout - in which case the only difference with PHP is that the python version requires "print 'Content-type: text/html\n'" at the top
But this web framework is much newer than PHP, isn't it? And this does not look better or easier than PHP: https://wiki.python.org/moin/CgiScripts
That has tracebacks on error and HTML escaping, so I'd say it's considerably better for a tiny increase in difficulty (but you're right that no matter now tiny the difference, PHP is still easier)