weird problem serving php outside of documentroot

weird problem serving php outside of documentroot

am 19.07.2007 10:26:03 von Reestit Mutton

Hi Guys,

I've been pulling my hair out over this problem for the past couple of
days and I've taken it as far as I can with the help of information
found on various newsgroups and forums.

I would like to install a single copy of phpmyadmin (2.9.1.1) on Ubuntu
7.04 (Feisty Fawn) to allow multiple subdomains hosted on my PC to
access the mysql database (5.0.38).

I currently have a single subdomain on the PC which has a document root
of /home/[SUBDOMAIN]/public_html/html and the phpmyadmin has been
installed at /usr/share/phpmyadmin (outside of the document root).

To the best of my knowledge I have, via the apache config files (see
listing below), told the web server where the phpmyadmin files reside
and allowed the necessary directory to hold executables.

I've been trying to follow the phpmyadmin configuration instructions at
http://phpmyadmin.sourceforge.net/documentation/ and I get stuck at the
point where it tells you to access the setup.php file via the browser to
kick off the interactive configuration utility.

Whenever I type the URL (subdomain.domain/pma/scripts/setup.php) into my
browser it asks me if I want to open the file with a specific
application or save it - i.e. it doesn't seem to understand that it is
an executable php file. When I allow the browser to open the file in a
text editor, it is empty. There are no errors logged in the relevant
apache error file.

HOWEVER...and this is where I'm stumped...if I place the usual php test
file

phpinfo();
?>

into the same directory as the setup.php file and try and access that I
get the usual php stats page, confirming that the server knows that it
is a php file and can deal with it appropriately. It also confirms my
php version (5.2.1). Equally, this also tells me that the server can
also access the relevant directory (outside of the web server's document
root) and run php scripts from within it.

The permissions of the test file (info.php) and the setup.php file are
identical as the following transcript of ls shows:

-rwxr-xr-x 1 root root 19 2007-07-17 16:43 info.php
-rwxr-xr-x 1 root root 72743 2007-03-24 23:47 setup.php

I have also inserted HTML comments at the top of both info.php and
setup.php and scattered echo statements inside the PHP blocks of both
files. With info.php, all comments and HTML statements are visible on
the output webpage. However, with setup.php, none of the comments or
HTML statements show in the output file when opened with a text editor
and no errors are found in the relevant apache2 error log file.

As a final test, I moved the setup.php file to within my document root
and tried to access it from there and it ran as expected (albeit simply
spewing out complaints about missing inclusions as I had only copied the
setup.php file in isolation, not the whole phpmyadmin subdirectory tree)

Why can I not run the setup.php file from a directory outside the web
server's document root as expected when I can run other PHP files such
as the test "info.php" file? Can anyone explain where my reasoning is
wrong or where I've missed something glaringly obvious? I'm really at my
wits end here...

For the record, I've asked the same question on the phpmyadmin forums
and, after some discussion, I've been referred here as they feel that my
problem seems to be specific to the apache setup.

cheers
Reestit Mutton


To help troubleshoot this problem, my subdomain-specific Apache2
(version 2.2.3) config file (/etc/apache2/sites-available/default) is as
follows, where certain details are currently masked out for security:

In the listing below, NNNN = port number

================================================

NameVirtualHost *:[NNNN]


ServerAdmin webmaster@localhost

DocumentRoot /home/[SUBDOMAIN]/public_html/html
ServerName [SUBDOMAIN].[DOMAIN]:NNNN
DirectoryIndex index.html index.htm index.php
ErrorLog /var/log/apache2/error.log


Options FollowSymLinks
AllowOverride None



Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


### Global phpMyAdmin for Virtual Hosts ###
Alias /pma/ /usr/share/phpmyadmin/

Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride None
Order allow,deny
allow from all


# Possible values include: debug, info, notice, warn, error,
# crit, alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128




and my apache2.conf is exactly as it was supplied out of the box with
only one addition at the end for the subdomain that I'm hosting on my PC:

======
# ServerName
ServerName [SUBDOMAIN].[DOMAIN]
======

Re: weird problem serving php outside of documentroot

am 19.07.2007 12:15:31 von David McKenzie

Reestit Mutton wrote:
> Hi Guys,
>
> I've been pulling my hair out over this problem for the past couple of
> days and I've taken it as far as I can with the help of information
> found on various newsgroups and forums.
>
> I would like to install a single copy of phpmyadmin (2.9.1.1) on Ubuntu
> 7.04 (Feisty Fawn) to allow multiple subdomains hosted on my PC to
> access the mysql database (5.0.38).
>
> I currently have a single subdomain on the PC which has a document root
> of /home/[SUBDOMAIN]/public_html/html and the phpmyadmin has been
> installed at /usr/share/phpmyadmin (outside of the document root).
>
> To the best of my knowledge I have, via the apache config files (see
> listing below), told the web server where the phpmyadmin files reside
> and allowed the necessary directory to hold executables.
>
> I've been trying to follow the phpmyadmin configuration instructions at
> http://phpmyadmin.sourceforge.net/documentation/ and I get stuck at the
> point where it tells you to access the setup.php file via the browser to
> kick off the interactive configuration utility.
>
> Whenever I type the URL (subdomain.domain/pma/scripts/setup.php) into my
> browser it asks me if I want to open the file with a specific
> application or save it - i.e. it doesn't seem to understand that it is
> an executable php file. When I allow the browser to open the file in a
> text editor, it is empty. There are no errors logged in the relevant
> apache error file.
>
> HOWEVER...and this is where I'm stumped...if I place the usual php test
> file
>
> > phpinfo();
> ?>
>
> into the same directory as the setup.php file and try and access that I
> get the usual php stats page, confirming that the server knows that it
> is a php file and can deal with it appropriately. It also confirms my
> php version (5.2.1). Equally, this also tells me that the server can
> also access the relevant directory (outside of the web server's document
> root) and run php scripts from within it.
>
> The permissions of the test file (info.php) and the setup.php file are
> identical as the following transcript of ls shows:
>
> -rwxr-xr-x 1 root root 19 2007-07-17 16:43 info.php
> -rwxr-xr-x 1 root root 72743 2007-03-24 23:47 setup.php
>
> I have also inserted HTML comments at the top of both info.php and
> setup.php and scattered echo statements inside the PHP blocks of both
> files. With info.php, all comments and HTML statements are visible on
> the output webpage. However, with setup.php, none of the comments or
> HTML statements show in the output file when opened with a text editor
> and no errors are found in the relevant apache2 error log file.
>
> As a final test, I moved the setup.php file to within my document root
> and tried to access it from there and it ran as expected (albeit simply
> spewing out complaints about missing inclusions as I had only copied the
> setup.php file in isolation, not the whole phpmyadmin subdirectory tree)
>
> Why can I not run the setup.php file from a directory outside the web
> server's document root as expected when I can run other PHP files such
> as the test "info.php" file? Can anyone explain where my reasoning is
> wrong or where I've missed something glaringly obvious? I'm really at my
> wits end here...
>
> For the record, I've asked the same question on the phpmyadmin forums
> and, after some discussion, I've been referred here as they feel that my
> problem seems to be specific to the apache setup.
>
> cheers
> Reestit Mutton
>
>
> To help troubleshoot this problem, my subdomain-specific Apache2
> (version 2.2.3) config file (/etc/apache2/sites-available/default) is as
> follows, where certain details are currently masked out for security:
>
> In the listing below, NNNN = port number
>
> ================================================
>
> NameVirtualHost *:[NNNN]
>
>
> ServerAdmin webmaster@localhost
>
> DocumentRoot /home/[SUBDOMAIN]/public_html/html
> ServerName [SUBDOMAIN].[DOMAIN]:NNNN
> DirectoryIndex index.html index.htm index.php
> ErrorLog /var/log/apache2/error.log
>
>
> Options FollowSymLinks
> AllowOverride None
>

>
>
> Options Indexes FollowSymLinks MultiViews
> AllowOverride None
> Order allow,deny
> allow from all
>

>
> ### Global phpMyAdmin for Virtual Hosts ###
> Alias /pma/ /usr/share/phpmyadmin/
>
> Options Indexes FollowSymLinks MultiViews +ExecCGI
> AllowOverride None
> Order allow,deny
> allow from all
>

>
> # Possible values include: debug, info, notice, warn, error,
> # crit, alert, emerg.
> LogLevel warn
>
> CustomLog /var/log/apache2/access.log combined
> ServerSignature On
>
> Alias /doc/ "/usr/share/doc/"
>
> Options Indexes MultiViews FollowSymLinks
> AllowOverride None
> Order deny,allow
> Deny from all
> Allow from 127.0.0.0/255.0.0.0 ::1/128
>

>
>

>
> and my apache2.conf is exactly as it was supplied out of the box with
> only one addition at the end for the subdomain that I'm hosting on my PC:
>
> ======
> # ServerName
> ServerName [SUBDOMAIN].[DOMAIN]
> ======
>
>
One thing you can check is that the php file that isn't loading isn't a
binary PHP file, such as one that uses Zend or Ioncube. It's a long
shot, but worth a try.

--
DM davidm@cia.com.au

The funny .sig is in the wash, I am your replacement.

Re: weird problem serving php outside of documentroot

am 19.07.2007 14:29:31 von mark

Reestit Mutton wrote in news:469f2027$0
$1634$ed2619ec@ptn-nntp-reader02.plus.net:

> ### Global phpMyAdmin for Virtual Hosts ###
> Alias /pma/ /usr/share/phpmyadmin/
>
> Options Indexes FollowSymLinks MultiViews +ExecCGI
> AllowOverride None
> Order allow,deny
> allow from all
>

>

This is also a long shot, but try changing these two lines as follows:


Alias /pma/ /usr/share/phpmyadmin
Options Indexes FollowSymLinks MultiViews ExecCGI


Be sure to restart the server.




--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: weird problem serving php outside of documentroot

am 19.07.2007 17:09:44 von Reestit Mutton

David McKenzie wrote:

>>
> One thing you can check is that the php file that isn't loading isn't a
> binary PHP file, such as one that uses Zend or Ioncube. It's a long
> shot, but worth a try.
>

Hi David,

Interesting theory...how do I check this?

cheers
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 19.07.2007 17:10:33 von Reestit Mutton

Mark wrote:
> Reestit Mutton wrote in news:469f2027$0
> $1634$ed2619ec@ptn-nntp-reader02.plus.net:
>
>> ### Global phpMyAdmin for Virtual Hosts ###
>> Alias /pma/ /usr/share/phpmyadmin/
>>
>> Options Indexes FollowSymLinks MultiViews +ExecCGI
>> AllowOverride None
>> Order allow,deny
>> allow from all
>>

>>
>
> This is also a long shot, but try changing these two lines as follows:
>
>
> Alias /pma/ /usr/share/phpmyadmin
> Options Indexes FollowSymLinks MultiViews ExecCGI
>
>
> Be sure to restart the server.
>

Hi Mark,

Anything's worth a try at this stage...

removing the trailing slash resulted in both setup.php and info.php
failing due to lack of permissions.

removing the "+" from the Options line has no effect.

cheers
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 19.07.2007 18:04:29 von Your Best Friend

Use LAMPP
http://www.google.com/search?q=LAMPP
http://www.google.com/search?q=xampp+for+linux

Reestit Mutton wrote:
> Hi Guys,
>
> I've been pulling my hair out over this problem for the past couple of
> days and I've taken it as far as I can with the help of information
> found on various newsgroups and forums.
>
> I would like to install a single copy of phpmyadmin (2.9.1.1) on Ubuntu
> 7.04 (Feisty Fawn) to allow multiple subdomains hosted on my PC to
> access the mysql database (5.0.38).
>
> I currently have a single subdomain on the PC which has a document root
> of /home/[SUBDOMAIN]/public_html/html and the phpmyadmin has been
> installed at /usr/share/phpmyadmin (outside of the document root).
>
> To the best of my knowledge I have, via the apache config files (see
> listing below), told the web server where the phpmyadmin files reside
> and allowed the necessary directory to hold executables.
>
> I've been trying to follow the phpmyadmin configuration instructions at
> http://phpmyadmin.sourceforge.net/documentation/ and I get stuck at the
> point where it tells you to access the setup.php file via the browser to
> kick off the interactive configuration utility.
>
> Whenever I type the URL (subdomain.domain/pma/scripts/setup.php) into my
> browser it asks me if I want to open the file with a specific
> application or save it - i.e. it doesn't seem to understand that it is
> an executable php file. When I allow the browser to open the file in a
> text editor, it is empty. There are no errors logged in the relevant
> apache error file.
>
> HOWEVER...and this is where I'm stumped...if I place the usual php test
> file
>
> > phpinfo();
> ?>
>
> into the same directory as the setup.php file and try and access that I
> get the usual php stats page, confirming that the server knows that it
> is a php file and can deal with it appropriately. It also confirms my
> php version (5.2.1). Equally, this also tells me that the server can
> also access the relevant directory (outside of the web server's document
> root) and run php scripts from within it.
>
> The permissions of the test file (info.php) and the setup.php file are
> identical as the following transcript of ls shows:
>
> -rwxr-xr-x 1 root root 19 2007-07-17 16:43 info.php
> -rwxr-xr-x 1 root root 72743 2007-03-24 23:47 setup.php
>
> I have also inserted HTML comments at the top of both info.php and
> setup.php and scattered echo statements inside the PHP blocks of both
> files. With info.php, all comments and HTML statements are visible on
> the output webpage. However, with setup.php, none of the comments or
> HTML statements show in the output file when opened with a text editor
> and no errors are found in the relevant apache2 error log file.
>
> As a final test, I moved the setup.php file to within my document root
> and tried to access it from there and it ran as expected (albeit simply
> spewing out complaints about missing inclusions as I had only copied the
> setup.php file in isolation, not the whole phpmyadmin subdirectory tree)
>
> Why can I not run the setup.php file from a directory outside the web
> server's document root as expected when I can run other PHP files such
> as the test "info.php" file? Can anyone explain where my reasoning is
> wrong or where I've missed something glaringly obvious? I'm really at my
> wits end here...
>
> For the record, I've asked the same question on the phpmyadmin forums
> and, after some discussion, I've been referred here as they feel that my
> problem seems to be specific to the apache setup.
>
> cheers
> Reestit Mutton
>
>
> To help troubleshoot this problem, my subdomain-specific Apache2
> (version 2.2.3) config file (/etc/apache2/sites-available/default) is as
> follows, where certain details are currently masked out for security:
>
> In the listing below, NNNN = port number
>
> ================================================
>
> NameVirtualHost *:[NNNN]
>
>
> ServerAdmin webmaster@localhost
>
> DocumentRoot /home/[SUBDOMAIN]/public_html/html
> ServerName [SUBDOMAIN].[DOMAIN]:NNNN
> DirectoryIndex index.html index.htm index.php
> ErrorLog /var/log/apache2/error.log
>
>
> Options FollowSymLinks
> AllowOverride None
>

>
>
> Options Indexes FollowSymLinks MultiViews
> AllowOverride None
> Order allow,deny
> allow from all
>

>
> ### Global phpMyAdmin for Virtual Hosts ###
> Alias /pma/ /usr/share/phpmyadmin/
>
> Options Indexes FollowSymLinks MultiViews +ExecCGI
> AllowOverride None
> Order allow,deny
> allow from all
>

>
> # Possible values include: debug, info, notice, warn, error,
> # crit, alert, emerg.
> LogLevel warn
>
> CustomLog /var/log/apache2/access.log combined
> ServerSignature On
>
> Alias /doc/ "/usr/share/doc/"
>
> Options Indexes MultiViews FollowSymLinks
> AllowOverride None
> Order deny,allow
> Deny from all
> Allow from 127.0.0.0/255.0.0.0 ::1/128
>

>
>

>
> and my apache2.conf is exactly as it was supplied out of the box with
> only one addition at the end for the subdomain that I'm hosting on my PC:
>
> ======
> # ServerName
> ServerName [SUBDOMAIN].[DOMAIN]
> ======
>
>

--
Thanks,
Bryan K
bk@bkworksproducts.com.info
To reply, remove .com
** PROUD USER OF THUNDERBIRD **

Re: weird problem serving php outside of documentroot

am 20.07.2007 01:01:53 von David McKenzie

Reestit Mutton wrote:
> David McKenzie wrote:
>
>>>
>> One thing you can check is that the php file that isn't loading isn't
>> a binary PHP file, such as one that uses Zend or Ioncube. It's a long
>> shot, but worth a try.
>>
>
> Hi David,
>
> Interesting theory...how do I check this?
>
> cheers
> Reestit Mutton
Open it up in a text viewer, e.g. Notepad in Windows or Vi if using the
command line, and if the text displays as non-readable, it's a binary
php file. I'm pretty sure phpMyAdmin doesn't use this, but still worth a
try.

--
DM davidm@cia.com.au

The funny .sig is in the wash, I am your replacement.

Re: weird problem serving php outside of documentroot

am 20.07.2007 06:46:55 von Reestit Mutton

David McKenzie wrote:
> Reestit Mutton wrote:
>> David McKenzie wrote:
>>
>>>>
>>> One thing you can check is that the php file that isn't loading isn't
>>> a binary PHP file, such as one that uses Zend or Ioncube. It's a long
>>> shot, but worth a try.
>>>
>>
>> Hi David,
>>
>> Interesting theory...how do I check this?
>>
>> cheers
>> Reestit Mutton
> Open it up in a text viewer, e.g. Notepad in Windows or Vi if using the
> command line, and if the text displays as non-readable, it's a binary
> php file. I'm pretty sure phpMyAdmin doesn't use this, but still worth a
> try.
>

d'oh!

It's a perfectly readable non-binary file.

Any more suggestions guys?

thanks,
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 20.07.2007 06:57:26 von Reestit Mutton

Your Best Friend wrote:
> Use LAMPP
> http://www.google.com/search?q=LAMPP
> http://www.google.com/search?q=xampp+for+linux
>

Thanks for the useful pointer, YBF.

I already have all the building blocks to LAMPP in place as it is, fully
configured for my needs (with the notable exception of getting
phpmyadmin to work as a centrally installed copy). If I were to replace
my current setup with a LAMPP installation it is possible that this
may fix my problem but it is also equally possible that I simply end up
replacing my current issue with an indeterminate number of other issues.

For this reason I'll have to leave this as a last-resort option for now.

regards
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 24.07.2007 14:02:58 von Reestit Mutton

Any more ideas guys?...I'm fresh out of ideas myself.

cheers
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 24.07.2007 15:39:18 von mark

Reestit Mutton wrote in news:46a5ea7b$0$1629
$ed2619ec@ptn-nntp-reader02.plus.net:

> Any more ideas guys?...I'm fresh out of ideas myself.
>
> cheers
> Reestit Mutton
>

Give me command line access with root privileges and I'll see what I can
do...



--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: weird problem serving php outside of documentroot

am 24.07.2007 17:10:00 von Reestit Mutton

Mark wrote:
> Reestit Mutton wrote:
>> Any more ideas guys?...I'm fresh out of ideas myself.
>
> Give me command line access with root privileges and I'll see what I can
> do...

Sorry...no can do. I'm desperate, but not *that* desperate.

Reestit Mutton

Re: weird problem serving php outside of documentroot

am 24.07.2007 17:31:07 von mark

Reestit Mutton wrote in
news:46a61648$0$1590$ed2619ec@ptn-nntp-reader02.plus.net:

> Mark wrote:
>> Reestit Mutton wrote:
>>> Any more ideas guys?...I'm fresh out of ideas myself.
>>
>> Give me command line access with root privileges and I'll see what I
>> can do...
>
> Sorry...no can do. I'm desperate, but not *that* desperate.
>
> Reestit Mutton
>

Well when you are, you can surely find someone to assist. Sometimes its
something simple that experienced admins do on instinct and just forget
to mention or assume you are doing it.



--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: weird problem serving php outside of documentroot

am 25.07.2007 12:09:09 von Reestit Mutton

Mark wrote:
> Reestit Mutton wrote in
> news:46a61648$0$1590$ed2619ec@ptn-nntp-reader02.plus.net:
>
>> Mark wrote:
>>> Reestit Mutton wrote:
>>>> Any more ideas guys?...I'm fresh out of ideas myself.
>>> Give me command line access with root privileges and I'll see what I
>>> can do...
>> Sorry...no can do. I'm desperate, but not *that* desperate.
>>
>
> Well when you are, you can surely find someone to assist. Sometimes its
> something simple that experienced admins do on instinct and just forget
> to mention or assume you are doing it.
>

I know what you mean, Mark. I do appreciate the offer of hands-on
assistance. However, as an experienced sysadmin I'm sure you can
understand my reluctance to open up my machine to someone that I've
never met, however well meaning they may seem. It would be a bit like
giving my house keys to someone I just happened to meet in a pub.

Anyway, while the issue remains outstanding, I've now moved on to
something else in the hope that revisiting the problem at a later date
with a fresh pair of eyes and, perhaps, a slightly different perspective
may allow me to spot the glaring error in my setup.

That said, I'm still open to further suggestions/advice...

regards
Reestit Mutton

Re: weird problem serving php outside of documentroot

am 06.08.2007 15:28:01 von Reestit Mutton

Reestit Mutton wrote:
> Mark wrote:
>> Reestit Mutton wrote in
>> news:46a61648$0$1590$ed2619ec@ptn-nntp-reader02.plus.net:
>>> Mark wrote:
>>>> Reestit Mutton wrote:
>>>>> Any more ideas guys?...I'm fresh out of ideas myself.
>>>> Give me command line access with root privileges and I'll see what I
>>>> can do...
>>> Sorry...no can do. I'm desperate, but not *that* desperate.
>>>
>>
>> Well when you are, you can surely find someone to assist. Sometimes
>> its something simple that experienced admins do on instinct and just
>> forget to mention or assume you are doing it.
>>
>
> I know what you mean, Mark. I do appreciate the offer of hands-on
> assistance. However, as an experienced sysadmin I'm sure you can
> understand my reluctance to open up my machine to someone that I've
> never met, however well meaning they may seem. It would be a bit like
> giving my house keys to someone I just happened to meet in a pub.
>
> Anyway, while the issue remains outstanding, I've now moved on to
> something else in the hope that revisiting the problem at a later date
> with a fresh pair of eyes and, perhaps, a slightly different perspective
> may allow me to spot the glaring error in my setup.
>
> That said, I'm still open to further suggestions/advice...
>

Hi guys,

Just a quick note to let you know that I've solved my problem.
Frustratingly, a fresh installation of the phpmyadmin application and a
symlink to the install directory under the document root was all that
was required...not even a sniff of manual configuration required.

Why it didn't work last time, I just don't know...I guess I'll never know.

cheers for all the advice,
Reestit Mutton