Find the answer to your Linux question:
Results 1 to 9 of 9
Like Tree2Likes
  • 1 Post By yancek
  • 1 Post By zombykillah
I'm just wondering if anyone has any idea on this? I'm not sure if this is the right area to find a solution to this either. My error is as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    22

    My php doesn't want to work properly. Apache + MySQL?


    I'm just wondering if anyone has any idea on this? I'm not sure if this is the right area to find a solution to this either.

    My error is as follows: the file which is written in html + php, but is saved as a .php file seems to only download rather than display a page.

    My products
    Database: PHPMYADMIN (I don't think the database would give this kind of error).
    Server: Apache on localhost
    OS: Linux/Ubuntu 11.04

    My website works properly on local host with the .html and .css files, but .php files won't work properly.
    Last edited by WickDaddy; 09-18-2011 at 02:07 AM.

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    How did you install?
    Each program separately?
    Using apt-get from command line?
    Using tasksel?
    When you open your browser in localhost and enter index.html, do yo get the IT WORKS page for Apache?
    Do you see output from the info.php file?
    PhpAdmin is a program to administer LAMP.

    Take a look at the link below which explains setting up LAMP on Ubuntu 11.04 and compare it to what you did.

    http://gregrickaby.com/2011/05/how-t...104-natty.html
    Last edited by yancek; 09-18-2011 at 03:23 AM. Reason: forgot link
    WickDaddy likes this.

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Posts
    22
    1. I used two tutorials online videos on a channel from youtube.


    2. I followed the videos.

    3. yes

    4. tasksel? I'm new to linux

    5. I used to get it, but now i don't because my .html file is there. It works fine.

    6. no output file just a 404.

    Do you have any easy tutorials on how to install something that will allow me to work with .php files?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User
    Join Date
    Dec 2009
    Posts
    264
    Hi,
    Error 404 means that the file you tried accessing doesn't exist.
    So apache just can't find your php script.

    I don't know your apache configuration, usualy the files for apache are stored @ /var/www
    This configuration should be saved in the folder: "/etc/apache2/sites-enabled"
    The files index.* are the standard names which will be used if no special file is requested by the browser.

    If there's not the error 404 but the file won't stop loading it's probably a script that never finishes.
    Meaning there may be a loop that can't finish.
    My suggestion is to test the web-server with a simple script like:
    PHP Code:
    <?php phpinfo(); ?>
    WickDaddy likes this.

  6. #5
    Just Joined!
    Join Date
    Sep 2011
    Posts
    52
    It seems that php is not installed properly. You did not tell what OS you have so I will post 2 links.

    For Redhat like systems:
    How to install LAMP (Apache, PHP and MySQL in Linux) using Yum - Techie Corner
    Note: check if you have the /etc/httpd/conf.d/php.conf file which enables php on the system

    For debian like systems:
    Installing PHP5 and Apache on Ubuntu - How-To Geek
    Note: check if you have /etc/apache2/mods-enabled/php* which enabled php on the system

  7. #6
    Just Joined!
    Join Date
    Sep 2011
    Posts
    22
    sudo apt-get install mysql-server -y

    sudo apt-get install php5 php5-mysql php5-mcrypt apache2

    phpmyadmin-3.4.3.2-english.tar.gz – off of phpmyadmin website

    extract to desktop

    cd ~

    cd Desktop

    phpmyadmin-3.4.3.2-english.tar.gz

    sudo mv phpmyadmin-3.4.3.2-english.tar.gz/ /var/www/phpmyadmin

    -------------

    Everything seemed to install properly when I first did it, but I changed the index.html file to my own index file. Only thing that is not working properly is the fact that I can't get php to parse?

  8. #7
    Just Joined!
    Join Date
    Sep 2011
    Posts
    22
    Quote Originally Posted by zombykillah View Post
    Hi,
    Error 404 means that the file you tried accessing doesn't exist.
    So apache just can't find your php script.

    I don't know your apache configuration, usualy the files for apache are stored @ /var/www
    This configuration should be saved in the folder: "/etc/apache2/sites-enabled"
    The files index.* are the standard names which will be used if no special file is requested by the browser.

    If there's not the error 404 but the file won't stop loading it's probably a script that never finishes.
    Meaning there may be a loop that can't finish.
    My suggestion is to test the web-server with a simple script like:
    PHP Code:
    <?php phpinfo(); ?>
    I changed my index.html file to the code you supplied me. It doesn't give any error, doesn't attempt to download anything, and/or etc. It just gives me a blank white page.

    I was mistaken. It's still attempting to download the file rather than display it.
    Last edited by WickDaddy; 09-18-2011 at 11:34 PM.

  9. #8
    Just Joined!
    Join Date
    Sep 2011
    Posts
    52
    If it gives you the file for downloading then it means php is not enabled in the apache configs. Try adding this to he apache configs:
    Code:
    AddHandler php5-script .php
    AddType text/html .php

  10. #9
    Linux User
    Join Date
    Dec 2009
    Posts
    264
    Quote Originally Posted by WickDaddy View Post
    I changed my index.html file to the code you supplied me. It doesn't give any error, doesn't attempt to download anything, and/or etc. It just gives me a blank white page.

    I was mistaken. It's still attempting to download the file rather than display it.
    Hi,
    If you use php code in an html file it won't be parsed by php.
    So if you change index.html into:
    HTML Code:
    <?php phpinfo(); ?>
    Your browser will show you a white page, when you view the source of the page you will read "<?php phpinfo(); ?>".

    You can enable the parser on html or simple rename the file into a .php file.
    Code:
    mv /var/www/index.html /var/www/index.php
    Open Source and Linux Forums shall now "execute" the php and show you your php config.

    What file extensions become parsed is set in the apache2 settings.
    On my computer for example it's set in:
    /etc/apache2/mods-enabled/php5.conf
    /etc/apache2/conf.d/phpmyadmin.conf

    Well anyway, it seems to me that your apache ain't running correct, so you should check your log files (/var/log) for reported errors:
    Code:
    cd /var/log
    sudo /etc/init.d/apache2 restart
    ls -ltr
    "ls -ltr" will list you all log files ordered by date, just take the last filename (it's probably "syslog") and run:
    tail -n 30 <filename>
    That will show you the last 30 messages of your log.

Posting Permissions

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