Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-02-2004, 05:44 PM   #1
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Rep: Reputation: 30
php from command line

I compiled php with apxs for apache support. I cannot however get it to run from the command line. I had hoped I could use it for some basic shell scripting as well. If I create a simple:

#! /usr/bin/php -q

<?php echo "test"; ?>

and execute it I get no output. Keep in mind that this is my first experience with a scripting language from the command line. Am I doing something wrong?

Old 05-02-2004, 05:49 PM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
I don't think php can run outside a web server? You've to upload the homepage with the php code to your Apache directory, then run it from a browser for that to work. Or have I been dreaming again...
Old 05-02-2004, 06:27 PM   #3
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
odious1, it works fine for me on Slackware 9.1, php version 4.3.6 (not my own pack, just an official Slackware one, ie. I didn't build it myself as I normally do). When you compiled it, did you use --enable-cli?
Old 05-02-2004, 07:11 PM   #4
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Original Poster
Rep: Reputation: 30
No I did not, if I recompile with that option I wonder if module function will remain intact. I do see that as one of the options of configure --help I will give it a try; thanks.
Old 05-03-2004, 12:31 AM   #5
Registered: Oct 2003
Location: Ireland
Distribution: Slackware 9.1, Ubuntu
Posts: 192

Rep: Reputation: 30
you can run a php script from the command line by using
#php file.php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[php] accessing command line dtra Linux - Software 1 04-26-2005 07:19 PM
Command Line PHP in Slack 10 Trano Slackware 4 02-12-2005 05:16 PM
php command line scripts naflan Programming 5 11-09-2004 08:02 AM
Command Line PHP on Mandrake Dilireus Linux - Software 2 08-04-2004 05:46 PM
PHP execute at command line gjmwalsh Mandriva 2 12-06-2003 01:03 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration