Jump to content

PHP isn't working with Apache webserver


Landslyde
Go to solution Solved by QuickOldCar,

Recommended Posts

First thing: I formatted my drive today and fresh installs of Apache2, PHP5 and MariaDB on Linux Mint 17.1. No files have been messed with. Not one. 

 

I created info.php and placed it in var/www dir. The file consists of one line:  <?php phpinfo(); ?>

 

When I run it our of my web editor (Bluefish), instead of showing me on my web browser the PHP info page that's suppose to show, I get:  <?php phpinfo(); ?>

 

I've been fighting this for two days! Done everything suggested by many others online...and that's why I had to scrub my drive; forgot all the files I augmented.

 

Does anyone know why my PHP files behave this way? I'd love to start working with PHP, but I can't until whatever's broken is fixed. Any ideas? Any suggestions? I'm at my wit's end with this.

 

Landslyde

Link to comment
Share on other sites

Did you manually install it or did you use the yum install?

 

Edit: Or even the rpm install?

Sorry. Linux Mint is Debian, so the install was sudo apt-get.

 

After installing my OS, I installed apache2, php5 and a few others like MariaDB. All were installed separately from one another. In other words, I didn't use LAMP.

Edited by Landslyde
Link to comment
Share on other sites

Sorry. Linux Mint is Debian, so the install was sudo apt-get.

 

After installing my OS, I installed apache2, php5 and a few others like MariaDB. All were installed separately from one another. In other words, I didn't use LAMP.

That's fine. Umm, When you go to localhost, does it give you the default Apache webpage stating that you've installed Apache correctly? Have you configured your Apache settings using gedit?

Link to comment
Share on other sites

That's fine. Umm, When you go to localhost, does it give you the default Apache webpage stating that you've installed Apache correctly? Have you configured your Apache settings using gedit?

Yes, I get the default Apache page. But no, I haven't edited any files, Apache or otherwise. From your question, I think I was suppose to. But I wldn't know where to start  :-\ 

Link to comment
Share on other sites

Yes, I get the default Apache page. But no, I haven't edited any files, Apache or otherwise. From your question, I think I was suppose to. But I wldn't know where to start  :-\ 

Ok, so if you're seeing the default Apache page, that means you've installed it correctly. Next, I would use sudo gedit and edit the httpd.conf file. I'm not sure exactly where it's located cuz I use Fedora, but umm find the line that says

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

In that section, check to see if you have php added, if not. Add in this line.

AddType application/x-httpd-php .php

The reason why you are seeing just the plain PHP code is because PHP isn't enabled like this. Sometimes you might have to actually add in the mime types or you won't see it.

 

I'm not sure if I'm right, but you can try that.

Link to comment
Share on other sites

Ok, so if you're seeing the default Apache page, that means you've installed it correctly. Next, I would use sudo gedit and edit the httpd.conf file. I'm not sure exactly where it's located cuz I use Fedora, but umm find the line that says



<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

In that section, check to see if you have php added, if not. Add in this line.



AddType application/x-httpd-php .php

The reason why you are seeing just the plain PHP code is because PHP isn't enabled like this. Sometimes you might have to actually add in the mime types or you won't see it.

 

I'm not sure if I'm right, but you can try that.

 

Debian doesn't use the httpd.conf file. I had read that it uses appache2.conf, but I checked for what you told me to look for and it isn't there. I checked not only that file but all files in all the folders in that dir. Now what? :happy-04:

Link to comment
Share on other sites

 

use taskel and install it







sudo apt-get update
sudo tasksel install lamp-server

What's tasksel? I ask because this command isn't found on Linux Mint. Should I just use: sudo apt-get install lamp-server ?

 

 

woogi@woogi-VPCEH1AFX ~ $ sudo tasksel install lamp-server

[sudo] password for woogi:

sudo: tasksel: command not found

 

Also, will I need to purge and autoremove apache2 before installing it with LAMP?

Edited by Landslyde
Link to comment
Share on other sites

Debian doesn't use the httpd.conf file. I had read that it uses appache2.conf, but I checked for what you told me to look for and it isn't there. I checked not only that file but all files in all the folders in that dir. Now what? :happy-04:

Hmmm, try doing sudo apt-get update. I remember when I had to install PHP on my Ubuntu machine and I had the same problem. I believe I just used sudo apt-get upgrade because after that, it started working for me. Or try re-installing it again. Maybe some plugins didn't install correctly.

 

Edit: Looks like QuickOldCar got to it before I did.

Edited by LeJack
Link to comment
Share on other sites

Hmmm, try doing sudo apt-get update. I remember when I had to install PHP on my Ubuntu machine and I had the same problem. I believe I just used sudo apt-get upgrade because after that, it started working for me. Or try re-installing it again. Maybe some plugins didn't install correctly.

 

Edit: Looks like QuickOldCar got to it before I did.

Yeah. I appreciate all of you guys helping me. But I'm going to throw in the towel on this and forget abt PHP altogether. You see, only a couple hours ago I updated and upgraded. Nothing brought me closer to being able to PHP like the rest of the world does. And my fight with this has been two very very long days. But while I have no love whatsoever for JSP, at least it works for me on NetBeans. So I guess that's the way I'll go. Thanks again for all your help...all of you.

 

LOL! Just when I closed this I had a new msg from QuickOldCar (hope it's a Mustang!). So, out of respect, I'll install LAMP and see where it takes me. I'll post again on this.

Edited by Landslyde
Link to comment
Share on other sites

Yeah. I appreciate all of you guys helping me. But I'm going to throw in the towel on this and forget abt PHP altogether. You see, only a couple hours ago I updated and upgraded. Nothing brought me closer to being able to PHP like the rest of the world does. And my fight with this has been two very very long days. But while I have no love whatsoever for JSP, at least it works for me on NetBeans. So I guess that's the way I'll go. Thanks again for all your help...all of you.

You shouldn't give up yet. Un-install everything. Then re-install everything. Install Apache first, then install PHP.

 

Here, I'll give you a link that might help you out in a PM.

Link to comment
Share on other sites

You shouldn't give up yet. Un-install everything. Then re-install everything. Install Apache first, then install PHP.

 

Here, I'll give you a link that might help you out in a PM.

 

I just installed LAMP through the use of tasksel as suggested by QuickOldCar. I get the same thing!! When I run the info.php file, which, again, consists of one line

 

<?php phpinfo(); ?> 

 

that line is what I see on the webpage. Why won't this work? I mean I formatted my drive today and started from scratch! Then installed LAMP, the same things I already had installed, and it still refuses to cooperate!! This is crazy. And once again, I'm open to suggestions...up to and including blowing up my laptop! :P

Link to comment
Share on other sites

Is there any difference running http://127.0.0.1/info.php versus http://localhost/info.php

It shouldn't be any different because it's running the same Apache configuration.

 

All I can think of right now is the .conf file is missing some key configurations, but I could be wrong. I remember I just had to update my Ubuntu and it worked. I'm not really sure what's going on with LandSlyde's localhost.

Link to comment
Share on other sites

QuickOldCar:

LeJack:

 

God bless both of you!! I now have PHP the way the rest of the world does! :D Everything works! You guys meet me at Joe's in an hour...the drinks are on me!

 

I installed Lamp, although I removed MySQL and reinstalled MariaDB, watched a video shot to me by LeJack and...lol...the rest is history! I will be a contributor here for a long time to come. This is the most helpful forum I've ever been on. PHPFreaks ROCKS!!

 

Thanks again :D

 

 

I do have one more question though: Do I have to store all of my php files in var/www/html for testing? They can't be somewhere on my Desktop in a folder? I ask because I can access regular html files from a desktop folder and use them...but it seems php is a special case. Just wondering.

Edited by Landslyde
Link to comment
Share on other sites

QuickOldCar:

LeJack:

 

God bless both of you!! I now have PHP the way the rest of the world does! :D Everything works! You guys meet me at Joe's in an hour...the drinks are on me!

 

I installed Lamp, although I removed MySQL and reinstalled MariaDB, watched a video shot to me by LeJack and...lol...the rest is history! I will be a contributor here for a long time to come. This is the most helpful forum I've ever been on. PHPFreaks ROCKS!!

 

Thanks again :D

 

 

I do have one more question though: Do I have to store all of my php files in var/www/html for testing? They can't be somewhere on my Desktop in a folder? I ask because I can access regular html files from a desktop folder and use them...but it seems php is a special case. Just wondering.

Well, you could, but I'm not sure how to configure Apache to point to a different destination cuz I have mine installed on Windows so I basically installed mine in my C drive.

 

I believe it's possible to install your workspace on other places, but you'll have to configure it in the apache2.conf file. Not sure if that helps.

Link to comment
Share on other sites

It used to always be var/www

 

The new default web server location is var/www/html, the answer is yes

The php won't get parsed unless you ran it from cli(command line interface) or in that folder

 

Mostly due to permissions is best to do it from the public html folder

You could include or require files (a php script for whatever reason) from outside of the public html folder though

For instance wanting to include a list of sensitive passwords to check against stored in a csv file located in /var/passwords

 

Btw welcome, visit php.net for some tutorials,examples and a wealth of information

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.