phpmyadmin throws a 404 on opening

97,611

Solution 1

Maybe it is an apache permission problem. Try to put in your /etc/apache2/sites-available/default the following lines

<Directory /> AllowOverride All </Directory>

and check that the /var/www folders owner is www-data

==================================================================================

Install mysql server: sudo apt-get install mysql-server

Here the installer will ask the mysql-server root password

Install apache 2: sudo apt-get install apache2

Test it: localhost (You must see "It works!" etc)

Install php5: sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Testing it: create the file php_info.php in /var/www/

The content of the file: <?php phpinfo(); ?>

Install php modules: sudo apt-get install php-pear php5-gd php5-xsl curl libcurl3 libcurl3-dev php5-curl

Connect apache 2 and mysql together: sudo apt-get install libapache2-mod-auth-mysql

Install phpmyadmin:

`sudo apt-get install php5-mysql`
`sudo apt-get install phpmyadmin`

Connect php5 with mysql server:

Edit the file /etc/php/apache2/php.ini

Uncomment the following line: extension=mysql.so

Restart apache: service apache2 restart

Try phpmyadmin: localhost/phpmyadmin/

This worked for me many times.

Solution 2

It seems to me that you forgot to tick apache during the phpmyadmin installation screen. You can check if that is the case by checking for the presence of /etc/apache2/conf.d /phpmyadmin file.

You can reconfigure phpmyadmin with the following command:

sudo dpkg-reconfigure phpmyadmin

You will see the following screen:

Choose Web Server

Tick apache (using spacebar), and tab to OK.

Solution 3

I know this is a very old problem, so if you encounter such an error and the above does not help you, this might:

Use this command sudo nano /etc/apache2/apache2.conf to open the file using nano then add the following line:

Include /etc/phpmyadmin/apache.conf

Save and close. Then restart the server. This should work.

Share:
97,611

Related videos on Youtube

SimplySimon
Author by

SimplySimon

Personal details Ex-Lorry Driver, Singer, Poet, Artist, Photographer, Caravanner, programmer, Walker, Reader, Techie, Website Hobbyist &amp; Dad September 2014 saw my beautiful wife and I, selling our house and taking to the roads in a caravan for 4.5 years to 'do Europe' 47 countries accessible by caravan.

Updated on September 18, 2022

