I’m using the Homebrew version of Apache/httpd. I’ve disabled the Mac OOTB version.
If I disable/comment the following, my localhost correctly brings up index.html from /Users/lamba/www/index.html.
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
However, when I uncomment it, I get an ERR_CONNECTION_REFUSED error in the browser (Chrome). I don’t see anything useful in the logs, even with trace8 level logging.
I have granted r access to all users for /Users/lamba/www and down. And r, x access to all users for /Users/lamba/Projects and down (I thought index.php might need x access).
Important parts of my Apache/httpd configuration:
httpd.conf
Listen 80
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule php_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp.so
DocumentRoot "/Users/lamba/www"
<Directory "/Users/lamba/www">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/lamba/Projects/Magento-Open-Source/pub"
ServerName local.m2os.com
ErrorLog "/usr/local/var/log/httpd/m2os-error_log"
CustomLog "/usr/local/var/log/httpd/m2os-access_log" common
<Directory "/Users/lamba/Projects/Magento-Open-Source/pub">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Header always set Strict-Transport-Security "max-age=0"
DirectoryIndex index.php
</VirtualHost>
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 local.m2os.com
255.255.255.255 broadcasthost
::1 localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
127.0.0.1 ::1 magento.test
After some more consideration, I think this is not a virtual host issue because (after disabling virtual hosts) I am not able to point my localhost to my real project’s root either. My project root has an index.php file, which the log indicates Apache is able to find. But then for some reason it sends a 302 response instead of executing the script. Before I had included the PHP module, it was displaying the contents of login.php and again not executing it. I would still appreciate help figuring out how to get Apache to execute index.php. Also, I have added index.php to the DirectoryIndex directive.
An even more pointed question to ask is, how do I change my DocumentRoot? I’ve set the DR to /Users/lamba/Projects/Magento-Open-Source/pub in /usr/local/etc/httpd/httpd.conf. However, when I run “brew info httpd”, it reports the default DR /usr/local/var/www. So, I’m guessing that is the source of my troubles. How do I change that?
The master conf in the pre-Homebrew world used to be 000-default.conf. Where is that file in the Homebrew world?
UPDATE: If I hide index.php, Apache successfully loads index.html from the same location. So, it appears to be a PHP issue.
UPDATE 2: I created a simple dummy index.php in my pub folder and Apache is serving it up just fine. So, I believe this to now be a Magento issue (with Magento’s index.php). Still digging.
Finally got the admin page to load by switching to Nginx. Nginx has better error logging, which helped me figure out that the issue was an untrusted SSL certificate. So I added it as trusted. The admin page is showing a 404 for some of the content due to a “mixed content” error, meaning some content on an HTTPS page is being fetched via HTTP. The storefront home page still isn’t loading, with the error “Redirected you too many times. Try deleting your cookies.”
Fixed the “mixed content” issue by disabling the CSP mod for now. Not sure why these issues should be popping up OOTB though. Feedback and comments welcome.