我尝试启动和停止 Apache,我尝试停止 Apache 两次以确保我应该被停止
Mac-mini:~ jeud$ sudo apachectl start
Mac-mini:~ jeud$ sudo apachectl stop
Mac-mini:~ jeud$ sudo apachectl stop
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
Run Code Online (Sandbox Code Playgroud)
但似乎我仍然可以使用http://localhost
,http://127.0.0.1
从网络浏览器访问 Apache Web 服务器,我仍然收到来自Server:Apache/2.4.9 (Unix) PHP/5.6.2
我试过 sudo lsof -i -P | grep 80
httpd 554 root 5u IPv6 0x8b96aa4ecd4e340b 0t0 TCP *:80 (LISTEN)
httpd 555 _www 5u IPv6 0x8b96aa4ecd4e340b 0t0 TCP *:80 (LISTEN)
httpd 566 _www 5u IPv6 0x8b96aa4ecd4e340b 0t0 TCP *:80 (LISTEN)
httpd 567 _www 5u IPv6 0x8b96aa4ecd4e340b …
Run Code Online (Sandbox Code Playgroud) 我在优胜美地运行 Apache 2.4
这是我的 /private/etc/apache2/httpd.conf
ServerName 127.0.0.1:80
DocumentRoot "/Library/WebServer/Documents/home_www/"
<Directory "/Library/WebServer/Documents/home_www">
Options Multiviews FollowSymLinks
MultiviewsMatch Any
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
通过此设置,我可以使用http://127.0.0.1
,并http://localhost
在Web浏览器中,然后将其引导我/Library/WebServer/Documents/home_www/index.html
像往常一样
然后我补充说,Include /private/etc/apache2/extra/httpd-vhosts.conf
因为我想在我的机器上使用 vhost
这是我的 /private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin jeud@hotmail.com
ServerName tutor4dev.local
DocumentRoot "/Library/WebServer/Documents/home_www/xxx"
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我试着用sudo apachectl -S
显示vhost配置,有结果
VirtualHost configuration:
*:80 xxx.local (/private/etc/apache2/extra/httpd-vhosts.conf:28)
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents/home_www/"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex proxy: using_defaults
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: …
Run Code Online (Sandbox Code Playgroud)