Forbidden You don't have permission to access /phpmyadmin on this server

I installed php, mysql, phpmyadmin on my Ubuntu 12.04 localhost in the following steps:

I try these steps:

sudo apt-get install apache2
sudo /etc/init.d/apache2 restart
sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install php5-cli
sudo apt-get install php5-cgi
sudo apt-get install php5-mysql
sudo apt-get install php5-pgsql
sudo /etc/init.d/apache2 restart

than after i faced phpmyadmin not found error and fixed using the following answer

How to solve the phpmyadmin not found issue after upgrading php and apache?

After applying that fix I got another error message:

Forbidden  You don't have permission to access /phpmyadmin on this server.

How can fix this?


Solution 1:

It solved :

sudo apt-get install mysql-server
sudo dpkg-reconfigure phpmyadmin
sudo service apache2 restart

Solution 2:

You need to change the permission with:

sudo chown -R $USER:$USER /var/www/  
sudo chmod -R 755 /var/www 

Solution 3:

  1. You should check /etc/apache2 and find the below lines:

    <Directory /usr/share>
        AllowOverride None
        Require all granted
    </Directory>
    
  2. the apache2 config should have this line:

    Include /etc/phpmyadmin/apache.conf
    
  3. Be you you phpadmin config look like this:

    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_admin_flag allow_url_fopen Off
            php_value include_path .
            php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
            php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/
       </IfModule>
    </Directory>
    
    <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>
    
    <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>