# phpmyadmin gives a directory listing

## thecooptoo

ive got phpwebsite working and want to compare phpnuke on different virtual hosts.

Got into problems importing the database fields so emerged phpmyadmin.

Going to http://server/phpmyadmin gives me a directory listing.

Ive chmoded everything in phpmyadmin (and the symlink) to apache:apache 

router etc # cat /commonapache2.conf |grep AddType

# AddType allows you to tweak mime.types without actually #editing it, or to

AddType application/x-tar .tgz

AddType image/x-icon .ico

#AddType application/x-httpd-php .php

AddType application/x-httpd-php .php .inc

##    AddType text/html .shtml

---------------------------------------------------------

dont know why i get a directory listing instead of the phpmyadmin interface

----------

## Chris W

This is not a permissions issue: all the phpmyadmin files should be owned by root and readable by the apache user either through group or other permissions.

It's far more likely that it's an Apache configuration issue to do with your virtual host(s).  The mod_php configuration is installed at emerge time and is enabled with:

```
APACHE2_OPTS="-D SSL -D PHP4"
```

in /etc/conf.d/apache2.  /etc/apache2/conf/modules.d/70_mod_php.conf contains the AddType commands you have inserted manually.  There should be no need to modify commonapache2.conf to accomodate PHP.  If that hasn't helped then you may need to answer a few questions: Is phpwebsite running in the default host or a vhost?  How are the vhosts defined?

----------

## thecooptoo

router / # cat  /etc/conf.d/apache2 |grep OPTS

APACHE2_OPTS="-D PHP4"

router / #

router / # cat /etc/apache2/conf/modules.d/70_mod_php.conf |grep AddType

        AddType application/x-httpd-php .php

        AddType application/x-httpd-php .phtml

        AddType application/x-httpd-php .php3

        AddType application/x-httpd-php .php4

        AddType application/x-httpd-php-source .phps

router / #

phpwebsite is running in a virtual host

myphpadmin in the default.

(FWIW I can get to all the mySQL DBs with webmin)

vhosts defined in vhosts.conf, using a client /etc/hosts to redirect it for the LAN 

<VirtualHost *>

ServerName server1.dyndns.org

DocumentRoot /var/www/server1/htdocs

ScriptAlias /cgi-bin/ /home/server1/cgi-bin/

</VirtualHost>

ExecCGI in the main commonapache2.conf

----------

## deeppro

Did you put this in you httpd.conf file ???

```
  DirectoryIndex index.html index.htm  index.php index.php3 index.php4

```

i think you have the same without the "index.php index.php3" so it cannot load index.php when you link trought "http://serveur/phpmyadmin"

hope to help you

----------

## thecooptoo

router root # cat  -n /etc/apache2/conf/commonapache2.conf |grep DirectoryIndex

   145  ### DirectoryIndex: Name of the file or files to use as a pre-written HTML

   149      DirectoryIndex index.html index.html.var index.php index.php3 index.php4 index.shtml index.cgi index.pl index.htm Default.htm default.htm

router root #

ive added  index.php4 to directory index, restarted apache 

still get directory listing

----------

## deeppro

what's the permission for the files ?

first:

drwxr-xr-x    7 52400    24067        4096 Dec 28 19:05 phpmyadmin

and within this:

deeppro@Acer htdocs $ ls -al /usr/local/apache/htdocs/phpmyadmin/

total 1600

drwxr-xr-x    7 52400    24067        4096 Dec 28 19:05 .

drwxr-xr-x    5 root     root         4096 Dec 29 13:14 ..

-rw-r--r--    1 52400    24067         173 Nov 18 16:20 CREDITS

-rw-r--r--    1 52400    24067      169344 Dec 28 19:00 ChangeLog

-rw-r--r--    1 52400    24067      160934 Dec 28 19:03 Documentation.html

-rw-r--r--    1 52400    users      134180 Dec 28 19:05 Documentation.txt

-rw-r--r--    1 52400    24067         183 Nov 18 16:20 INSTALL

-rw-r--r--    1 52400    24067       15237 Nov 18 16:20 LICENSE

-rw-r--r--    1 52400    24067        2866 Dec 28 19:04 README

