Mod_php and CGI newbie questions

Hey All,

I’m using PHP for a web app I’m building and I’m mostly new to PHP. My friend the other day told me to check out Python for my server-side scripts, and while researching I ran into this part of the documentation: https://docs.python.org/2/howto/webservers.html

Just seeing if I understand this correctly: mod_php is the name of an interpreter (a program) to convert php into the language the server was written in so it can understand it (C++ or whatever my host would be using). This interpreter is loaded and installed onto the web server once, as opposed to CGI which calls and runs an interpreter every time a request is made.

I cant find information about this for any commercial web host, so is it safe to assume most hosting services have mod_php installed on the server? If I was going to use python, would I need to install mod_python myself?

Lastly, Im a little confused between how PHP is setup vs other languages like Python or Ruby. When you write PHP, you just write it the same way you write HTML and you write them together. The server reads PHP first before anthying is loaded, and the resulting, finished code is rendered by the browser. Python cant be written with HTML, so if you want to run a python script on a DB and use the table info on your HTML page, you just use AJAX or would you link to the .py file in script tags like a js file?

Any info would be awesome! Thanks

1 Like

Hi there @FcknDrrn. Hopefully someone will be able to answer your questions more thoroughly, but this might help explain what mod_php is. Basically it is a PHP interpreter, but to say it converts PHP into another language isn’t really correct, it simply interprets your (or my) PHP commands and does what it is told to do.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.