这是我所做的但我对终端还很陌生:
Jeremys-MacBook-Pro-2:~ jeremyoconnor$ apachectl restart
This operation requires root.
答案1
由于 Apache 在保留端口(80
)上运行,而该端口被视为敏感的系统级端口,因此您必须apachectl restart
通过sudo
如下方式运行:
sudo apachectl -k restart
输入该命令后,系统会要求您输入密码。假设您具有管理员权限,只需输入密码,Apache 就会重新启动。其他命令包括start
和stop
,可以像这样运行以启动 Apache:
sudo apachectl -k start
像这样停止 Apache:
sudo apachectl -k stop
此外,如果您只是输入apachectl
任何内容,您将收到可以与命令一起使用的选项和指令列表apachectl
;这是我从 Mac OS X 10.9.5 输出的:
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
-S : a synonym for -t -D DUMP_VHOSTS
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t : run syntax check for config files
-T : start without DocumentRoot(s) check