LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-07-2013, 04:09 AM   #1
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201
Blog Entries: 3

Rep: Reputation: 37
php files not working in my public_html in ubuntu


I have lampp as well as apache2.
I can easily access my files using lampp but they are not accessible when they are in public_html.
My lampp is stopped and apache2 is running when I try to open them through public_html.
What am I doing wrong?

When you open php files using lampp. you say you are using xampp or lampp but what do say when you run it using httpd and access through public_html?
 
Old 03-07-2013, 04:33 AM   #2
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
As you have said you have stopped XAMPP and start apache2.
I hope you have watched it carefully and it does not give error.
Another apache web server demon is running.
 
Old 03-07-2013, 04:52 AM   #3
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
Hey ! Thanks for your reply.
Yes I have watched this, it does not give this error.
When I start apache2, it gives following message
Code:
 * Starting web server apache2                                           [ OK ]
 
Old 03-07-2013, 05:11 AM   #4
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
When you try to access your php files, what is the error there.
Code:
http://localhost/webproject
what is the output of
Code:
http://localhost
 
Old 03-07-2013, 05:21 AM   #5
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
when I open http://localhost
It opens page "It works"
It looks like apache2 is working but when I try to open
http://localhost/phpproject
It shows not found. It gives download link of index.php. The index.php in inside phpproject directory.
Although phpproject is inside /var/www.
I don't know why does it not find it?

Last edited by bloodstreetboy; 03-07-2013 at 05:28 AM.
 
Old 03-07-2013, 05:26 AM   #6
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Have you added this line in your apache conf file
Code:
AddType application/x-httpd-php .php .phtml
 
Old 03-07-2013, 05:29 AM   #7
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
Yes this line is already there in apache2.conf and it is not commented.
Although I have restarted apache2 and it still gives me download link of index.php.
 
Old 03-07-2013, 05:31 AM   #8
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Did you install libapache2-mod-php5?
 
Old 03-07-2013, 05:47 AM   #9
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
Yes, the module has been installed already and it says "already installed".
Although I have restarted apache2 again and it still gives me download link of index.php.
 
Old 03-07-2013, 05:54 AM   #10
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Try adding this to your .htaccess file:

Code:
DirectoryIndex index.php index.html index.htm
 
Old 03-07-2013, 05:58 AM   #11
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
No DirectoryIndex is not working for me.
Same issue.
 
Old 03-07-2013, 06:10 AM   #12
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Try the following:

* Disable SELINUX if it's enabled.

* Try giving any .php files the "x" execute permission.

* Create a small file called info.php containing:

Code:
<?php
phpinfo();
<?>
Place it in the relefant folder and access it directly with http://server/folder/info.php

If you get the original file back then your PHP installation is not working, if it comes back with a lot of information then PHP IS working.
 
Old 03-07-2013, 06:24 AM   #13
bloodstreetboy
Member
 
Registered: May 2012
Posts: 201

Original Poster
Blog Entries: 3

Rep: Reputation: 37
Yes My SELinux is disabled already.
I already told you if it is php file, it shows me download box instead of opening it.
same for phpinfo.php
I don't want to download it and it gives me download link.
I know how is it opened, I have opened it in xampp.
It is not working here. thanks for reply.
 
Old 03-07-2013, 06:25 AM   #14
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
If you can see "it works page", it means it can read the html but as you are saying it gives download link for index.php.
Some how it is not able to read php files. It looks like php modules are disabled.
Can you run following command?
Code:
$ sudo a2enmod php5
Check once /etc/apache2/mods-available, if there are php.conf and php.load, then run
Code:
$ sudo a2enmod php
 
Old 03-07-2013, 06:31 AM   #15
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by bloodstreetboy View Post
I already told you if it is php file, it shows me download box instead of opening it.
same for phpinfo.php
I'm well aware that it is a PHP file, with the phpinfo.php file I was starting with a known method of checking that your php modules for apache were correctly installed.

They aren't.

You're now going to reply with "I already told you they are installed"... they aren't. They aren't installed/configured correctly. Good luck!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
no browser open index.php files but other *.php files working gal Linux - Server 3 12-24-2012 06:40 AM
public_html not working house_randann Linux - Networking 4 01-05-2007 06:56 PM
httpd ~user/public_html not working belorion Linux - General 11 12-01-2006 04:19 PM
PHP and public_html MurrayL Linux - Security 2 11-08-2004 01:00 AM
User's public_html is not parseing .htaccess files greenhornet Linux - Networking 1 04-02-2002 03:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration