MacOS – Sierra – Apache localhost user level and phpMyAdmin

apachemacosMySQLwebserver

I've installed the AMP stack (Apache, MySQL, PHP) and phpMyAdmin on my system.
I set up user level root too (localhost/~user) and it worked.

The things that make me still confused are:

  • Why is it forbidden to access system level root (http://localhost/) now?
  • And if I want to use phpMyAdmin on my user level site (http://localhost/~user/) should I install it again on my localhost/~user?

Best Answer

The "Forbidden" (error 403) error message is something that's generated by the Apache web server

enter image description here


What you need to check in your httpd.conf (or related files) that:

  • Your global Directory has Options -Indexes (this prevents the server from showing an index of the directory and file structure in the absence of an index.htm or index.html file. Having this option set and no index.htm file will cause this 403 message to be generated.

  • You have the line DirectoryIndex index.html index.php specified. This will ensure it automatically opens either file name upon entering the directory. You also want to make sure you have an index.html or an index.php file in the directory.

If you want to test out your PHP installation, there's a small piece of code you can put into an index.php file (you can name it anything you want, but it must end with .php).

<?php  
   phpinfo(); 
?>

When you point your browser to localhost you should now see (your settings will vary of course):

enter image description here

phpMyAdmin

As for phpMyAdmin, you can put this anywhere. You can put it in your users directory (not recommended if you have multiple users that need to use it) or your can create a port based virtual host so that it will be available only if someone knows which port it's listening on. Have a look at the Apache documentation to see examples and explanations.

Also, you might want to have a look at Adminer instead of phpMyAdmin. I have found it much easier to deploy and much more robust.