#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    192
    Rep Power
    17

    Problem with Apache and Virtual Hosts


    Server OS: CentOS v.7
    Web Server: Apache v.2.4.6

    I have made the following changes to the httpd.conf file:
    Code:
    ...
    
    ServerName www.mydomain.net:80
    
    ...
    
    DocumentRoot "/var/www/html"
    
    ...
    
    # For .htaccess files...
    AllowOverride All
    
    ...
    
    # Virtual Host Files
    IncludeOptional sites-enabled/*.conf
    So in this new Apache setup, all the virtual host stuff is located in the "sited-enabled" directory. And here's that file called "mydomain.net.conf" ...

    The path is /etc/httpd/sites-enabled/mydomain.net.conf

    Code:
    <VirtualHost *:80 *:443>
        ServerName www.mydomain.net
        ServerAlias mydomain.net
        DocumentRoot /var/www/html/mydomain.net/public_html
        ErrorLog /var/www/html/mydomain.net/error.log
        CustomLog /var/www/html/mydomain.net/requests.log combined
    </VirtualHost>
    So what's going on is that when I punch www.mydomain.net into the browser, Apache should load the index.html document that I have in here: /var/www/html/mydomain.net/public_html/index.html

    However, it does not. Instead it loads an index.html document that I have (to prevent directory listings, although there is a directive in httpd.conf that addresses directory listings as well): /var/www/html/index.html

    When Apache reads httpd.conf and then IncludeOptional sites-enabled/*.conf and then /etc/httpd/sites-enabled/mydomain.net.conf, it should be serving /var/www/html/mydomain.net/public_html/index.html

    Incidentally, I have an SSL cert (Let's Encrypt), and so everything is redirected from http to https.
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,177
    Rep Power
    9644
    Did you restart Apache?

    Originally Posted by Arty Zifferelli
    Incidentally, I have an SSL cert (Let's Encrypt), and so everything is redirected from http to https.
    ...if you explicitly set that up.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    192
    Rep Power
    17
    Originally Posted by requinix
    Did you restart Apache?
    Of course.
    ...if you explicitly set that up.
    I did.
  6. #4
  7. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,177
    Rep Power
    9644
    If you don't have a default virtualhost for /var/www/html that is accidentally covering mydomain.net then it sounds like there's a typo somewhere.

IMN logo majestic logo threadwatch logo seochat tools logo