Running PHP Script

I've enabled the Apache server on my mac, and when I access my local IP address I can see the web page I've created. However, it appears that the server doesn't process PHP scripts, and just returns the source code of the PHP script when I try to open the script in Safari 4. How do I get the built-in Apache server to process PHP scripts and return the desired result?

PHP is disabled by default. To enable it, you must edit Apache's configuration file. To do this, open up /private/etc/apache2/httpd.conf with a text editor. The file is owned by root, so you'll need appropriate access to modify the file. Text editors like BBEdit or TextWrangler can make this step much easier.
Fairly early on in the configuration file is the section for the Dynamic Shared Object support - these are the modules that Apache loads to enable it to perform various tasks. In this section are a whole bunch of "LoadModule" statements - one for each module that Apache is loading. One of these is for PHP support. In the httpd.conf file on my machine, the built-in PHP module's statement is on line 114, the next to last item in this section. It reads: "#LoadModule php5_module libexec/apache2/libphp5.so" Remove the "#" from the beginning of the line, save the file, and restart Apache.
If you plan on using PHP files as the default page for a directory (index.php, for example), you'll need to add index.php to the Directory Index section (line 225 in my file). Apache looks for them in the order listed, so if you list index.php after the index.html that's already there, Apache will look for index.html when asked for the directory before looking for index.php. If you're going to have index.php for most of your directories, you may want to list it first, before index.html.
With regard to PHP itself, Apple's included PHP isn't any more official that the one I mentioned from Marc Liyanage. They're both compiled from the same source code. And, as far as updating goes, I'd argue that it's easier to update Marc's version, as you simply download an updated version and the installer will overwrite the old version. And, you don't have to wait for Apple to release a new version of OS X or a security update to see if you get a more current version. His versions will almost always be more current than the one Apple provides.
In any event, Marc's version does not remove Apple's version from your system. His installs in /usr/local/ and leaves Apple's version intact. So, you can always go back to Apple's version by changing a few lines in a configuration file.

