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 .


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

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

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! :)

  • Does the page prompt you for a password when trying to access it? – Nick Pascucci Nov 23 '10 at 3:11
  • What are the permissions and ownership on /usr/share/phpmyadmin/? – Marco Ceppi Nov 23 '10 at 3:21
  • @codeMonk: No password prompt. @Marco Ceppi: edited my post with permissions info. – UrkoM Nov 23 '10 at 3:51
  • Have you added anyone to the AuthUserFile? – Nick Pascucci Nov 23 '10 at 3:57
  • Content of that file, as default, is admin:* – UrkoM Nov 23 '10 at 4:00

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

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
  • If you got the solution then please mark the question as answered. – aneeshep Nov 23 '10 at 15:40
  • Yeah, but since I answered the question myself, AskUbuntu.com forces me to wait before marking it as answered. I'll mark it as answered as soon as I can. – UrkoM Nov 24 '10 at 4:24

How did you install this?

The simplest way is to use the terminal and type the following...

apt-get install phpmyadmin

During the installation process, it will prompt you for a few variables. After it is finished, it should have setup all the permissions, ownerships and symbolic links for you, and you should be able to access it via http://localhost/phpmyadmin/ (unless of course you changed the name of your server from "localhost").

403 typically means the folder doesn't have the correct ownership and / or permissions for apache to execute the files inside.

  • That's what I did, but as mentioned in the question, I am not using mod_php5. If I was, it would probably work right away. With mod_fcgid, it doesn't. It needs the +ExecCGI addition. What I think was happening is that it wouldn't send the index.php file to the php5 cgi handler, and instead would try to show it. But then the permissions would trigger, and not let you do that. – UrkoM Nov 24 '10 at 4:22

I know this is a very old thread, but just in case someone finds it like I did.

sudo chown -R www-data /var/www/phpmyadmin

worked for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.