I can't configure two domains with VirtualHost, because, always show me only one domain. I mean, if I visit domainB.com that redirect me to domainA.com and domainA.com works fine. I made this procedure in anothers hosts like: DigitalOcean or my own localhost, but with this instance I can't find the issue. If I disable one site the other works without problem.
I have a google instance with Ubuntu 17.10 and Apache2 with two domains (virtualhost). I disabled the default virtualhost. My folder structure is /var/www/domainA/ and /var/www/domainB/
Cloud DNS is configured with two zones domainA.com and domainB.com with A and CNAME records point to my server IP. I have too NS records pointed to googledomains.com and in my registar I added those DNS.
If I do a ping to both domains, them resolve correctly to my IP address without problem.
I have the two domains configured in sites-available:
#in /etc/apache/sites-available/domainA.com.conf
<VirtualHost *:443>
ServerAdmin webmaster#domainA.com
ServerName domainA.com
ServerAlias www.domainA.com
DocumentRoot /var/www/domainA
ErrorLog ${APACHE_LOG_DIR}/error-domainA.log
CustomLog ${APACHE_LOG_DIR}/access-domainA.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/sslcert/certified-number.crt
SSLCertificateKeyFile /etc/apache2/sslcert/domainA.com.key
SSLCertificateChainFile /etc/apache2/sslcert/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /var/www/domainA/>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
#in /etc/apache/sites-available/domainB.com.conf
<VirtualHost *:80>
ServerAdmin webmaster#domainB.com
ServerName domainB.com
ServerAlias www.domainB.com
DocumentRoot /var/www/domainB
ErrorLog ${APACHE_LOG_DIR}/error-domainB.log
CustomLog ${APACHE_LOG_DIR}/access-domainB.log combined
<Directory /var/www/domainB/>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Result of apachectl -S command:
sudo apache2ctl -S
VirtualHost configuration:
*:80 domainB.com (/etc/apache2/sites-enabled/domainB.conf:1)
*:443 domainA.com (/etc/apache2/sites-enabled/domainA.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
What other setting I must to check?
UPDATE INFORMATION: If I try with www for the domainA, works fine.
www.domainA.com -> Works
domainA.com -> Doesn't work, redirect to domainB.com
www.domainB.com -> Works
domainB.com -> Works
I had only a VirtualHost configuration in the port 443 for domainA.com.
I added a configuration *:80 with a redirection to ssl and works. Like this:
<VirtualHost *:80>
ServerAdmin webmaster#domainA.com
ServerName domainA.com
ServerAlias www.domainA.com
Redirect / https://www.domainA.com/
</VirtualHost>
Thanks Matt Raines for his comment.
Related
Created a Hello_World NodeJS App.
The app is accessible at http://<DOMAIN_NAME>/app & http://<DOMAIN_NAME>:3000
but when accessed via https://<DOMAIN_NAME>/app it returns an error.
http://<SERVER_IP>:3000 also works & https:<SERVER_IP>:3000 returns an error
sudo apachectl -S
OUTPUT :
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 okoyama.in (/etc/apache2/sites-enabled/okoyama.in.conf:1)
*:443 okoyama.in (/etc/apache2/sites-enabled/okoyama.in.conf:45)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
<VirtualHost *:80>
ServerAdmin admin#okoyama.in
ServerName okoyama.in
ServerAlias www.okoyama.in
DocumentRoot /var/www/okoyama.in/public_html
ProxyPreserveHost On
ProxyPass /app http://localhost:3000/
ProxyPassReverse /app http://localhost:3000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/okoyama.in/public_html
ServerName okoyama.in
SSLEngine on
SSLCertificateFile /etc/ssl_install/certificate.crt
SSLCertificateKeyFile /etc/ssl_install/private.key
SSLCertificateChainFile /etc/ssl_install/ca_bundle.crt
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
The above code has Reverse Proxy enabled for HTTP. HTTPS works normally. I have removed the Reverse Proxy section from 443 Port for now to make the working code cleaner.
Multiple variations of solutions suggested on various platforms have been tried in Port 443 section but none worked until now.
The included turning on SSLProxyEngine & a similar Proxy method as mentioned in the HTTP section.
Suggest possible solution. I will retry & post for clarity.
I have a web server which hosts several sites, and also reverse proxies other applications. The sites hosted on the box appear to be working. One of the sites being reverse proxied is working. The second site (pihole) being reverse proxied is returning the apache default ubuntu page, and I don't understand why. Typically this would be because the default site is enabled, but in this case it's not. Additionally, "phone.example1.com" would be the "default" according to the output below, but it's webroot is /var/www/phone and the default page serves from /var/www/html/ so it's not that.
Here's the output of apache2ctl -S where you should see that phone, saml, and samltest are actual apache hosted sites, then dlna and pihole would be reverse proxied. For https, there is no "default-ssl.conf" site enabled, we're getting caught in the phone.example1.com as the default, but it shouldn't match because of the servername:
VirtualHost configuration:
?:0 /var/www/torquetest (/etc/apache2/sites-enabled/torquetest.subdir.conf:1)
*:80 is a NameVirtualHost
default server hass.example1.com (/etc/apache2/sites-enabled/hass.conf:2)
port 80 namevhost hass.example1.com (/etc/apache2/sites-enabled/hass.conf:2)
port 80 namevhost hda.example1.com (/etc/apache2/sites-enabled/hda.conf:2)
port 80 namevhost mc.example2.com (/etc/apache2/sites-enabled/mc.example2.com.conf:1)
*:443 is a NameVirtualHost
default server phone.example1.com (/etc/apache2/sites-enabled/010.phone.subdomain.conf:1)
port 443 namevhost phone.example1.com (/etc/apache2/sites-enabled/010.phone.subdomain.conf:1)
alias phone.example1.com
wild alias *.phone.example1.com
port 443 namevhost samltest.example1.com (/etc/apache2/sites-enabled/011.samltest.subdomain.conf:1)
alias samltest.example1.com
wild alias *.samltest.example1.com
port 443 namevhost saml.example1.com (/etc/apache2/sites-enabled/012.saml.subdomain.conf:1)
alias saml.example1.com
wild alias *.saml.example1.com
port 443 namevhost dlna.example1.com (/etc/apache2/sites-enabled/013.dlna.subdomain.conf:1)
alias dlna.example1.com
wild alias *.dlna.example1.com
port 443 namevhost pihole.example1.com (/etc/apache2/sites-enabled/014.pihole.subdomain.conf:1)
alias pihole.example1.com
wild alias *.pihole.example1.com
port 443 namevhost hass.example1.com (/etc/apache2/sites-enabled/hass.conf:9)
port 443 namevhost hda.example1.com (/etc/apache2/sites-enabled/hda.conf:16)
port 443 namevhost mc.example2.com (/etc/apache2/sites-enabled/mc.example2.com.conf:7)
*:8089 hda.example1.com (/etc/apache2/sites-enabled/phoneproxy.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=2001
Group: name="www-data" id=2001
Since dlna is working and pihole is not, I figured it's useful to include them for debugging (in the following 2 examples the cert file is a wildcard for example1.com, the name is some legacy stuff):
This is "013.dlna.subdomain.conf" which I can successfully navigate to at https://dlna.example1.com and get the dlna status page:
<VirtualHost *:443>
ServerName dlna.example1.com
ServerAlias dlna.example1.com
ServerAlias *.dlna.example1.com
#DocumentRoot /var/www/dlna
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8200
ProxyPassReverse / http://127.0.0.1:8200
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
SSLOptions +StdEnvVars
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/hda.example1.com.crt
SSLCertificateKeyFile /etc/ssl/private/hda.example1.com.key
SSLCACertificateFile /etc/ssl/certs/RapidSSL.Intermediate.crt
SSLHonorCipherOrder On
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDS
A-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA25
6:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
SSLInsecureRenegotiation off
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
SSLProxyEngine On
ProxyRequests On
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
This is "014.pihole.subdomain.conf" where I get the apache default page when I navigate to it at https://pihole.example1.com:
<VirtualHost *:443>
ServerName pihole.example1.com
ServerAlias pihole.example1.com
ServerAlias *.pihole.example1.com
#DocumentRoot /var/www/pihole
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5354/
ProxyPassReverse / http://127.0.0.1:5354/
SSLProxyEngine On
ProxyRequests On
RequestHeader set X-Forwarded-Proto "https"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
SSLOptions +StdEnvVars
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/hda.example1.com.crt
SSLCertificateKeyFile /etc/ssl/private/hda.example1.com.key
SSLCACertificateFile /etc/ssl/certs/RapidSSL.Intermediate.crt
SSLHonorCipherOrder On
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDS
A-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA25
6:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
SSLInsecureRenegotiation off
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
I'm stumped and am finding myself throwing syntax at it, any advice is appreciated.
I am trying to set up two virtual hosts, one for my website and another for my nextcloud instance. This is what my config files look like:
/etc/apache2/site-available/000-default.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot "/var/www/html"
CustomLog /var/log/apache2/nc-access.log combined
ErrorLog /var/log/apache2/nc-error.log
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
LimitRequestBody 0
SSLRenegBufferSize 10486000
</Directory>
</IfModule>
/etc/apache2/site-available/nextcloud.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName nextcloud.domain.com
DocumentRoot "/var/www/nextcloud"
CustomLog /var/log/apache2/nc-access.log combined
ErrorLog /var/log/apache2/nc-error.log
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
LimitRequestBody 0
SSLRenegBufferSize 10486000
</Directory>
</IfModule>
Output of apache2ctl -S, showing the activated hosts:
VirtualHost configuration:
*:80 domain.com (/etc/apache2/sites-enabled/000-default.conf:2)
*:443 nextcloud.domain.com (/etc/apache2/sites-enabled/nextcloud.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
When I enter domain.com in my browser, I am expecting it to load /var/www/html, my website. However, it loads my nextcloud (/var/www/nextcloud) instance. What do I do to make domain.com redirect to my website instead of my nextcloud instance?
You should modify your configurations like this (explanation below):
/etc/apache2/site-available/000-default.conf
<VirtualHost _default_:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot "/var/www/html"
CustomLog /var/log/apache2/80_nc-access.log combined
ErrorLog /var/log/apache2/80_nc-error.log
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
LimitRequestBody 0
</Directory>
</VirtualHost>
/etc/apache2/site-available/nextcloud.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName nextcloud.domain.com
DocumentRoot "/var/www/nextcloud"
CustomLog /var/log/apache2/443_nc-access.log combined
ErrorLog /var/log/apache2/443_nc-error.log
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
LimitRequestBody 0
SSLRenegBufferSize 10486000
</Directory>
</VirtualHost>
</IfModule>
Changes
In your :80 VirtualHost, you should not have any SSL directives. Port 80 is for http:// connections. So I remove everything that had to do with SSL.
In your :443 VirtualHost, there you want to have your SSL directives. So keep those.
<Directory> directives should be included in the <VirtualHost> sections. These only make sense in the context of your <VirtualHost> anyway. There should be a generic <Directory> in httpd.conf that blocks direct access to all directories anyway.
I suggest you use separate log files for each <VirtualHost>. It is a good habit to have, trust me I have had Apache server with 20 hosts, it is impossible to figure out which log entry is for which. Also you might want to put your SSL in Debug log to troubleshoot something...
To reach the first <VirtualHost>, enter http://example.com
To reach the second <VirtualHost>, enter https://example.com
There is no redirection here. Just <Virtualhost> names and ports assignment. Apache looks at what you asked for (the site in the address bar of your browser) and uses the <VirtualHost> that best matches your request. If it cannot find a specific one, it will use the first one by default.
That explains why if you try https://example.com, Apache will select the <VirtualHost> based on the port. Here it is port 443 (https://). So Apache will respond with your cloud <VirtualHost>. The port is the deciding factor here, not the domain name.
I have deployed my project on linode and configured everything correctly but I find the homepage the only thing to be working. Anything else is giving me The requested url can not be found on this server. I have check all my configurations and everything seems to be correct. a2enmod rewrite is enabled and this 000-default.conf:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteBase /var/www/application
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
What else is missing?
Edit:
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
You need to set document root to the public folder of your application like so:
"var/www/your-site.com/public"
Try follow my config:
<VirtualHost *:80>
ServerName yourproject.com
ServerAlias www.yourproject.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/yourproject/public
<Directory "/var/www/yourproject/public">
Require all granted
Allowoverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Turns out the .htaccess was missing so that was the reason. I have added it and it is working normally.
I'm running Apache 2.4.6 on Ubuntu 13.
In sites-available, I have a conf file for my site that contains only this:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody#somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
</VirtualHost>
There are no other conf files enabled. When I have use apachectl -S to display the sites, it shows:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
The first thing I notice is the duplicate entry for namevhost www.ourco.me. And when I visit the site in a browser, I get:
You don't have permission to access / on this server.
Apache/2.4.6 (Ubuntu) Server at www.ourco.me Port 80
All the directories and files specified in the conf file exist. a2ensite and a2dissite work as expected to add/remove a symlink for this file from sites-enabled, so it's looking at the right file. Does anyone know why its directives are being ignored? Thanks.
Put Allow from all
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody#somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
Allow from all
</VirtualHost>
This appears to solve the problem:
<Directory />
Require all granted
</Directory>
when placed in the VirtualHost entry.
That snippet came from this post. I'm looking at this Apache doc to see why it works.