You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Mac OS Sierra后Apache无法访问求助

Fixing Apache "This site cannot be reached" After macOS Sierra Upgrade

Hey there, let's work through this Apache issue together—upgrades can definitely mess with our server settings, so we'll go step by step to get it back up and running.

Step 1: Check if Apache is actually running

First, let's confirm Apache's current status. Open up Terminal and run:

sudo apachectl status
  • If you see httpd is not running, that means the service isn't active at all.
  • If you get an error message instead, note it down—it'll help us narrow things down.

Step 2: Try restarting Apache properly

Sometimes a simple restart fixes post-upgrade glitches. Run these commands in order:

sudo apachectl stop
sudo apachectl start

If the start command fails, don't panic—let's check the error logs for details:

cat /var/log/apache2/error_log

Look for lines with [error]—they'll tell you exactly what's broken (like a missing config file, syntax error, or port conflict).

Step 3: Check if Port 80 is being used by another app

macOS upgrades might leave other services (like Node.js servers, Nginx, or even some VPN tools) running on port 80, which Apache needs. To check:

sudo lsof -i :80

This will list all processes using port 80. If you see something other than httpd, you have two options:

  • Stop that process (use kill -9 [PID] where PID is the number in the second column)
  • Or change Apache's listening port:
    1. Open /etc/apache2/httpd.conf in a text editor (like sudo nano /etc/apache2/httpd.conf)
    2. Find the line that says Listen 80 and change it to Listen 8080
    3. Save the file (Ctrl+O, then Enter in nano) and restart Apache with sudo apachectl restart
    4. Now try accessing localhost:8080 instead of just localhost

Step 4: Verify Apache's configuration syntax

Upgrades sometimes reset or corrupt config files. Let's check for syntax errors:

sudo apachectl configtest

If you see Syntax OK, great—configs are fine. If not, the output will tell you which line/file has the problem (for example, a missing semicolon or a commented-out include you need to re-enable).

Step 5: Check permissions on your web root directory

macOS might have changed the ownership of Apache's default web root (/Library/WebServer/Documents/). Let's fix that:

sudo chown -R _www:_www /Library/WebServer/Documents/
sudo chmod -R 755 /Library/WebServer/Documents/

This ensures the Apache user (_www) has the right access to serve files from that folder.

Step 6: Check your firewall settings

Sometimes the macOS firewall blocks Apache's incoming connections. To test:

  1. Open System Preferences > Security & Privacy > Firewall
  2. Click the lock icon (enter your password) and then click Firewall Options
  3. Look for httpd in the list—make sure it's set to Allow incoming connections
  4. If it's not there, you can add it by clicking the + button and navigating to /usr/sbin/httpd
  5. Alternatively, temporarily turn off the firewall to see if that fixes the issue (remember to turn it back on later!)

Bonus: Restore custom configurations (if you had any)

If you set up virtual hosts or custom modules before the upgrade, check if their includes are still enabled in httpd.conf:

  • Open /etc/apache2/httpd.conf and look for lines like #Include /private/etc/apache2/extra/httpd-vhosts.conf
  • Remove the # at the start of the line to re-enable the include, then restart Apache.

Once you've worked through these steps, try accessing localhost (or localhost:8080 if you changed the port) again—it should show the familiar "It Works!" page.

内容的提问来源于stack exchange,提问作者Kat Joy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:40:30