Results 1 to 9 of 9
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 ...
- 09-18-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 18
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 01:07 AM.
- 09-18-2011 #2Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,943
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.htmlLast edited by yancek; 09-18-2011 at 02:23 AM. Reason: forgot link
- 09-18-2011 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 18
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?
- 09-18-2011 #4Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
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(); ?>
- 09-18-2011 #5Just 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
- 09-18-2011 #6Just Joined!
- Join Date
- Sep 2011
- Posts
- 18
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?
- 09-18-2011 #7Just Joined!
- Join Date
- Sep 2011
- Posts
- 18
Last edited by WickDaddy; 09-18-2011 at 10:34 PM.
- 09-19-2011 #8Just 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
- 09-20-2011 #9Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
Hi,
If you use php code in an html file it won't be parsed by php.
So if you change index.html into:
Your browser will show you a white page, when you view the source of the page you will read "<?php phpinfo(); ?>".HTML Code:<?php phpinfo(); ?>
You can enable the parser on html or simple rename the file into a .php file.
Open Source and Linux Forums shall now "execute" the php and show you your php config.Code:mv /var/www/index.html /var/www/index.php
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:
"ls -ltr" will list you all log files ordered by date, just take the last filename (it's probably "syslog") and run:Code:cd /var/log sudo /etc/init.d/apache2 restart ls -ltr
tail -n 30 <filename>
That will show you the last 30 messages of your log.


2Likes
Reply With Quote
