Skip to content

Instantly share code, notes, and snippets.

@ahmadshuami
Last active April 12, 2024 06:52
Show Gist options
  • Save ahmadshuami/2becf91a4adda196cc691a88e42d3476 to your computer and use it in GitHub Desktop.
Save ahmadshuami/2becf91a4adda196cc691a88e42d3476 to your computer and use it in GitHub Desktop.
How to Setup Apache, PHP 8.0, MariaDB and Apache Virtual Host using Homebrew Part 1 - Installation of Apache
Watch the video at https://youtu.be/Tlu2Prm_UNw
1. Stop default apache
% sudo apachectl stop
% sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
2. Install apache
% brew install httpd
% brew services start httpd
3. Browse
http://localhost:8080
4. Open httpd config file (I'm using sublime text)
- If you're using Intel-based Mac
% subl /usr/local/etc/httpd/httpd.conf
- If you're using Mac with Apple Silicon
% subl /opt/homebrew/etc/httpd/httpd.conf
5. Update these lines
Listen 8080 -->> Listen 80
DocumentRoot "/usr/local/var/www" -->> DocumentRoot "/Users/your_account/Sites"
<Directory "/usr/local/var/www"> -->> <Directory "/Users/your_account/Sites">
AllowOverride None -->> AllowOverride All
*** /usr/local/var/www => default root directory (Intel-based Mac)
*** /opt/homebrew/var/www => default root directory (Mac with Apple Silicon)
6. Uncomment this line
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
7. Update these lines
User _www -->> User your_account
Group _www -->> Group staff
8. Update this line
#ServerName www.example.com:8080 -->> ServerName localhost
9. Create Sites folder and add dummy index html file
% mkdir ~/Sites
% echo "<h2>This is my new index</h2>" > ~/Sites/index.html
10. Restart apache
% brew services restart httpd
11. Test
http://localhost
@nisarul-dev
Copy link

It was helpful, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment