How to start homebrew Apache on boot?

If you run:

brew services

The last two lines of the output gives the answer to your question:

If sudo is passed, operate on /Library/LaunchDaemons (started at boot).
Otherwise, operate on ~/Library/LaunchAgents (started at login).

So, to start apache at boot run:

sudo brew services start apache2

and to start apache at login run:

brew services start apache2

I tried the accepted solution, but it didn't worked for me. The only way to get the autostart to work was by modifying the '.plist' file:

sudo brew services start apache2
sudo nano /Library/LaunchDaemons/homebrew.mxcl.httpd.plist

I added:

<string>/usr/local/bin/apachectl</string>
<string>start</string>

And I also commented out:

<string>/usr/local/opt/httpd/bin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>

The result looked like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.httpd</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/apachectl</string>
    <string>start</string>
    <!--
    <string>/usr/local/opt/httpd/bin/httpd</string>
    <string>-D</string>
    <string>FOREGROUND</string>
    -->
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>