Similar Messages

  • RUNNING PHP SCRIPT WITH ZEND FRMWRK IN WINDOWS TASK SCHEDULER

    I have a PHP script which includes the Zend framework Mail.php for sending mails.
    I am running a WAMP server and i used DW to create it.
    I want to run my script in every 5 mins, How i can schedule it in Windows task scheduler.
    I tried running a bat which contains the php.exe path and arguments as php file but it gives an error that zend/mail.php not found.
    Please help its really urgent.

    Thanks for your response.
    bat file has:
    path of the php.exe -f path of php file.
    But when it runs it gives an error that the zend framework file not found.
    I have a seperate PHP includes folder under which zend FW is stored.
    That folder is marked in includes_paths in php.ini.

  • Need to run php script before the Flash component kicks in

    I have a slide show component in Flash which uses an xml file to load images. The xml file, however, is created dynamically when the user selects which slide show they want to see. How do I run the php script BEFORE the slide show component has a chance to look for it? Usually it begins as soon as the .swf is run.
    thanks,
    chop

    thank you for responding.
    I'm still new at as3 so forgive me for needing details.
    I searched adobe for help and came up with the following to import the component. However, it seemed too easy to be true and so it was. I received errors when I ran it. The component is a commercial one called SlideshowBox and is in my library with that exact name.
    //add a component to the stage
    import fl.controls.SlideshowBox;
    var aSlideshowBox:Button = new Button();
    addChild(aSlideshowBox);
    errors:
    Scene 1, Layer 'Actions', Frame 1, Line 3    1172: Definition fl.controls:SlideshowBox could not be found.
    Scene 1, Layer 'Actions', Frame 1, Line 3    1172: Definition fl.controls:SlideshowBox could not be found.
    Scene 1, Layer 'Actions', Frame 1, Line 4    1180: Call to a possibly undefined method Button.
    thank you, k

  • Run PHP script

    Hello, everybody. I'm wondering if it's possible to run a HTML PHP script in a report region which type is HTML format? Something like:
    <?php
    echo phpinfo();
    ?>
    As I can imagine, this code could not be handled to PHP compiler although as I know, the ORACLE appication server has been compiled together with PHP 5. So is there any tricks to make this work, or does APEX have some plan to make similar things work in the later version?
    Thanks!

    I have a PHP application that opens up a template (MS
    Word) invoice file, inserts some information in the
    file (eg. today's date, customer name) and then saves
    it as a new Word file. My questions are as follows.
    1- How can I call this script from my Java
    application. Please note that I want to be able to
    pass parameters (eg. custome name read from a DB) from
    my Java app. to this script.You would have to call the PHP interpreter through Runtime.exec(), I believe. I haven't done anything with it, but you would have to build the command that would normally be typed on the command line as a string and pass it to Runtime.exec().
    2- Is it possible to print already saved MS Word
    documents from Java? If so, how?Try looking at the Jakarta POI project.
    3- Is it possible to do what my PHP script is doing in
    pure Java? I couldn't find a simple way of doing this,
    that's why I used PHP but I would like to do this in
    Java if I can.Same as 2.

  • Launchd not running php script in background

    Hi there,
    I am trying to run a php script repeatedly after every 2 minutes using launchd. I am using mac 10.9.2.
    Here is my plist file-->
    com.mycompanyname.mydepartment.mytaskname.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.mycompanyname.mydepartment.mytaskname</string>
        <key>ProgramArguments</key>
        <array>
              <string>/Applications/XAMPP/xamppfiles/htdocs/oauth/job.php</string>
        </array>
        <key>StartInterval</key>
        <integer>50</integer>
    </dict>
    </plist>
    /Applications/XAMPP/xamppfiles/htdocs/oauth/job.php --->
    #!/usr/bin/php
    <?php 
    $File = "YourFile.txt"; 
    $Handle = fopen($File, 'a');
    $Data = "Jane Doe\n"; 
    fwrite($Handle, $Data); 
    $Data = "Bilbo Jones\n"; 
    fwrite($Handle, $Data); 
    print "Data Added"; 
    fclose($Handle); 
    ?>
    My command line for your reference-->
    studio-film1:oauth MetricFilm$ sudo chmod a+x job.php
    studio-film1:oauth MetricFilm$ sudo cp com.mycompanyname.mydepartment.mytaskname.plist /Library/LaunchDaemons
    studio-film1:oauth MetricFilm$ sudo launchctl load -w /Library/LaunchDaemons/com.mycompanyname.mydepartment.mytaskname.plist
    studio-film1:oauth MetricFilm$ sudo launchctl load -w /Library/LaunchDaemons/com.mycompanyname.mydepartment.mytaskname.plist
    com.mycompanyname.mydepartment.mytaskname: Already loaded
    When i drag and drop my job.php script on terminal, it shows its path and when i enter.... It is not giving me any error & it is running on command line too & creating "YourFile.txt" if it does not exists & if it exists then it writes two lines into it.
    Problem is---->
    "YourFile.txt"  is not getting generated neither if it is there is getting written by php script. Which means it is not running into memory even a once.
    What should i do to make launchd run this script repeatedly.
    Thanking you

    Thanks dear,
    Should i change relative path mentioned into PLIST file
    <string>/Applications/XAMPP/xamppfiles/htdocs/oauth/job.php</string>
    to Absolute...?
    And is there any other command to start a plist task running after we have loaded it with launchctl??
    Thank you

  • Run PHP script in Java app.

    Hi,
    I have a PHP application that opens up a template (MS Word) invoice file, inserts some information in the file (eg. today's date, customer name) and then saves it as a new Word file. My questions are as follows.
    1- How can I call this script from my Java application. Please note that I want to be able to pass parameters (eg. custome name read from a DB) from my Java app. to this script.
    2- Is it possible to print already saved MS Word documents from Java? If so, how?
    3- Is it possible to do what my PHP script is doing in pure Java? I couldn't find a simple way of doing this, that's why I used PHP but I would like to do this in Java if I can.
    thanks in advance,
    Mete

    I have a PHP application that opens up a template (MS
    Word) invoice file, inserts some information in the
    file (eg. today's date, customer name) and then saves
    it as a new Word file. My questions are as follows.
    1- How can I call this script from my Java
    application. Please note that I want to be able to
    pass parameters (eg. custome name read from a DB) from
    my Java app. to this script.You would have to call the PHP interpreter through Runtime.exec(), I believe. I haven't done anything with it, but you would have to build the command that would normally be typed on the command line as a string and pass it to Runtime.exec().
    2- Is it possible to print already saved MS Word
    documents from Java? If so, how?Try looking at the Jakarta POI project.
    3- Is it possible to do what my PHP script is doing in
    pure Java? I couldn't find a simple way of doing this,
    that's why I used PHP but I would like to do this in
    Java if I can.Same as 2.

  • Running php scripts on development server

    Hi,
    I have Coldfusion development server and Apache running on my local host. CF is on port 8500 and Apache is running on port 80.
    On my remote host in plesk I can add support for Coldfusion and PHP, is there a way to run PHP files on localhost:8500?
    Thanks

    Sweet. I run this setup on Mac 10.5.7 and it's great (PHP & CFML on port 80, that is).
    The easiest solution is to reinstall CF as a multi-server and run the connectors for Apache. The most recent CF (8.0.1) Mac installer is 'built' for Leopard, so it works well.
    Mark Drew has a good post:
    http://www.markdrew.co.uk/blog/post.cfm/running-coldfusion-8-on-leopard
    Aaron West also has an excellent post on CF 8 & Leopard:
    http://www.trajiklyhip.com/blog/index.cfm/2008/1/14/ColdFusion-8-Apache-22x-and-OS-X-105-L eopard
    If you run into a snag, PM me & I can help more (I've freaking installed this $%&@ thing so many times )!

  • Running PHP script from Java apps

    Hi,
    I have a PHP application that opens up a template (MS Word) invoice file, inserts some information in the file (eg. today's date, customer name) and then saves it as a new Word file. My questions are as follows.
    1- How can I call this script from my Java application. Please not that I want to be able to pass parameters (eg. custome name read from a DB) from my Java app. to this script.
    2- Is it possible to print already saved MS Word documents from Java? If so, how?
    3- Is it possible to do what my PHP script is doing in pure Java? I couldn't find a simple way of doing this, that's why I used PHP but I would like to do this in Java if I can.
    thanks in advance,
    Mete

    Don't reply here. Go here instead.
    http://forum.java.sun.com/thread.jsp?forum=54&thread=479160&tstart=0&trange=15
    Cross-listed
    Sorry, I thought this didn't post before.

  • Running PHP script via ColdFusion

    I'm running CFMX 7 on a Solaris platform with PHP 5.0.5.
    I need to determine the width and height of an uploaded image
    to ensure that the file can be reasonably used on a web page. I
    have scoured the Internet and found a numer of solutions to this.
    Most need the installation of additional software on our server and
    the creation of a custom tag. These are doable, but would require
    additional effort I don't have time for at the moment. Also, the
    software to install is a full image manipulation package that is
    definitely overkill for my needs. Kind of like threading a needle
    with a hammer.
    On the other hand I know that PHP has a command called
    "getimagesize" that would be perfect for my use. This would be much
    more simple and elegant. And I have created a small program (see
    below) that can accept a location of an image file and display the
    width and height of the image as a result. The code is:
    <?php
    list($width, $height) = getimagesize($argv[1]);
    echo "$width, $height";
    ?>
    I've tested it via the command line and it works fine.
    However, I'm having difficulty in running it via the ColdFusion
    cfexecute tag. Here is that code:
    <cfsavecontent variable="imgsize">
    <cfexecute name="#phpfilelocation#"
    arguments="#imagelocation#"></cfexecute>
    </cfsavecontent>
    I get nothing back from this. I've also tried the cfhttp tag
    with similar results. It seems to me that the argument (the
    location of the image) is not being accepted by the PHP code for
    some reason.
    I've looked for a solution to this within this forum and via
    Google, etc. to no avail. There is apparently something about PHP
    or ColdFusion that is escaping me. Any help clarifying why this is
    not working and (hopefully) a workaround would be very much
    appreciated. Thank you.

    Maybe this will help:
    http://groups.google.com/group/alt.comp.lang.coldfusion/msg/af84ac7dfec0d09e?dq=&hl=en&lr= &ie=UTF-8&oe=UTF-8&rnum=8

  • How do I execute a PHP script on a remote server?

    I have a PHP script that sends a confirmation email to guest users that fill out one of my forms. The script runs fine when I test it, but when it is called from a custom JSP, Vibe blocks it from running. I understand that what I want to do is to most likely to use a remote application, but I don't want to send data back and forth and all the examples use java servlets, I just simply want to run my script without Vibe blocking it. Is there a easier way to do this? or can someone point me in the right direction?

    Vibe is not configured to run PHP scripts so you cannot run your script from custom jsp.
    You have already PHP script running on the server and running it as remote application is realy easy. All you have to do is to get request paramater in PHP script, register remote application in Vibe and in some point call remote application (you can do it also from custom jsp).
    Regards
    Pawel

  • Uploading a file using a php script while running application with LCDS

    Hi! I developping an application under Flex 2 / Java -
    running on LCDS / JRun server.
    I'm trying to add uploading capabilities. I'm using a php
    script for the upload part.
    First, I just try to put script on the app directory. Doesn't
    work.
    After that I set up an apache server from where I put a small
    web site with my script. It's telling me that my file is
    succesfully uploaded, but I can't find the file. The apache log
    give me no error.
    Someone can help me?

    Originally, I had problems w/ the file being placed in
    C:/whatever.ext b/c I wasn't using relative paths.
    This is the code I use:
    $MAXIMUM_FILESIZE = 1024 * 1024 * 2; // 2MB
    $newFileLoc = "./wherever/file.jpg"
    if ($_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE) {
    move_uploaded_file($_FILES['Filedata']['tmp_name'],
    "./temporary/".$_FILES['Filedata']['name']);
    rename( "./temporary/".$_FILES['Filedata']['name'],
    $newFileLoc );
    chmod( $newFileLoc, 0777 );
    Modified from this article by Adobe:
    http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=17_Networking_and_communications_173_6.html

  • Determine when a php script has run, then continue in actionscript

    I  want to run a php script before continuing to processs any more a.s. because the php script creates an xml file on which the a.s. depends. In addition, I need to send a variable to the php script that tells it what kind of xml script it will create.
    (i suppose I could just add the rest of the a.s. into a later frame but that sounds like a method when all else fails)
    Here's how it works in detail:
    1. someone clicks on the "oil" button which means they want to view all the images in the "oil" gallery.
    2. A php script creates an xml that includes only the oil images (that''s the variable it must receive from Flash "oil").
    3. The php script finishes its job before a.s. script continues
    Here's how I started but I'm not even sure what type of "event" is used to listen for a finished php script or where to put the variable parameter:
    oil_btn.addEventListener(MouseEvent.CLICK,xmlGenesis);
    function xmlGenesis
    (evt:MouseEvent):void{
        var urlRequest:URLRequest= new URLRequest
        ('xmlGenesis.php');
        navigateToURL (urlRequest);
    thank you for your assistance
    chop

    Well, after a few hours of looking around the Internet and in reference books and at the example you indicated, I finally managed to nail the pieces together to get something that works... just before I decided to start drinking again. whew! It works!
    var myVariables:URLVariables = new URLVariables();
    myVariables.gallery = "nature";
    var myURLRequest:URLRequest = new URLRequest("xmlGenesis.php");
    myURLRequest.data = myVariables;
    var ulLoader:URLLoader= new URLLoader();
    ulLoader.addEventListener(Event.COMPLETE,xmlComplete);
    ulLoader.load(myURLRequest);
    function xmlComplete (ev:Event):void{ // finished creating xml file
    do everything else
    thank you
    That which doesn't kill us makes us stronger.
    Friedrich Nietzsche

  • Error on running a PHP script

    I just migrated my web server over to Leopard and I am having an annoying issue with some PHP scripts. When I call a certain subroutine library (specifically Graph->Stroke from the JpGraph PHP library, http://www.aditus.nu/jpgraph/), the PHP code crashes with the following errors recorded in the /var/log/apache2/error_log:
    The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
    Break on _THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___Y OU_MUST_EXEC_() to debug.
    Now, I did a bit of poking around and discovered that Leopard did make a change (for security?) where a process that is forked is no longer allowed to call CoreFoundation routines (see http://developer.apple.com/technotes/tn2005/tn2083.html#SECDAEMONVSFRAMEWORKS). I have a vague idea of CoreFoundation (I am not a MacOS programmer), and I am guessing that the specpfic JpGraph command I am executing is triggering CoreFoundation to do some file handling. I am not sure about this because my own PHP routines that create files work just fine, but this JpGraph package chokes.
    Does anyone have any idea if there are some PHP tweaks I could make (via editing the php.ini file) that might prevent "forking" or of any other techniques that might avoid this problem.

    Hi if you are unable to go to this page after doing some personalizations ,
    then you need to do the following :
    ACTION PLAN
    ===========
    1. Login to application
    2. Select Responsibility Functional Administrator
    3. Click Personalization Tab ( Upper Right)
    4. For Application , Enter the following: Self-Service Web Applications
    5. Click on the Personalized Checkbox
    6. Click Go
    7. Remove or De-activate your personalization that is causing the issue
    8 Re-test your login.
    Thanks ,
    Raj.

  • Run a php script

    Is there a way to run a script if the user closes the browser
    window, or hits backspace?
    I can do this with <body> tag supports an onUnload
    attribute, however I was hoping flash may be able to do it, as I am
    trying to pass the username to the script I want to run,therefore
    it be easier all rond if flash could do it. Thansk to any
    responders. J

    basically I am trying to log a user out, so I know what users
    are online, but if they don't logout themselves, my mysql databse
    will still have them as logged in... any solutions?

  • PDF files pushed by PHP scripts cannot be previewed in the browser (only "Save as" dialog is displayed). How can I fix this?

    Running Firefox 27.0 on Linux Mint Petra (16).
    Direct download links to PDF files (URLs that end in .pdf) preview or open (or whatever I set in the App preferences dialog) no problem. However, any PDF file that is pushed by a php script can only be downloaded (no matter what I set in the App preferences dialog).
    I have several PCs running the same software (Linux Mint Petra with FF 27). All of them exibit the same problem.
    I've tried all solutions to similar problems listed here. None of them worked.

    You need to install server software to process the php code and send the file as text/html to Firefox.
    <pre><nowiki><?php header('Content-Type: text/html; charset=utf-8'); ?>
    </nowiki></pre>

Maybe you are looking for

  • Report Builder is crashing... 6i, 9i and 10g

    Dear All, During my experience with all versions of report builder, all versions crash from time to time when building reports. Is there any way to get rid from this?? Regards, Joe

  • Pass PL/SQL collection as function parameter over DBLink

    Hi all, I am trying to do the following; ---Remote database --create SQL type create type attributeidarray as table of varchar2(255); --create a package specs CREATE OR REPLACE PACKAGE testp AS TYPE ref_res IS REF CURSOR; FUNCTION foo (i NUMBER) RETU

  • URGENT   KERNEL PANIC

    Hi everyone ..... do u guys now what do these codes mean ...i got it from panic.log of my 2Ghz Macbook which indicates the kernel panic i've had ...if someone knows about it please tell me what's wrong with my macbook Tue Jan 2 22:42:16 2007 panic(cp

  • HT1338 Hi, does anyone know how to clear a icon saying Microsoft Error Report?

    Hi, Does anyone know how to clear an icon saying Microsoft Error Reporting?

  • Slideshow From iPhoto

    I built a slideshow in iPhoto, which I then shared and ATV does see it and play it. The problem I am having is that ATV plays the first song in the custom playlist, but just repeats that song instead of playing the next song in the playlist. When wat