# ubuntu/lighttpd: 404 error though file exists



## Gorge (Nov 10, 2008)

Ubuntu, installed phpmyadmin via apt-get (current version 3.4.11.1deb1) and configured a vhost that points to /usr/share/phpmyadmin

everything is working except from phpmyadmin.css.php. it gives me the wanted result when I run it from the command line, but lighttpd gives me a 404

access log shows "404 345", but no mention in the error log

any ideas?


----------



## Fjandr (Sep 26, 2012)

So you can access any other file in /usr/share/phpmyadmin via http except phpmyadmin.css.php?


----------



## Gorge (Nov 10, 2008)

exactly. phpmyadmin looks weird that way and is a bit difficult to use ... I already considered to hack the source and use a static css; but I´d rather like the cause solved instead of only the symptom.


----------



## Fjandr (Sep 26, 2012)

That is very odd. Have you checked the httpd.conf and any .htaccess files for possible redirection weirdness?

Try renaming the file to something simple like "test" and replacing the calls in the source to point to it. Might give you a clue to the origin of the problem.


----------



## Gorge (Nov 10, 2008)

no htaccess files but in /usr/share/phpmyadmin/setup/lib, /usr/share/phpmyadmin/setup/frames, /usr/share/phpmyadmin/libraries
and they all contain nothing but "Order allow,deny" and a few comments.
-----

```
> tail -6 /etc/lighttpd/lighttpd.conf
$HTTP["host"] =~ "(^|\.)(pma|(php)?myadmin)\.(local|dev)$" {
  server.document-root = "/usr/share/phpmyadmin"
  server.errorlog = "/var/log/lighttpd/phpmyadmin/error.log"
  accesslog.filename = "/var/log/lighttpd/phpmyadmin/access.log"
  server.error-handler-404 = "/e404.php"
}
```
I know, a bit wicked regexp for the domain name, but I like many ways to Rome.

```
> cat /etc/lighttpd/conf-enabled/50-phpmyadmin.conf
# Alias for phpMyAdmin directory
alias.url += (
        "/phpmyadmin" => "/usr/share/phpmyadmin",
)

# Disallow access to libraries
$HTTP["url"] =~ "^/phpmyadmin/libraries" {
    url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/phpmyadmin/setup/lib" {
    url.access-deny = ( "" )
}

# Limit access to setup script
$HTTP["url"] =~ "^/phpmyadmin/setup" {
        auth.backend = "htpasswd"
        auth.backend.htpasswd.userfile = "/etc/phpmyadmin/htpasswd.setup"
        auth.require = (
                "/" => (
                        "method" => "basic",
                        "realm" => "phpMyAdmin Setup",
                        "require" => "valid-user"
                )
        )
}
```
 so there are a few things disallowed or limited, but only for ^/phpmyadmin, and not the CSS.
When I call it via [ip-address]/phpmyadmin/, the CSS is there - but not on any of my vhosts.
-----
> cd /usr/share/phpmyadmin;sudo cp phpmyadmin.css.php css.php
http://www.myadmin.dev/phpmyadmin.css.php : 404 - not found
http://www.myadmin.dev/css.php : OK
all files in that directory are owned by root:root and have mod 644, the directories are all 755

it also works when I edit css.php to

```
<?php include 'phpmyadmin.css.php'; ?>
```
-----
There are seven scripts altogether that link to phpmyadmin.css.php, hard coded ...

> sudo find ./ -type f -exec sed -i 's/phpmyadmin.css.php/css.php/' {} \;
(and manually edit css.php again to include phpmyadmin.css.php)
... now it also works on the vhosts.

a workaround ... I´ll probably habe to find/sed and edit again after the next myAdmin update ...

so is there a real solution?


----------



## Gorge (Nov 10, 2008)

I just found out ... there are a few more config files ...

/etc/phpmyadmin/config.inc.php includes /var/lib/phpmyadmin/config.inc.php (empty file), and there is nothing about phpmyadmin.css.php in it. Also, it is a php script and very unlikely to cause the 404 response.

/etc/phpmyadmin also contains a lighttpd.conf with the same contents as /etc/lighttpd/conf-enabled/50-phpmyadmin.conf

but ... could this here be a reason?

```
> cat /etc/phpmyadmin/phpmyadmin.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">phpMyAdmin on %h</name>
  <service>
   <type>_http._tcp</type>
   <port>80</port>
   <txt-record>path=/phpmyadmin/</txt-record>
  </service>
</service-group>
```
but then again ... why does it work on http://[ip-address]/phpmyadmin and not on my vhosts?


----------



## Fjandr (Sep 26, 2012)

It's obviously not a filesystem permission problem, since you can workaround using css.php the way you did.

Given that the error is filename-dependent, and only appears when accessed through a vhost, I'd look at the vhost configuration. Maybe there's a regex in a directive therein which is capturing the phpmyadmin.css.php filename and causing access to it to be disallowed.


----------



## Gorge (Nov 10, 2008)

Is there any more vhost configuration apart from the parts I already posted?


----------



## Fjandr (Sep 26, 2012)

After looking through the Lighthttp documentation, it doesn't appear that there is anything more to setting up a vhost conditional.

Well, there are some other things you could try that may or may not narrow down the possibilities. You could copy the contents of phpmyadmin.css.php directly into css.php and see if you get the 404 again. If it still works correctly, try copying css.php back into phpmyadmin.css.php then re-run sed to restore the original calls to phpmyadmin.css.php. I know I said it's not a permission problem, but I could be wrong.

If the above fails, you could try re-creating phpmyadmin.css.php as a symbolic link to css.php. If that works, you'd only have to recopy the contents of phpmyadmin.css.php to css.php and re-create the symbolic link whenever the original file is updated. It would make your workaround a little more permanent and would only require the additional step of running a short shell script to update the hack each time the version is updated.


----------



## Gorge (Nov 10, 2008)

Fjandr said:


> You could copy the contents of phpmyadmin.css.php directly into css.php and see if you get the 404 again.


already tried that (before I had the idea of just including the original file), no 404.


> try copying css.php back into phpmyadmin.css.php then re-run sed to restore the original calls to phpmyadmin.css.php.


just tried that, back to 404.

Guess I´ll just stick with the include workaround and check from time to time until the problem solves itself - or not.

Thanks for the effort everybody!


----------



## Fjandr (Sep 26, 2012)

That's definitely a weird one. At least you have a functional workaround.


----------



## Gorge (Nov 10, 2008)

this bug may be related to my problem:


> from phpMyAdmin / Bugs / #3166 Theme pmahomme-1.0 makes phpmyadmin unusable:
> CSS is broken because phpmyadmin.css.php returns Content-Type Header "text/html" instead of "text/plain" (see attachment).


 I´ll have a look into it should I find the time.


----------



## Gorge (Nov 10, 2008)

I am currently on ubuntu 13.10, lighttpd/1.4.31, phpMyAdmin 4.0.6deb1

tried the solution to bug 3166, but removal of neither theme does solve the problem.

but I did some more ...
downloaded MyAdmin 4.0.9: css works
downloaded MyAdmin 4.0.6: css works
(each to a subdir in my document_root)

rolled back my workaround, created a symbolic link to and a copy of /usr/share/phpmyadmin in my document_root ... (had to add a sym link to usr/share/php in the doc_root to make the copy work; there are some relative sym links in the package)


in both the copy and the symlink, the css was broken but a request on phpmyadmin.css.php worked fine. This made me MAD until I found out that my rollback was not clean. So, I uninstalled and re-installed phpmyadmin and made a new copy. now, in both cases css is ok - yet not on the vhost:

http://pma-vhost.dev/ has broken css
http://pma-vhost.dev/phpmyadmin.css.php results in a 404
BUT I found out by error that
http://pma-vhost.dev/phpmyadmin/phpmyadmin.css.php WORKS

checked my lighttpd.conf, found that the document_root setting for the vhost had no trailing slash. added that, restarted lighty, but still the same behaviour.

At least my workaround has now been reduced to inserting a "phpmyadmin/" in one line of libraries/Header.class.php

Can anyone verify that with lighty? or check with other web servers?


----------



## Gorge (Nov 10, 2008)

P.S.: registration on lighty labs is weird too:

register said "ok"
login said "no"
retrieve password said "I don´t know that address"
registering again sais "username taken, email taken"
:banghead:

is anyone registered there and can post my bug(s)?

can´t that guy just use sourceforge!?!


----------



## Gorge (Nov 10, 2008)

one more: I created a vhost pointing to the copy aaaand ...
- css broken
- /phpmyadmin.css not found
- /phpmyadmin/phpmyadmin.css.php found

and another one: vhost pointing to my document-root
new-vhost.dev/pma-copy/ --> css works !

so far so good ... strange enough. but the next experiments really freaked me out:

I touched a phpmyadmin.css.php in the doc-root of another vhost, requested it and got a 404.
I requested phpmyadmin/phpmyadmin.css.php from that host, but: I did NOT get an empty output. I did not get a 404 either ... I got the output of the real phpmyadmin.css !!!

next step: move the (empty) phpmyadmin.css.php to a subdirectory of that domain. That gave me empty output.

next: created a directory "phpmyadmin" on that domain and moved the empty phpmyadmin.css.php there - original output!

tried that with other vhosts, and on everyone it´s the same: call /phpmyadmin/phpmyadmin.css.php and I get the phpmyadmin stylesheets. :ermm:

I´m scared :hide:


Now it´s even more interesting how that looks on other web servers.


----------



## Gorge (Nov 10, 2008)

more experiments
- edited usr/share/phpmyadmin/phpmyadmin.css.php to verify: that´s the script that´s accessed
- checked the directory "phpmyadmin" on a few vhosts: there´s one on every domain, also on http://192.168.0.xxx ... and when I remove my latter fix for the initiate bug, they also have working css. WICKED
- tried http://other-vhost.dev/php/php-gettext ... that gave me a 404. tried some other subdirectories from /usr/share, all 404. ok.

so ... I have a working and pretty phpMyAdmin everywhere, but not where I want it.
is that a bug or a feature?
and who´s is it?


----------



## Gorge (Nov 10, 2008)

my question on askubuntu has been deleted.
guess this will remain a mystery.


----------



## Fjandr (Sep 26, 2012)

You might want to try asking over at Server Fault. Lots of people there who really know the esoteric issues with Linux server administration.


----------



## Gorge (Nov 10, 2008)

partially solved: the virtual directory can be deactivated by removingtje "alias" directive from /etc/phpmyadmin/lighttpd.conf.
The css bug still remains.


----------