-rw-r--r--    1 52400    24067          29 Dec 28 19:05 RELEASE-DATE-2.5.5

-rw-r--r--    1 52400    24067         239 Nov 18 16:20 TODO

-rw-r--r--    1 52400    24067        7558 Dec  4 17:09 browse_foreigners.php

-rw-r--r--    1 52400    24067         475 Nov 26 23:52 chk_rel.php

-rw-r--r--    1 52400    24067       35174 Dec 30 23:06 config.inc.php

drwxr-xr-x    2 52400    24067        4096 Dec 28 19:05 css

-rw-r--r--    1 52400    24067         878 Nov 26 23:52 db_create.php

-rw-r--r--    1 52400    24067       10131 Dec 22 20:37 db_datadict.php

-rw-r--r--    1 52400    24067        9329 Dec 11 12:11 db_details.php

-rw-r--r--    1 52400    24067        1842 Nov 26 23:52 db_details_common.php

-rw-r--r--    1 52400    24067        2739 Nov 26 23:52 db_details_db_info.php

-rw-r--r--    1 52400    24067        1940 Nov 26 23:52 db_details_export.php

-rw-r--r--    1 52400    24067       13273 Nov 26 23:52 db_details_importdocsql.php

-rw-r--r--    1 52400    24067        2166 Nov 22 21:51 db_details_links.php

-rw-r--r--    1 52400    24067       37148 Nov 26 23:52 db_details_qbe.php

-rw-r--r--    1 52400    24067       29077 Dec 11 11:29 db_details_structure.php

-rw-r--r--    1 52400    24067       10743 Dec 22 20:41 db_printview.php

-rw-r--r--    1 52400    24067       14167 Nov 26 23:52 db_search.php

-rw-r--r--    1 52400    24067        2817 Nov 18 16:20 docs.css

-rw-r--r--    1 52400    24067       19188 Dec 12 12:13 export.php

-rw-r--r--    1 52400    24067        6930 Nov 26 23:52 footer.inc.php

-rw-r--r--    1 52400    24067        6666 Nov 26 23:52 header.inc.php

-rw-r--r--    1 52400    24067        2448 Dec 11 12:05 header_printview.inc.php

drwxr-xr-x    2 52400    24067        4096 Dec 28 19:05 images

-rw-r--r--    1 52400    24067        5036 Nov 26 23:52 index.php

drwxr-xr-x    2 52400    24067        4096 Dec 28 19:05 lang

-rw-r--r--    1 52400    24067        5532 Nov 26 23:52 ldi_check.php

-rw-r--r--    1 52400    24067        7389 Nov 26 23:52 ldi_table.php

-rw-r--r--    1 52400    24067       37278 Dec  9 14:38 left.php

drwxr-xr-x    7 52400    24067        4096 Dec 28 19:05 libraries

-rw-r--r--    1 52400    24067       24101 Dec  9 16:06 main.php

-rw-r--r--    1 52400    24067        9747 Dec  4 17:09 mult_submits.inc.php

-rw-r--r--    1 52400    24067       24291 Nov 26 23:52 pdf_pages.php

-rw-r--r--    1 52400    24067       51852 Nov 26 23:52 pdf_schema.php

-rw-r--r--    1 52400    24067         416 Nov 26 23:52 phpinfo.php

-rw-r--r--    1 52400    24067        3865 Nov 26 23:52 queryframe.php

-rw-r--r--    1 52400    24067       16487 Nov 26 23:52 querywindow.php

-rw-r--r--    1 52400    24067       13660 Dec 15 19:13 read_dump.php

drwxr-xr-x    2 52400    24067        4096 Dec 28 19:05 scripts

-rw-r--r--    1 52400    24067        3355 Nov 26 23:52 server_collations.php

-rw-r--r--    1 52400    24067        1010 Nov 26 23:52 server_common.inc.php

-rw-r--r--    1 52400    24067       17990 Nov 26 23:52 server_databases.php

-rw-r--r--    1 52400    24067        1877 Nov 26 23:52 server_export.php

-rw-r--r--    1 52400    24067        1437 Nov 26 23:52 server_links.inc.php

-rw-r--r--    1 52400    24067       91195 Nov 26 23:52 server_privileges.php

-rw-r--r--    1 52400    24067        3742 Nov 26 23:52 server_processlist.php

-rw-r--r--    1 52400    24067       14447 Nov 26 23:52 server_status.php

-rw-r--r--    1 52400    24067        2642 Nov 26 23:52 server_variables.php

-rw-r--r--    1 52400    24067       32842 Dec 11 12:15 sql.php

-rw-r--r--    1 52400    24067        9339 Nov 26 23:52 tbl_addfield.php

-rw-r--r--    1 52400    24067        8618 Nov 26 23:52 tbl_alter.php

-rw-r--r--    1 52400    24067       39567 Dec 11 14:43 tbl_change.php

-rw-r--r--    1 52400    24067        8324 Nov 26 23:52 tbl_create.php

-rw-r--r--    1 52400    24067       20410 Nov 26 23:52 tbl_indexes.php

-rw-r--r--    1 52400    24067       20944 Nov 26 23:52 tbl_move_copy.php

-rw-r--r--    1 52400    24067       22559 Nov 26 23:52 tbl_printview.php

-rw-r--r--    1 52400    24067       26893 Nov 26 23:52 tbl_properties.inc.php

-rw-r--r--    1 52400    24067         617 Nov 26 23:52 tbl_properties.php

-rw-r--r--    1 52400    24067        1019 Nov 26 23:52 tbl_properties_common.php

-rw-r--r--    1 52400    24067        2002 Nov 26 23:52 tbl_properties_export.php

-rw-r--r--    1 52400    24067        2820 Nov 26 23:52 tbl_properties_links.php

-rw-r--r--    1 52400    24067       21971 Nov 26 23:52 tbl_properties_operations.php

-rw-r--r--    1 52400    24067       32429 Nov 26 23:52 tbl_properties_structure.php

-rw-r--r--    1 52400    24067        1739 Nov 26 23:52 tbl_properties_table_info.php

-rw-r--r--    1 52400    24067       20831 Nov 26 23:52 tbl_query_box.php

-rw-r--r--    1 52400    24067       23176 Nov 26 23:52 tbl_relation.php

-rw-r--r--    1 52400    24067        4017 Nov 26 23:52 tbl_rename.php

-rw-r--r--    1 52400    24067       10990 Dec 15 22:41 tbl_replace.php

-rw-r--r--    1 52400    24067        9030 Dec 11 14:43 tbl_replace_fields.php

-rw-r--r--    1 52400    24067        2980 Dec  4 18:25 tbl_row_delete.php

-rw-r--r--    1 52400    24067       12092 Nov 26 23:52 tbl_select.php

-rw-r--r--    1 52400    24067        4013 Nov 26 23:52 transformation_wrapper.php

-rw-r--r--    1 52400    24067       43072 Dec 28 19:03 translators.html

-rw-r--r--    1 52400    24067        4767 Nov 26 23:52 user_password.php

deeppro@Acer htdocs $

this works fine and so you have php site running, that cannot be a configuration mistake from your http server (apache)

----------

## Chris W

Not that I think this is the problem...   Is your cgi-bin directory deliberately outside the document root?  

Do you have a NameVirtualHost directive anywhere?  There's a commented out NameVirtualHost in /etc/apache2/conf/vhosts/vhosts.conf on my default Apache 2 install.  This directive enables name based virtual hosting.  

There's some Apache 2 doco goodness here: Name-based Virtual Host Support

----------

## thecooptoo

the cgi-bin is where it was before they changed the default apache install.

I'll move it sometime soon.

router htdocs # ls -l |grep php

drwxr-xr-x    7 apache   apache       4096 Dec 31 21:13 phpmyadmin

drwxrwxrwx   16 apache   apache       4096 Dec 19 21:27 phpwebsite

total 1384

-rw-r--r--    1 apache   apache     145679 Dec 31 21:13 ChangeLog

-rw-r--r--    1 apache   apache     157105 Dec 31 21:13 Documentation.html

-rw-r--r--    1 apache   apache      15237 Dec 31 21:13 LICENSE

-rw-r--r--    1 apache   apache       2844 Dec 31 21:13 README

-rw-r--r--    1 apache   apache       2031 Dec 31 21:13 badwords.txt

-rw-r--r--    1 apache   apache       7285 Dec 31 21:13 browse_foreigners.php

-rw-r--r--    1 apache   apache        463 Dec 31 21:13 chk_rel.php

lrwxrwxrwx    1 apache   apache         30 Dec 31 21:13 config.inc.php -> /etc/p

hpmyadmin/config.inc.php

drwxr-xr-x    2 apache   apache       4096 Dec 31 21:13 css

-rw-r--r--    1 apache   apache       1031 Dec 31 21:13 db_create.php

-rw-r--r--    1 apache   apache      10759 Dec 31 21:13 db_datadict.php

-rw-r--r--    1 apache   apache       9216 Dec 31 21:13 db_details.php

-rw-r--r--    1 apache   apache       1975 Dec 31 21:13 db_details_common.php

-rw-r--r--    1 apache   apache       3357 Dec 31 21:13 db_details_db_info.php

-rw-r--r--    1 apache   apache       1994 Dec 31 21:13 db_details_export.php

-rw-r--r--    1 apache   apache      14139 Dec 31 21:13 db_details_importdocsql.

php

-rw-r--r--    1 apache   apache       2160 Dec 31 21:13 db_details_links.php

-rw-r--r--    1 apache   apache      38172 Dec 31 21:13 db_details_qbe.php

-rw-r--r--    1 apache   apache      32990 Dec 31 21:13 db_details_structure.php

-rw-r--r--    1 apache   apache      12168 Dec 31 21:13 db_printview.php

-rw-r--r--    1 apache   apache      14163 Dec 31 21:13 db_search.php

-rw-r--r--    1 apache   apache       2816 Dec 31 21:13 docs.css

-rw-r--r--    1 apache   apache      19301 Dec 31 21:13 export.php

-rw-r--r--    1 apache   apache       6613 Dec 31 21:13 footer.inc.php

-rw-r--r--    1 apache   apache       7439 Dec 31 21:13 header.inc.php

-rw-r--r--    1 apache   apache       2301 Dec 31 21:13 header_printview.inc.php

drwxr-xr-x    2 apache   apache       4096 Dec 31 21:13 images

-rw-r--r--    1 apache   apache       5155 Dec 31 21:13 index.php

drwxr-xr-x    2 apache   apache       4096 Dec 31 21:13 lang

-rw-r--r--    1 apache   apache       6289 Dec 31 21:13 ldi_check.php

-rw-r--r--    1 apache   apache       7425 Dec 31 21:13 ldi_table.php

-rw-r--r--    1 apache   apache      37101 Dec 31 21:13 left.php

drwxr-xr-x    7 apache   apache       4096 Dec 31 21:13 libraries

-rw-r--r--    1 apache   apache      24114 Dec 31 21:13 main.php

-rw-r--r--    1 apache   apache       9833 Dec 31 21:13 mult_submits.inc.php

-rw-r--r--    1 apache   apache      24040 Dec 31 21:13 pdf_pages.php

-rw-r--r--    1 apache   apache      53207 Dec 31 21:13 pdf_schema.php

-rw-r--r--    1 apache   apache        408 Dec 31 21:13 phpinfo.php

-rw-r--r--    1 apache   apache       3854 Dec 31 21:13 queryframe.php

-rw-r--r--    1 apache   apache      16433 Dec 31 21:13 querywindow.php

-rw-r--r--    1 apache   apache      14179 Dec 31 21:13 read_dump.php

drwxr-xr-x    2 apache   apache       4096 Dec 31 21:13 scripts

-rw-r--r--    1 apache   apache       3470 Dec 31 21:13 server_collations.php

-rw-r--r--    1 apache   apache       1152 Dec 31 21:13 server_common.inc.php

-rw-r--r--    1 apache   apache      18035 Dec 31 21:13 server_databases.php

-rw-r--r--    1 apache   apache       1892 Dec 31 21:13 server_export.php

