skip to Main Content

I need help configuring my website to be accessed in the local server as a virtual directory in Apache.
I am trying to use the port 8050, and when i open localhost:8050 , it shows:

This site can’t be reached
localhost refused to connect. ERR_CONNECTION_REFUSED

when i try to access my localhost:80 in the browser, it shows the default blank page with the message “It Works”
if i change my virtualhost to *.80 in the config, it keeps showing the default message “It Works”, instead of my page.

apachectl -t returns Syntax OK
the command:
apachectl -t -D DUMP_VHOSTS returns:

VirtualHost configuration:
*:8050 personal.com (/private/etc/apache2/extra/httpd-vhosts.conf:24)

the Servername in my httpd.conf file is localhost, and it also contains:
Listen 8050
and
Listen localhost:8050

this is my httpd-vhosts in etc/apache2/extra/httpd-vhosts.conf:

<VirtualHost *:8050>
    ServerAdmin [email protected]
    DocumentRoot "/Users/renatobento/Documents/Projetos/Personal"
    ServerName personal.com
    ErrorLog "/private/var/log/apache2/personal.com-error_log"
    CustomLog "/private/var/log/apache2/personal.com-access_log" common
<Directory "/Users/renatobento/Documents/Projetos/Personal">
    Order allow,deny
    Allow from all
    Require all granted
</Directory>
</VirtualHost>

The path “/Users/renatobento/Documents/Projetos/Personal” seems correct, and contains a simple index.html with some content, which works in the browser with file protocol: “file:///Users/renatobento/Documents/Projetos/personal/index.html”

Already executed
apachectl stop , apachectl start , and apachectl restart thousand times

after the stop command, the localhost:80 still shows the message “It Works”

I am using MAC OSX 10.3 high sierra, apache 2.4

Server version: Apache/2.4.33 (Unix) Server built: Apr 3 2018
23:45:11 Server’s Module Magic Number: 20120211:76 Server loaded: APR
1.5.2, APR-UTIL 1.5.4 Compiled using: APR 1.5.2, APR-UTIL 1.5.4 Architecture: 64-bit Server MPM: prefork threaded: no
forked: yes (variable process count) Server compiled with…. -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE -D
APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D
APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D
DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT=”/usr” -D
SUEXEC_BIN=”/usr/bin/suexec” -D
DEFAULT_PIDLOG=”/private/var/run/httpd.pid” -D
DEFAULT_SCOREBOARD=”logs/apache_runtime_status” -D
DEFAULT_ERRORLOG=”logs/error_log” -D
AP_TYPES_CONFIG_FILE=”/private/etc/apache2/mime.types” -D
SERVER_CONFIG_FILE=”/private/etc/apache2/httpd.conf”

edit:
tried with a different port :9050 but still not working

2

Answers


  1. Chosen as BEST ANSWER

    Problem solved. Weird, looks like restarting Apache and cache commands sometimes are not enough. The message changed to 403-forbidden after a system restart.

    I checked the ports with lsof -nP -i4TCP:80 | grep LISTEN lsof -nP -i4TCP:8050 | grep LISTEN lsof -nP -i4TCP:9050 | grep LISTEN

    and it showed 4 httpd process listening to :80 even with apache stopped, then after a reboot appeared a process listening in the correct port.


  2. Check whether permissions for DocumentRoot

    /Users/renatobento/Documents/Projetos/Personal
    

    are set to be accessible for everyone.

    Your overall config seems to be good.


    Check your /etc/hosts file, if it contains something like

    127.0.0.1    localhost
    127.0.0.1    personal.com
    

    To edit this file, type sudo nano /etc/hosts in Terminal and after editing, type sudo killall -HUP mDNSResponder to flush DNS cache.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search