MOD_PHP vs PHP CLI, I always used mod_php, but someone told me they use PHP CLI instead of MOD_PHP, I want to know why someone would do that, and what disadvantages/advantages between those two.

MOD_PHP vs PHP CLI,  I always used mod_php, but someone told me they use PHP CLI instead of MOD_PHP, I want to know why someone would do that, and what disadvantages/advantages between those two.
OctalysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sjohnstone1234Commented:
They are for different things, mod_php is for serving PHP web pages whereas PHP CLI is for writing command line scripts (e.g. database maintenance and other routine tasks you don't want to do through the web, or would like to run periodically).

mod_php is quick as it embeds a PHP interpreter into the Apache web server so it doesn't have to start a copy of PHP every time somebody visits a page. Its main disadvantage is its lack of security - if you're sharing a server with other people then all sites are run with the same user privileges.

The other common way of serving PHP web pages is using the CGI version of PHP (as opposed to CLI), which is slower (starts a copy of PHP every time somebody visits a page) but works with web servers other than Apache, and lets you use things like SuPHP, which improves security on a shared server by forcing each site to run with the privileges of the user who uploaded it.

PHP CLI isn't really comparable to mod_php as it's used for different things - typically you'd be logged into a server using SSH or configure the server to run your script periodically using 'cron' or similar.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.