Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:23:27+00:00 2026-06-02T10:23:27+00:00

How can I run a PHP script from the command line using the PHP

  • 0

How can I run a PHP script from the command line using the PHP interpreter which is used to parse web scripts?

I have a phpinfo.php file which is accessed from the web shows that German is installed. However, if I run the phpinfo.php from the command line using – php phpinfo.php and grep for German, I don’t find it. So both PHP files are different. I need to run a script which the php on which German is installed.

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:23:29+00:00Added an answer on June 2, 2026 at 10:23 am

    You should check your server configuration files. Look for lines that start with LoadModule php…
    There probably are configuration files/directories named mods or something like that. Start from there.

    You could also check output from php -r 'phpinfo();' | grep php and compare lines to phpinfo(); from web server.

    To run php interactively:

    (So you can paste/write code in the console.)

    php -a
    

    To make it parse a file and output to the console:

    php -f file.php
    

    Parse a file and output to another file:

    php -f file.php > results.html
    

    Do you need something else?

    To run only a small part, one line or like, you can use:

    php -r '$x = "Hello World"; echo "$x\n";'
    

    If you are running Linux then do man php at the console.

    If you need/want to run PHP through fpm (FastCGI Process Manager), use cli fcgi:

    SCRIPT_NAME="file.php" SCRIP_FILENAME="file.php" REQUEST_METHOD="GET" cgi-fcgi -bind -connect "/var/run/php-fpm/php-fpm.sock"
    

    Where /var/run/php-fpm/php-fpm.sock is your php-fpm socket file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can run my script just fine from the command line: php test.php and
I have a PHP script launched from a command-line (aka CLI mode, no webserver
I've got a PHP script which I'm running from a command line (windows) that
Right now I can run a PHP script from my Mac terminal like echoing
Can I run a PHP CGI script as a background process using exec() ?
I have a PHP script that I need to run as root from the
I can run an svn command from the command line but not from within
i am using PHP to run exec() on a script which looks like this:
Can you run some script before the uploading of a file starts in php?
I just setup PortablePython on my system, so I can run python scripts from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.