-rw-r--r--    1 apache   apache       1482 Dec 31 21:13 server_links.inc.php

-rw-r--r--    1 apache   apache      95206 Dec 31 21:13 server_privileges.php

-rw-r--r--    1 apache   apache       3772 Dec 31 21:13 server_processlist.php

-rw-r--r--    1 apache   apache      14476 Dec 31 21:13 server_status.php

-rw-r--r--    1 apache   apache       2648 Dec 31 21:13 server_variables.php

-rw-r--r--    1 apache   apache      32588 Dec 31 21:13 sql.php

-rw-r--r--    1 apache   apache       9553 Dec 31 21:13 tbl_addfield.php

-rw-r--r--    1 apache   apache       8930 Dec 31 21:13 tbl_alter.php

-rw-r--r--    1 apache   apache      34076 Dec 31 21:13 tbl_change.php

-rw-r--r--    1 apache   apache       8680 Dec 31 21:13 tbl_create.php

-rw-r--r--    1 apache   apache      20718 Dec 31 21:13 tbl_indexes.php

-rw-r--r--    1 apache   apache      20727 Dec 31 21:13 tbl_move_copy.php

-rw-r--r--    1 apache   apache      23121 Dec 31 21:13 tbl_printview.php

-rw-r--r--    1 apache   apache      27051 Dec 31 21:13 tbl_properties.inc.php

-rw-r--r--    1 apache   apache        616 Dec 31 21:13 tbl_properties.php

-rw-r--r--    1 apache   apache       1145 Dec 31 21:13 tbl_properties_common.ph                                            p

-rw-r--r--    1 apache   apache       1993 Dec 31 21:13 tbl_properties_export.ph                                            p

-rw-r--r--    1 apache   apache       2833 Dec 31 21:13 tbl_properties_links.php

-rw-r--r--    1 apache   apache      22851 Dec 31 21:13 tbl_properties_operation                                            s.php

-rw-r--r--    1 apache   apache      32817 Dec 31 21:13 tbl_properties_structure                                            .php

-rw-r--r--    1 apache   apache       2248 Dec 31 21:13 tbl_properties_table_inf                                            o.php

-rw-r--r--    1 apache   apache      20737 Dec 31 21:13 tbl_query_box.php

-rw-r--r--    1 apache   apache      22650 Dec 31 21:13 tbl_relation.php

-rw-r--r--    1 apache   apache       3922 Dec 31 21:13 tbl_rename.php

-rw-r--r--    1 apache   apache       7410 Dec 31 21:13 tbl_replace.php

-rw-r--r--    1 apache   apache       8505 Dec 31 21:13 tbl_replace_fields.php

-rw-r--r--    1 apache   apache       1445 Dec 31 21:13 tbl_row_delete.php

-rw-r--r--    1 apache   apache      11902 Dec 31 21:13 tbl_select.php

-rw-r--r--    1 apache   apache       4072 Dec 31 21:13 transformation_wrapper.p                                            hp

-rw-r--r--    1 apache   apache      42256 Dec 31 21:13 translators.html

-rw-r--r--    1 apache   apache       4753 Dec 31 21:13 user_password.php

router phpmyadmin #

----------

## supenguin

I think your index.php needs to be executable by whatever user owns the apache process. Hmm. You should get some kind of permission denied error with your current settings. 

Also I've heard from multiple people that phpnuke is prone to getting hacked very easily. You may want to look into alternatives.

----------

## Chris W

The ownership of files in htdocs should, as a general rule, NOT be apache:apache.   Index.php does not need to be executable.  The permissions in the phpmyadmin directory should be (extract only): 

```

chrisw@ptolemy phpmyadmin $ pwd

/var/www/localhost/htdocs/phpmyadmin

chrisw@ptolemy phpmyadmin $ ls -al

total 1281

drwxr-xr-x    7 root     root         2048 Nov 28 18:13 .

drwxr-xr-x    9 apache   apache       2048 Dec 31 10:07 ..

-rw-r--r--    1 root     root       145679 Nov 28 18:13 ChangeLog

-rw-r--r--    1 root     root       157105 Nov 28 18:13 Documentation.html

-rw-r--r--    1 root     root        15237 Nov 28 18:13 LICENSE

-rw-r--r--    1 root     root         2844 Nov 28 18:13 README

-rw-r--r--    1 root     root         2031 Nov 28 18:13 badwords.txt

-rw-r--r--    1 root     root         7285 Nov 28 18:13 browse_foreigners.php

-rw-r--r--    1 root     root          463 Nov 28 18:13 chk_rel.php

lrwxrwxrwx    1 root     root           30 Nov 28 18:13 config.inc.php -> /etc/phpmyadmin/config.inc.php

drwxr-xr-x    2 root     root         1024 Nov 28 18:13 css

-rw-r--r--    1 root     root         1031 Nov 28 18:13 db_create.php

-rw-r--r--    1 root     root        10759 Nov 28 18:13 db_datadict.php

-rw-r--r--    1 root     root         9216 Nov 28 18:13 db_details.php

-rw-r--r--    1 root     root         1975 Nov 28 18:13 db_details_common.php

-rw-r--r--    1 root     root         3357 Nov 28 18:13 db_details_db_info.php

...
```

 which is the result of a default emerge.   Two config files in /etc/phpmyadmin are: 

```
chrisw@ptolemy phpmyadmin $ ls -la /etc/phpmyadmin/

total 48

drwxr-xr-x    2 root     root         4096 Nov 28 18:13 .

drwxr-xr-x   62 root     root         4096 Jan  2 12:20 ..

-rw-r-----    1 root     apache      34398 Nov 28 18:13 config.inc.php

-rw-r-----    1 root     apache       3240 Nov 28 18:13 mysql-setup.sql
```

The issue is not one of phpmyadmin file permissions - it is one of Apache configuration.  Have you checked for the NameVirtualHost directive as described above?  Have you created a vhost to replace the default host that has been overidden by enabling the vhosts functionality?  From the doco linked above:  *Quote:*   

> Main host goes away
> 
> If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName
> 
>  and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first
> ...

 

You could try postnuke (no ebuild AFAIK) as an alternative to phpnuke.

----------

## thecooptoo

i gave up trying to configure it in /home/httpd/htdocs/phpmyadmin and re-emerged it, left it in /var/www/localhost/htdocs and changed the virtualhost configuration with an entry in my local /etc/hosts.

http://localserver/phpmyadmin

now asks me for a username and password 

when i enter 'root' and my root password 

or  'root' and my sql password ( set up /etc/mysql/my.cnf

with each I get 

Server localhost

Error

MySQL said:

#1045 - Access denied for user: 'pma@localhost' (Using password: YES)

so how do i get in ?

----------

## Chris W

The MySQL user 'pma' does not have privileges in the database pmadb.  Did you complete the phpmyadmin install per the instructions? 

```
To complete installation, you must

1. Update your configuration files:

     etc-update

2. Update MySQL's grant tables and the pmadb database:

     ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config

3. Reload MySQL:

     /etc/init.d/mysql restart

If you are upgrading from an earlier version and are using phpMyAdmin's

features for master/foreign tables be sure to read

  http://localhost/phpmyadmin/Documentation.html#col_com

You will need to perform the ALTER TABLE step yourself. 
```

----------

## thecooptoo

did the update stuff after the emerge

with webmin  I can see the databases + pmadb with tables in it.

in the users  ive got a

user  pma

hosts localhost

encrypted pw .........

permissions none

IFIAK i didnt set it up. No ide wher the PW came from. 

I coule delete the user 'pma and then recreate it with a know pw and the relevant permissions

----------

## Chris W

You can use the SQL in /usr/portage/dev-db/phpmyadmin/files/phpmyadmin-mysql-setup.sql.in to setup the user.  You'll need to substute the password of your choice.

----------

## deeppro

you need to add permissions to your user...

without these you can do nothing with your mysql server ...

----------

## thecooptoo

added a passwod to the config file adn re-emerged phpmyadmin 

directory listing again...

Must be an apache problem.........

----------

## deeppro

personnaly, i don't use apache from the portage, i prefer to compile it myself and i don't use the apache2 ... I had some mistakes with the one from the portage tree....

----------

