Mac OS Xのターミナルを使用してApacheを再起動するにはどうすればよいですか?


13

これは私がやったことですが、私は本当にターミナルに新しいです:

Jeremys-MacBook-Pro-2:~ jeremyoconnor$ apachectl restart

This operation requires root.

回答:


23

Apacheは80機密性の高いシステムレベルのポートと見なされる予約ポート()で実行されるためapachectl restart、次のsudoように実行する必要があります。

sudo apachectl -k restart

パスワードを入力すると、パスワードが入力されます。管理者権限がある場合、パスワードを入力するだけでApacheが再起動します。その他のコマンドにはstartstopApacheを起動するために次のように実行できるものがあります。

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
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.