Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Apache downloading PHP instead of running

  1. #1
    Join Date
    Nov 2011
    Beans
    89

    Apache downloading PHP instead of running

    I've seen this topic posted a number of places, but I though it might be worth posting my own thread since my situation seems different from ones others have posted (and none of the posted solutions have worked). I installed Apache, MySQL, and PHP on my Ubuntu 14.04 system to do some testing, and had everything working beautifully for a few days. Then suddenly PHP files started downloading instead of running. I don't think I changed or updated anything when the problem began, but obviously something's different since I wasn't having this problem before. I tried reinstalling PHP, making sure .load and .conf were in mods-enabled, etc. Cleared may cache at every step. Looking at the conf files everything seems like it should work, but I'm not having any luck getting it to execute the PHP scripts. Am I overlooking something obvious? Otherwise I can post apache2.conf if it would be worthwhile.

  2. #2
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache downloading PHP instead of running


  3. #3
    Join Date
    Nov 2011
    Beans
    89

    Re: Apache downloading PHP instead of running

    I did try reinstalling libapache2-mod-php5, and still no luck. I've done less with the .conf files because I'm not quite sure what I'm doing there. In fact, I can't even find httpd.conf -- has this been replaced by apache2.conf? If not, then I might not have everything installed properly. php.ini is where it should be, but I can't figure out what section of the file to add the relevant lines to (and I'm still unclear as to exactly what they do).

  4. #4
    Join Date
    Feb 2008
    Location
    Pelican Bay Correctional
    Beans
    Hidden!

    Re: Apache downloading PHP instead of running

    Code:
    DirectoryIndex index.html index.php
    and bounce?

    See http://httpd.apache.org/docs/current...directoryindex
    Push the fader, gifted animator
    One for the now and eleven for the later

  5. #5
    Join Date
    Nov 2011
    Beans
    89

    Re: Apache downloading PHP instead of running

    Thanks -- but I'm still not clear on what these commands are. Maybe this is a case of RTFM and I just haven't familiarized myself with Apache enough yet, but are these lines in a config file, or shell commands? If the former, what file, and where is it stored?

  6. #6
    Join Date
    Nov 2011
    Beans
    89

    Re: Apache downloading PHP instead of running

    I did a little more playing around and found that I CAN get the files to parse if I type the address (e.g., "localhost/test.php") into the browser. They just won't open if I try to open the files from Nautilus. Not sure if this is a default program issue or just a fact about how Apache runs things.

  7. #7
    Join Date
    May 2008
    Location
    Saint Louis
    Beans
    56
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache downloading PHP instead of running

    did you modify the permissions to be executable? ls -ltrh and check to make sure the .php script is marked at least r-x for the www-data user

    example of my settings for a Twitter API php script that is called in the footer of my site. footer.php is a dynamic element that executes the TwitterAPIExchange.php script..soooooo the Twitter script needs to be executable in my case, but not the footer.php because it's just being read from and not actually doing anything outside of exposing it's contents.

    Code:
    -r-x------  1 www-data www-data 7.7K Oct  3  2013 TwitterAPIExchange.php
    drwxrwx---  2 www-data www-data 4.0K Nov  7 21:49 data
    drwxrwxrwx  2 www-data www-data 4.0K Jan 18 13:45 config
    drwxrwxr-x  5 www-data www-data 4.0K Jan 19 16:57 Scrape
    drwxr-xr-x  8 www-data www-data 4.0K Jan 21 11:12 settings
    drwxrwxrwx 33 www-data www-data 4.0K Mar 27 15:20 apps
    drwxr-xr-x 18 www-data www-data 4.0K Mar 27 16:09 lib
    -rw-r--r--  1 www-data www-data 1.4K May  1 17:06 footer.php
    _whitty saying

  8. #8
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    11,250
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Apache downloading PHP instead of running

    Quote Originally Posted by JohnDillinger43 View Post
    I did a little more playing around and found that I CAN get the files to parse if I type the address (e.g., "localhost/test.php") into the browser. They just won't open if I try to open the files from Nautilus. Not sure if this is a default program issue or just a fact about how Apache runs things.
    When you open the file with Nautilus, no program is invoked to parse the PHP code. You see the code itself perhaps in an editor. To see the result after the code is parsed requires that you view the PHP file with a browser. Then Apache gets the request and uses the files in libapache2-mod-php5 to identify the code as a PHP script and hand it on to the PHP Apache module for parsing.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  9. #9
    Join Date
    Nov 2011
    Beans
    89

    Re: Apache downloading PHP instead of running

    Proper execute permissions are set. So even if I select "Open in Google Chrome", what's happening is that Chrome is being used to open it, but the actual PHP5 mod isn't parsing the code before Chrome tries to open it? I suppose that makes sense, though it would still be nice to be able to double-click instead of typing in the address every time.

  10. #10
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache downloading PHP instead of running

    What appears in the address bar when you open it with Chrome?

    Is it something like
    Code:
    file:///var/www/nameoffile.php
    or is it more like
    Code:
    http://localhost/nameoffile.php
    ?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •