Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Apache downloading PHP instead of running

  1. #11
    Join Date
    Nov 2011
    Beans
    95

    Re: Apache downloading PHP instead of running

    The former (file://) downloads the PHP file, while the latter (http://localhost), which is what I have been using successfully, parses and executes the PHP correctly.

  2. #12
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Apache downloading PHP instead of running

    That's normal behavior.

  3. #13
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Apache downloading PHP instead of running

    Quote Originally Posted by aysiu View Post
    That's normal behavior.
    Just to expand on that. PHP is a server side language, which means the web server (Apache/Nginx/IIS, whatever) executes it and spits back the output to the browser.

    If you are opening the php file as a file and not through the web server, it will show the contests of the file itself and not parse it.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  4. #14
    Join Date
    Aug 2012
    Beans
    5

    Re: Apache downloading PHP instead of running

    I'm having a similar problem with .pl (or .cgi) files. They are in the ScriptAlias directory, permissions are 755 for both the directory and the file.



    Here's the relevant part of the .vhost file:

    <Directory /var/www/clients/client3/web12/cgi-bin/>
    Order allow,deny
    Allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /var/www/clients/client3/web12/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl




    The file runs correctly from the command line, but when I access it via the web, instead of executing, it tries to download.

    I've spent the better part of the last two days trying to figure this out. Any help will be GREATLY appreciated.

  5. #15
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Apache downloading PHP instead of running

    Have you considered adding mod_perl to Apache and using that for .pl files?
    Code:
    sudo apt-get install libapache2-mod-perl2 libapache2-mod-perl2-doc
    What are the .cgi file written in? Are they binaries or scripts?
    If you ask for help, do not abandon your request. 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

  6. #16
    Join Date
    Nov 2011
    Beans
    95

    Re: Apache downloading PHP instead of running

    Thanks for all the helpful information and advice. I'm marking this as solved.

Page 2 of 2 FirstFirst 12

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
  •