SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 30
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Apache2 server cant not run .php file!

    hello guys, i'm new here. need some help regarding php and apache2. recently i've installed apache2 and php5. After installation, the server can succesfully run .html files only. (http://localhost/~myname/). but when i tried to open .php files. it'll ask me to save/open it. why is that happening?

  2. #2
    SitePoint Zealot 2ndmouse's Avatar
    Join Date
    Jan 2007
    Location
    West London
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try adding php5 to APACHE_MODULES in /etc/sysconfig/apache2 and restarting apache
    Detect file changes remotely. SimpleSiteAudit is an early
    warning anti-hacker system which sends an alert on detection.

    PHP Find Orphan Files - Finds all the unreferenced files on your site.

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    most common cause of this problem is skipping the 'restart apache' portion of this instruction
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    ... yup, right up there alongside not knowing about Mysql's FLUSH PRIVILEGES ...

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 2ndmouse View Post
    Try adding php5 to APACHE_MODULES in /etc/sysconfig/apache2 and restarting apache
    i tried already..still the same..

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    most common cause of this problem is skipping the 'restart apache' portion of this instruction
    that's what i thought at the first time, i restarted few times already but still the same.

  7. #7
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Did you complile PHP / Apache from source? If so what ./configure arguments did you use?

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    Did you complile PHP / Apache from source? If so what ./configure arguments did you use?
    when i compile from /var/www it works but when i compile from folder which i created in desktop it cant run.

  9. #9
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    first, do you have in your config file something like:
    Code:
    LoadModule php5_module "/php/path/module"
    AddType application/x-httpd-php .php
    PHPIniDir "/php/ini/path"
    ?

    If yes, restart and check the Apache log.

    Second, try
    Code:
    -t -D DUMP_MODULES
    to check if PHP is there.

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Screenshot from 2013-01-29 19:49:54.png\

    i've uploaded a picture showing the .php files can't run when it is clicked. please give your comment.

  11. #11
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    when i compile from /var/www it works but when i compile from folder which i created in desktop it cant run.
    Do you mean placing the php file in /var/www/ allows it to execute but placing it in /~myfolder/ does not?

    If so, you need to configure /~myfolder/ as a virtual directory allowed to execute php.

    Look for
    Code:
        <IfModule mod_userdir.c>
            <Directory /home/*/public_html>
                php_admin_value engine Off
            </Directory>
        </IfModule>
    In your php5.conf (located in /etc/apache2/mods-enabled/)

    Try changing Off to On and restart apache.

  12. #12
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Screenshot from 2013-02-02 23:05:21.png

    yes,thank you for understanding my problem..i don't really know how to explain at first..anyway, i tried to change php_admin_value engine to On but still it can't execute .php file..i've uploaded a picture regarding the problem..please take a look..for .php file, the symbol is question mark..but for .html file, it's different.

  13. #13
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you post the contents of your php5.conf? I'd like to see it, as maybe I'm missing something obvious that someone else would catch. But I think that file is what we need to be focusing on right now.

    As for the ? icon, don't worry about that, that is apache stating, it doesn't have an icon for the php extension (my setup shows that too, and I can execute php files just fine).

  14. #14
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Can you post the contents of your php5.conf? I'd like to see it, as maybe I'm missing something obvious that someone else would catch. But I think that file is what we need to be focusing on right now.

    As for the ? icon, don't worry about that, that is apache stating, it doesn't have an icon for the php extension (my setup shows that too, and I can execute php files just fine).
    this is my php5.conf content

    <IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
    <Directory /home/*/public_html>
    php_admin_value engine Off
    </Directory>
    </IfModule>
    </IfModule>

  15. #15
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've turn the php_admin_value engine off as it didnt work just now..

  16. #16
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    this is my php5.conf content
    So I suck at reading

    The file clearly states to comment out the entire <IfModule> block not set it to On. *sigh*

    Make your file look like the one below:
    Code:
    <IfModule mod_php5.c>
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        <FilesMatch "\.phps$">
            SetHandler application/x-httpd-php-source
        </FilesMatch>
        # To re-enable php in user directories comment the following lines
        # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
        # prevents .htaccess files from disabling it.
        #<IfModule mod_userdir.c>
        #    <Directory /home/*/public_html>
        #        php_admin_value engine Off
        #    </Directory>
        #</IfModule>
    </IfModule>
    Then restart apache.

  17. #17
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    So I suck at reading

    The file clearly states to comment out the entire <IfModule> block not set it to On. *sigh*

    Make your file look like the one below:
    Code:
    <IfModule mod_php5.c>
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        <FilesMatch "\.phps$">
            SetHandler application/x-httpd-php-source
        </FilesMatch>
        # To re-enable php in user directories comment the following lines
        # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
        # prevents .htaccess files from disabling it.
        #<IfModule mod_userdir.c>
        #    <Directory /home/*/public_html>
        #        php_admin_value engine Off
        #    </Directory>
        #</IfModule>
    </IfModule>
    Then restart apache.
    OMG,it works! haha,thanks dude. ^^,

  18. #18
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    So I suck at reading

    The file clearly states to comment out the entire <IfModule> block not set it to On. *sigh*

    Make your file look like the one below:
    Code:
    <IfModule mod_php5.c>
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        <FilesMatch "\.phps$">
            SetHandler application/x-httpd-php-source
        </FilesMatch>
        # To re-enable php in user directories comment the following lines
        # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
        # prevents .htaccess files from disabling it.
        #<IfModule mod_userdir.c>
        #    <Directory /home/*/public_html>
        #        php_admin_value engine Off
        #    </Directory>
        #</IfModule>
    </IfModule>
    Then restart apache.
    i'm having another problem where even when i execute http://localhost/~myname/ i get the page "IT WORKS". i didn't see my files anymore. why is that happening? but when i execute http://localhost/~myname/test.php i can see the result. means the file is still there,but i just can't see it.
    Last edited by Marvin_G; Feb 2, 2013 at 10:09. Reason: adding information

  19. #19
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    omg.png

    this is what i'm talking about..it keeps come out this page..what happen?

  20. #20
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Hmm... Do you have any files named ".htaccess index.html index.cgi index.pl index.php index.xhtml index.htm" in your folder? From what I can tell, the default setup should permit directory listings

  21. #21
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Hmm... Do you have any files named ".htaccess index.html index.cgi index.pl index.php index.xhtml index.htm" in your folder? From what I can tell, the default setup should permit directory listings
    u mean the public_html folder? last time i checked i dont have those files in there but still works. now i don't know what happen.

  22. #22
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Hmm... Do you have any files named ".htaccess index.html index.cgi index.pl index.php index.xhtml index.htm" in your folder? From what I can tell, the default setup should permit directory listings
    can i re-create the folder? i mean the public_html folder..

  23. #23
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Do you have any files in your public_html folder? This must be a setting somewhere, maybe I'll get a chance to do a fresh apache install in a virtual machine this weekend to see if I can track it down as I've customized 90% of the version of apache I'm running.

  24. #24
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Do you have any files in your public_html folder? This must be a setting somewhere, maybe I'll get a chance to do a fresh apache install in a virtual machine this weekend to see if I can track it down as I've customized 90% of the version of apache I'm running.
    yes i have files in it. just a few minutes ago i can view the content of the folder in the webpage but after i copy few .php and .html files in the public_html folder suddenly it can't be opened. I really don't have any idea what's happening.

  25. #25
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do i need to make the folder world-readable? (i found this somewhere else) but how?


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
  •