MacOS Sierra下localhost/phpmyadmin访问404问题求助
Alright, let's break this down—you're hitting a classic Apache DocumentRoot vs. external directory issue, and yes, it's absolutely a configuration problem. Here are two solid fixes to get phpMyAdmin accessible at localhost/phpmyadmin:
Since Apache's DocumentRoot is set to ~/Sites/Meetings, it only looks for files and directories inside that folder when you hit localhost. To make phpmyadmin appear as a subdirectory here, create a symbolic link (soft link) pointing to your actual phpMyAdmin folder:
- Open your terminal and run this command:
ln -s ~/Sites/phpmyadmin ~/Sites/Meetings/phpmyadmin - Next, ensure Apache is allowed to follow symbolic links. Open your
httpd.conffile and locate the<Directory>block for yourMeetingsfolder (it’ll look like<Directory "/Users/YourUsername/Sites/Meetings">). Update it to includeFollowSymLinksin theOptionsline:<Directory "/Users/YourUsername/Sites/Meetings"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> - Restart Apache to apply changes (use
sudo apachectl restarton macOS, orsudo systemctl restart apache2on most Linux distros).
If you don’t want a symbolic link cluttering your project directory, you can configure Apache to map the /phpmyadmin URL directly to your phpMyAdmin folder using an Alias:
- Open
httpd.confand add these lines (preferably near other Alias directives or at the bottom of the file):
Note: ReplaceAlias /phpmyadmin "/Users/YourUsername/Sites/phpmyadmin" <Directory "/Users/YourUsername/Sites/phpmyadmin"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory>YourUsernamewith your actual system username—using an absolute path avoids issues with Apache not resolving~correctly. - Save the file and restart Apache as before.
If you still encounter errors after trying either fix, double-check that Apache’s runtime user (usually _www on macOS, www-data on Linux) has access to your phpMyAdmin folder:
# For macOS chmod -R 755 ~/Sites/phpmyadmin chown -R _www:_www ~/Sites/phpmyadmin # For Linux chmod -R 755 ~/Sites/phpmyadmin chown -R www-data:www-data ~/Sites/phpmyadmin
内容的提问来源于stack exchange,提问作者zalyahya

