Ubuntu – Installing phpMyAdmin from repository, 403 Forbidden error

Apache2MySQLPHP

I have installed phpMyAdmin from the repositories, but I get 403 forbidden when I access http://localhost/phpmyadmin/index.php

Apache is running fine, and so is PHP (I'm using apache2-mpm-worker with fcgi, phpinfo() works just fine).

The repository installation for phpMyAdmin has created a folder /etc/phpmyadmin. There is a file apache.conf there, and a symlink to it from /etc/apache2/conf.d/phpmyadmin.conf. It has this content:

root@srvr-test:/etc/apache2/conf.d# cat phpmyadmin.conf
# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php

        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_value include_path .
        </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
</Directory>

The permissions are:

root@srvr-test:/usr/share# ls -la
....
drwxr-xr-x   8 root root  4096 2010-11-22 16:28 phpmyadmin
....

root@srvr-test:/usr/share/phpmyadmin# ls -la
total 1128
drwxr-xr-x   8 root root  4096 2010-11-22 16:28 .
drwxr-xr-x 110 root root  4096 2010-11-22 16:28 ..
-rw-r--r--   1 root root 10829 2010-04-14 05:33 browse_foreigners.php
-rw-r--r--   1 root root  4354 2010-04-14 05:33 bs_change_mime_type.php
-rw-r--r--   1 root root  1797 2010-04-14 05:33 bs_disp_as_mime_type.php
-rw-r--r--   1 root root  2368 2010-04-14 05:33 bs_play_media.php
-rw-r--r--   1 root root   798 2010-04-14 05:33 calendar.php
-rw-r--r--   1 root root  3565 2010-04-14 05:33 changelog.php
-rw-r--r--   1 root root   473 2010-04-14 05:33 chk_rel.php
-rw-r--r--   1 root root   181 2008-12-10 03:00 config.footer.inc.php
....

If I understand correctly, this should work. But it doesn't.
I expected installing from the repositories would be a lot faster. But it doesn't work.
The Ubuntu wiki pages have no information about a 403 Forbidden error.

I'm surprised that this is so difficult… so obviously I'm doing something wrong.
Help! 🙂

Best Answer

Ok, I got it to work. I hope it helps someone by putting it here.

I had to change the /etc/apache2/mods-enabled/fcgid.conf to tell it to use php5-cgi (done already when I asked the question):

root@srvr-test:/etc/apache2/mods-enabled# cat fcgid.conf
<IfModule mod_fcgid.c>
  AddHandler fcgid-script .fcgi .php

  FcgidConnectTimeout 20

  # Where to look for the php.ini file?
  # Maximum requests a process handles before it is terminated
  MaxRequestsPerProcess       1000
  # Maximum number of PHP processes
  MaxProcessCount             10
  # Number of seconds of idle time before a process is terminated
  IPCCommTimeout              240
  IdleTimeout                 240
  #Or use this if you use the file above
  FCGIWrapper /usr/bin/php5-cgi .php

  ServerLimit           500
  StartServers            3
  MinSpareThreads         3
  MaxSpareThreads        10
  ThreadsPerChild        10
  MaxClients            300
  MaxRequestsPerChild  1000

  PHP_Fix_Pathinfo_Enable 1
</IfModule>

Then I had to edit /etc/phpmyadmin/apache.conf to add +ExecCGI in the section:

root@srvr-sandbox1:/etc/phpmyadmin# cat apache.conf
# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks +ExecCGI
        DirectoryIndex index.php
....
Related Question