Comments

  • SimplySimon
    SimplySimon over 1 year

    I have installed php5 and phpMyAdmin from the Ubuntu Software Centre on a fresh install of Ubuntu 13.04.

    when I enter localhost in my browser the following is displayed:

    It works!

    This is the default web page for this server.

    The web server software is running but no content has been added, yet.

    So something is working.

    if I then type in localhost/phpmyadmin or localhost/phpmyadmin/index.php the page returns a 404 error page, file not found.

    I created a file in /var/www called test.php with one line in it <?php phpinfo(); ?> when I try to access it through my browser, I get 403 Forbidden

    This points to a permissions problem

    with phpMyAdmin I also installed:

    • Apache HTTP Server metapackage (apache2)
    • Base support for JavaScript library packages (javascript-common)
    • Fast webserver with minimal memory footprint (lighttpd)
    • MySQL Client (mysql-client)
    • GD module for php5 (php5-gd)
    • MySQL Server (mysql-server)

    When installing phpMyAdmin, I was not asked any questions, which I found interesting as on previous installs, I have been asked to choose a server.

    The folder /etc/phpmyadmin has the following content:

    • conf.d/
    • config-db.php.ucf-dist

    The folder conf.d has no content

    Is there something I need to install which I haven't or is there something I can do to fix the 404 & 403 errors?

    Edit

    owners in /var

    :/var$ ls -lh
    total 48K
    drwxr-xr-x  2 root root     4.0K Jun  9 12:16 backups
    drwxr-xr-x 21 root root     4.0K Jun  9 13:28 cache
    drwxrwsrwt  2 root whoopsie 4.0K Jun  9 16:01 crash
    drwxr-xr-x 73 root root     4.0K Jun  8 19:24 lib
    drwxrwsr-x  2 root staff    4.0K Apr 19 10:03 local
    lrwxrwxrwx  1 root root        9 Jun  9 16:00 lock -> /run/lock
    drwxr-xr-x 20 root root     4.0K Jun  9 16:01 log
    drwxrwsr-x  2 root mail     4.0K Apr 24 18:01 mail
    drwxrwsrwt  2 root whoopsie 4.0K Apr 24 18:05 metrics
    drwxr-xr-x  2 root root     4.0K Apr 24 18:01 opt
    lrwxrwxrwx  1 root root        4 Jun  9 16:00 run -> /run
    drwxr-xr-x 10 root root     4.0K Jun  8 19:41 spool
    drwxrwxrwt  4 root root     4.0K Jun  9 16:25 tmp
    drwxr-xr-x  2 www-data www-data     4.0K Jun  7 21:04 www
    

    and:

    ...:/var$ ls -lh /var/www
    total 12K
    -rw-r--r-- 1 www-data www-data  177 Jun  7 20:30 index.html
    -rw-r--r-- 1 www-data www-data 3.5K Jun  7 20:30 index.lighttpd.html
    -rw-r--r-- 1 www-data www-data   20 Jun  7 21:04 test.php
    -rw-r--r-- 1 www-data www-data    0 Jun  7 21:04 test.php~
    

    on restarting the apache2 service I get the following in Terminal

    simon@simon-VGN-AR71E:~$ sudo service apache2 restart
    apache2: Syntax error on line 260 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf.d/phpmyadmin.conf: No such file or directory
    Action 'configtest' failed.
    The Apache error log may have more information.
       ...fail!
    

    i renamed phpmyadmin.conf link and ran

    sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
    

    see the broken link symbol in nautilus:

    enter image description here

    simon@simon-VGN-AR71E:~$ ls -lh /etc/apache2/conf.d
    total 16K
    -rw-r--r-- 1 root root  269 Jul 16  2012 charset
    lrwxrwxrwx 1 root root   45 Jun  7 21:14 javascript-common.conf -> /etc/javascript-common/javascript-common.conf
    -rw-r--r-- 1 root root 3.3K Jul 16  2012 localized-error-pages
    -rw-r--r-- 1 root root  143 Jul 16  2012 other-vhosts-access-log
    lrwxrwxrwx 1 root root   28 Jun  9 17:28 phpmyadmin.conf -> ../../phpmyadmin/apache.conf
    -rw-r--r-- 1 root root 1.7K Jul 16  2012 security
    

    END===================================

    • Debashish Das
      Debashish Das over 9 years
      Did you add this to /etc/apache2/apache2.conf? Include /etc/phpmyadmin/apache.conf
  • SimplySimon
    SimplySimon almost 11 years
    Thanks for that,I changed the existing AllowOverride none with AllowOverride All no change, still 404. How do I find out the owner of a folder or file?
  • C1sc0
    C1sc0 almost 11 years
    For example with ls -lh
  • SimplySimon
    SimplySimon almost 11 years
    ls -lh reports drwxr-xr-x 2 root root 4.0K Jun 7 21:04 www
  • C1sc0
    C1sc0 almost 11 years
    Try to edit your default file in sites-available folder and put the bottom, after </VirtualHost> the following Alias phpmyadmin /usr/share/phpmyadmin
  • SimplySimon
    SimplySimon almost 11 years
    I have added the details to the bottom of the question. chown makes all files in www www-data
  • SimplySimon
    SimplySimon almost 11 years
    Alias phpmyadmin /usr/share/phpmyadmin added, no change or do I need to restart the service?
  • C1sc0
    C1sc0 almost 11 years
    Exactly :) sudo service apache2 restart
  • SimplySimon
    SimplySimon almost 11 years
    That's done and added the error I received to the bottom of the question. I'll try rebooting.
  • C1sc0
    C1sc0 almost 11 years
    run, the following sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
  • SimplySimon
    SimplySimon almost 11 years
    I get ln: failed to create symbolic link ‘/etc/apache2/conf.d/phpmyadmin.conf’: File exists after I complete this. It still doesn't work!
  • Nemo
    Nemo almost 11 years
    Try restarting apache (sudo service apache2 restart)
  • SimplySimon
    SimplySimon almost 11 years
    I get ln: failed to create symbolic link ‘/etc/apache2/conf.d/phpmyadmin.conf’: File exists, still not working :(
  • SimplySimon
    SimplySimon almost 11 years
    Added the nautilus screenshot to bottom of the question.
  • SimplySimon
    SimplySimon almost 11 years
    I tried that, see the edit at the bottom of the original question
  • C1sc0
    C1sc0 almost 11 years
    Maybe the www-data user don't have a read permission to the link, can you paste me the result of: sudo ln -lh /etc/apache2/conf.d
  • SimplySimon
    SimplySimon almost 11 years
    ln -lh give ln: invalid option -- 'l'
  • C1sc0
    C1sc0 almost 11 years
    Ohh, sorry, sudo ls -lh /etc/apache2/conf.d
  • SimplySimon
    SimplySimon almost 11 years
    Placed at the bottom of the question.
  • C1sc0
    C1sc0 almost 11 years
    At the beginning you created a file test.php, that works or still throws 403?
  • C1sc0
    C1sc0 almost 11 years
    You are welcome, try to remove phpmyadmin and install it from source.
  • SimplySimon
    SimplySimon almost 11 years
    I'll do that now. I'll get back to you.
  • C1sc0
    C1sc0 almost 11 years
    I have added a description to the bottom of my answer. Before you start the process remove all installed packages what you already installed (with apt-get remove packagename)
  • Jason Southwell
    Jason Southwell almost 11 years
    These are too many comments, and this discussion would be better suited for chat.
  • Nemo
    Nemo almost 11 years
    At this point, I'd probably download phpmyadmin and unzip it in /var/www/
  • khaled_webdev
    khaled_webdev about 10 years
    it's working for me by doing project.local/phpmyadmin after doing what exist in official ubuntu site by addin the including path to apache2/apache2.conf and the symolic links
  • nahtnam
    nahtnam about 10 years
    Thanks a lot! I forgot to tick the apache2 while installation with tasksel.
  • Miro
    Miro over 9 years
    You're golden. Why is this not ticked by default and why does it let you proceed without making a choice?
  • Suraj
    Suraj about 9 years
    During initial installation, I kind of pressed <ENTER> instead of <SPACE> to select Apache2, and the window disappeared.
  • Ejaz
    Ejaz over 7 years
    AAHAAA!!! I was about to remove and reinstall phpmyadmin. Thanks a lot.
  • athi
    athi over 4 years
    This worked for me! Thanks
  • Teshan Nanayakkara
    Teshan Nanayakkara over 4 years
    Worked for me too
  • Rohit
    Rohit about 4 years
    Really, its worked for me
  • divHelper11
    divHelper11 over 3 years
    Thats the solution for me!
  • paddyg
    paddyg over 3 years
    Also worked for me!
  • Barney Chambers
    Barney Chambers over 3 years
    Nice this worked for me, can anyone explain what exactly happened here?
  • AntonyMN
    AntonyMN over 3 years
    This is because you skipped some steps while installing phpmyadmin. When you were supposed to apply apache2, you supposed to select using spacebar, press tab to move the cursor to ok, then press enter. If you didn't do this, this is short code to link phpmyadmin with apache2.
  • Admin
    Admin almost 2 years
    worked for me, on windows 11 wsl2 ubuntu apache2. And I did select using spacebar tab etc as suggested by @AntonyMN, at least it looked like I did on screen...