ฉันจะรีสตาร์ท Apache โดยใช้ Terminal ใน Mac OS X ได้อย่างไร


13

นี่คือสิ่งที่ฉันทำ แต่ฉันยังใหม่กับเทอร์มินัล:

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

This operation requires root.

คำตอบ:


23

เนื่องจาก 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
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.