I am trying to run some PHP course projects in my Mac.
I used XAMP, Homebrew, PHP local server, Docker and I keep getting 403 forbidden errors, I tried to mess with some file permissions but now in Homebrew httpd has some bootstrap errors, and some other errors, the thing is: it’s not working.
My question is: what’s the way that people use to develop in this mac environment to run PHP, Apache, MySQL/MariaDB, Composer. I can’t find a course to cover all these, just parts of them.
edit :
So, I redid everything more carefully.
I managed to get same error, I don’t know how (I managed to solve it).
-
brew services start httpd
Bootstrap failed: 5: Input/output error Try re-running the command as root for richer errors. Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/username/Library/LaunchAgents/homebrew.mxcl.httpd.plist exited with 5. -
httpd -t
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using username-macbook-air.local. Set the ‘ServerName’ directive globally to suppress this message Syntax OK -
Here I changed my servername to localhost and errors are gone (httpd.conf)
=> environment : httpd in homebrew
Now localhost is accessing my document root directory with the projects in it, it’s working (to access localhost, it sees all folders/files), but I tried to create a .htaccess file to redirect every request to index.php and is not working
error log is showing (/opt/homebrew/var/log/httpd/error_log) : AH01630: client denied by server configuration: /Users/username/Code/.htaccess -
document root has allowoverride all and require all granted
-
httpd.conf : User username / Group staff (Here I didn’t do anything more than just changing the names of user and group in that file, I don’t know if I should add some Linux command to create the group or something)
-
I added these commands :
- sudo chmod -R 755 /Users/username/Code
- sudo chown -R $(whoami):staff /Users/username/Code
-
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so is uncommented
=> Error still exists, so the problem is that the htaccess file isn’t working
=> LATER EDIT : adding this as htaccess makes it work, I don’t understand how but..
DirectoryIndex index.phpRewriteEngine On
RewriteBase /RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ – [L]RewriteRule . index.php [L]
=> something is off, I created a new virtualhost with directory at : /Users/user/Code/php/course/course-name/ at phpmvc.localhost and if I access it, it’s accessing my /Users/user/Code folder, not the course-name folder.
ps aux | grep httpd shows my username multiple times and root one time with this at the end : /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND ls -l (in projects folder) has my username (group staff) with drwxr-xr-x on folders and -rwxr-xr-x@ on files