How do I restart Apache web server under Mac OS X operating systems?
The apachectl command act as Apache HTTP Server control interface. It can be used to start, stop, and restart the Apache web server from command line.
Open a terminal and type any one of the following command:
sudo apachectl restart
OR
sudo apachectl -k restart
Task: Stop Apache Web server
sudo apachectl -k stop
Task: Start Apache Web server
sudo apachectl -k start
🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 12 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks, but it might be easier this way: Open the “Sharing” preference, (de-)select “Web Sharing”.
I was just wondering if OS X got some sort of service manager. I need to dig it a little more…
thanks for the comment!
The software to start/stop (load/unload) services is called “launchctl”. From the man page:
launchctl interfaces with launchd to load, unload daemons/agents and generally control launchd. launchctl supports taking subcommands on the command line, interactively or even redirected from standard input.
These commands can be stored in $HOME/.launchd.conf or /etc/launchd.conf to be read at the time launchd starts.
Vivek, what does the -k switch do? I couldn’t find it in the man page for apachectl on a Mac OS X system.
@Robert, I will look into it.
@Leaman, the apachectl command works in two modes:
a) Sys v style mode – One line command mode which take args like start, restart, and stop, and translating them into appropriate UNIX signals to httpd.
b) Traditional UNIX mode with lots of options for testing and debugging. In this mode it can act as a simple front-end to the httpd command that simply sets necessary environment variables and then invokes httpd, passing through any command line arguments.
HTH
it does’mt work for me :(
SUM-IT:~ sumitgupta$ apachectl -k graceful
httpd: Syntax error on line 488 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+entropy-php.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _libiconv\n Referenced from: /usr/local/php5/lib/libintl.8.dylib\n Expected in: /usr/lib/libiconv.2.dylib\n
SUM-IT:~ sumitgupta$
this is the problem i am facing please help…..
i receive an error when I try to restart apache with: sudo apachectl restart
the error reads: /urs/sbin/apachectL: line 73: unlimit: open files: cannot modify limit: invalid argument
can anyone help! please.
Solution is here http://wordpress.org/support/topic/upgraded-to-php-530-on-mac-now-no-database-connection
changes are to be made in “/usr/sbin/apachectl”
comment out the these lines.
i did this through the command line using ‘vi’ commands
@Javier, I’d say there is an error in your httpd.conf file. Open it up in the plain-text editor of your choice–one that shows line numbers–and look at line 73. There is either a syntax error or an invalid argument for the option contained on that line.
Good luck!
lemanc,
i went to httpd.conf file and line 73 is ‘LoadModule include_module libexec/apache2/mod_include.so ‘ do you know anything about this kind of issue?
thanks in advanced!
This is not the correct solution. Please see my other reply for the solution.