0

Firstly I've read many tutorials, I'm trying for many hours during last days (because I know there were billion similar questions and tutorials for the same thing before) but I'm in the ends... :-(

The last site I've followed (and checked many times) was https://tech-cookbook.com/2020/11/14/setting-up-your-local-web-server-on-macos-big-sur-11-0-1-2020-mamp-macos-apache-mysql-php/. Before I've tried https://medium.com/nerd-for-tech/how-to-run-apache-php-on-mac-os-big-sur-7ffbf7cbef7b, but they looks very similar.

What I have

  • Apache 2.4.46 (apachectl -v)

  • php 7.3.24 (php -v)

  • Apache should be setted correctly. Stopped and started.

  • sudo apachectl configtest returns Syntax OK

  • in /etc/apache2/httpd.conf I have set DocumentRoot and <Directory ... to /Users/username/Sites/

  • /Users/username/Sites has chmod 777

  • /Users/username/Sites shows me directory content (path is correct)

  • /etc/apache2/extra/httpd-vhosts.conf is set to (source https://wpbeaches.com/set-up-virtual-hosts-on-macos-big-sur-11-in-apache/)

      <VirtualHost *:80>
          ServerName localhost
          DocumentRoot /Users/username/Sites/ 
          # I've tried: 
          ## insert value into "",
          ## localhost, 
          ## localhost/~username, 
          ## set localhost and ServerAlias to localhost/~username, etc.
      </VirtualHost>
    

Result
As result, both http://localhost and http://localhost/~username returns me ERR_CONNECTION_REFUSED.

I've checked all .conf files settings with my older macbook and they look very similar in both machines... :-(

Any idea where could be problem? I'm able to put here more additional information (copy conf files content, whatever) if needed... I'm a little bit hopeless... :-(

Thanks!

EDIT

ps -ax | grep '[h]ttpd' returns

14994 ??         0:00.51 /usr/sbin/httpd -D FOREGROUND
14997 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
15002 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
15040 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
15042 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
15043 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND

sudo lsof -a -iTCP -sTCP:LISTEN -c httpd returns

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd   14994 root    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   14997 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15002 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15040 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15042 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15043 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
pavel
  • 111
  • 2
  • Is Apache actually running? Check with `ps -ax | grep '[h]ttpd'` (note that if it is running, you'll probably see several processes.) If it's running, check whether it's listening for incoming connections with `sudo lsof -a -iTCP -sTCP:LISTEN -c httpd` – Gordon Davisson Oct 01 '21 at 05:02
  • @GordonDavisson thx for your comment. Both outputs are added into the question (sorry, I'm not able to tell if it's running from it) – pavel Oct 01 '21 at 10:35
  • The `lsof` output indicates it's listening for IPv6 connections, but not for IPv4; I don't know what'd cause that, but that's what I'd concentrate on trying to find. Actually, one more test: run `netstat -anv | grep '[.]80 .*LISTEN'` -- you'll see a line starting with `tcp6` showing that it's listening on TCP over IPv4, but does is also show one starting with `tcp4`? If so, that'd show that something else is grabbing the port on IPv4, and preventing Apache from getting it. – Gordon Davisson Oct 01 '21 at 17:25
  • @GordonDavisson I'm getting this `tcp46 0 0 *.80 *.* LISTEN 131072 131072 18249 0 0x0080 0x0000000e` – pavel Oct 01 '21 at 17:47
  • @GordonDavisson: _If so, that'd show that something else is grabbing the port on IPv4, and preventing Apache from getting it. _... what does it mean, or what I should to do? I'm totally lost... :-( – pavel Oct 01 '21 at 17:48
  • Actually, that means I misinterpreted the `lsof` output -- it's actually listening for both IPv6 and IPv4 (that's what the "tcp46" at the beginning of the `netstat` output means), and `lsof` was only showing v6 for some reason. So... this isn't the problem. But it does mean that Apache is running and listening for connections, which basically means it (and its config files and whatnot) are *not* the problem. So look at your network config; things like any firewalls you're running, proxies, weird network/VPN configs, etc. – Gordon Davisson Oct 01 '21 at 18:44
  • Also, rather than using "localhost", try an explicit address: `http://127.0.0.1/`. I'd also try from the command line, with `curl http://127.0.0.1/`. – Gordon Davisson Oct 01 '21 at 18:45
  • @GordonDavisson No VPN, no proxy... :-( `localhost` and `127.0.0.1` do the same (redirected automatically to https and `err_connection_refused`). `curl http://127.0.0.1` returns `302`, `curl https://127.0.0.1` (or `https://localhost`) returns `curl: (7) Failed to connect to localhost port 443: Connection refused`... It looks like problem is in automatically redirect to https (I've tried to google it, and I didn't find a way how to disable it)? – pavel Oct 01 '21 at 18:53
  • @GordonDavisson I've set HTTPS - browser marks URL as not safe, but it works... Green lock in URL I can solve later... thanks for your time! – pavel Oct 01 '21 at 19:34

0 Answers0