Làm cách nào để tôi khởi động lại Apache bằng Terminal trong Mac OS X?


13

Đây là những gì tôi đã làm nhưng tôi thực sự mới đối với thiết bị đầu cuối:

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

This operation requires root.

Câu trả lời:


23

Vì Apache chạy trên một cổng dành riêng ( 80) được coi là cổng cấp độ hệ thống nhạy cảm, bạn sẽ phải chạyapachectl restart qua sudonhư thế này:

sudo apachectl -k restart

Sau khi gõ nó trong đó sẽ như bạn cho mật khẩu của bạn. Giả sử bạn có quyền quản trị viên, chỉ cần nhập mật khẩu và Apache sẽ khởi động lại. Các lệnh khác bao gồm startstop có thể chạy như thế này để khởi động Apache:

sudo apachectl -k start

Và như thế này để ngăn chặn Apache:

sudo apachectl -k stop

Ngoài ra, nếu bạn chỉ cần nhập apachectlmà không có gì, bạn sẽ nhận được một danh sách các tùy chọn và chỉ thị bạn có thể sử dụng với apachectllệnh; đây là đầu ra của tôi từ 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
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.