Table of Contents
Apache is already installed on macOS, but it is not set up to auto start Apache during boot. You’ll have to start the httpd process by hand every time you want to use it. When you have trouble turning off your server and the Apache server doesn’t start automatically when the server is turned back on. It keeps people from getting to your website. And the only way to fix it was to open the server terminal and start the Apache server.
It’s a lot of trouble and troublesome. Some Centos 7 servers, like those at Digital Ocean, do this step automatically when they boot up. By default, they didn’t make the Apache server run automatically when your servers did.
How to auto start Apache during boot
- From the Terminal, enter the following command:
- sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
- Hit return and enter the admin password as requested to complete the job.
- Now when the Mac is booted or rebooted, Apache will start automatically, which is easily verified by going to any browser and entering “localhost” as the URL.
- You’ll see the familiar “It Works!” message at localhost and those core files are located in:
- /Library/WebServer/Documents/
- Going further, you can also enable the user level Sites option for localhost/~User, but that’s beyond the scope of this article, we cover that here.
Stop Apache from Loading on Boot in Mac OS X
- To stop Apache from starting itself automatically upon system start, you simply need to remove the agent from launchd as with any other daemon, like so:
- sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
- Again you will need to enter the admin password to confirm the change.
FAQ
How do I start httpd on boot time?
The httpd service doesn’t start automatically when the computer boots up by default. Use an initscript utility like /sbin/chkconfig, /sbin/ntsysv, or the Services Configuration Tool to set up the httpd service to start up when the computer boots.
What command could you use to enable httpd to start at boot?
You can also set up an initscript utility like /sbin/chkconfig, /usr/bin/ntsysv, or the Services Configuration Tool to start the httpd service when the computer boots up. For this to work, you need to turn on the status module mod status in your httpd.conf configuration file.
How can you make a service run automatically after boot?
Used to start a service that has been made. We have explained how to set up the services so that they start automatically when the computer boots up. Check out the video below to get a better idea of what I mean.
How do I start a service automatically when startup Linux?
- Run this command sudo nano /etc/systemd/system/YOUR_SERVICE_NAME.service.
- Paste in the command below. …
- Reload services sudo systemctl daemon-reload.
- Enable the service sudo systemctl enable YOUR_SERVICE_NAME.
- Start the service sudo systemctl start YOUR_SERVICE_NAME.