Question
How to get apache virtual hosts working
I have tried following every tutorial I can find and I can’t seem to get the WordPress one click setup to serve files from a different directory besides the default /var/www/html
.
I have used a2dissite
, a2ensite
, reloaded, restarted apache. The properties in the config file ServerName
, etc.
One interesting detail is that when I ran a2dissite 000-default.conf
came back with an error to the effect that the corresponding file in sites-enabled
was not symlinked. Which is weird since creating new .conf
files in sites-available
does seem to symlink them into sites-enabled
. I have setup these files on other droplets and had no problems. Is this something unique to this pre configured droplet?
I scrapped my first droplet - I had deleted all the original default .conf
files in frustration and apache was, in my opinion, still using one of them. It was looking for a directory that I had deleted, which though an error, but that directory was not pointed to in any of the configurations that were supposed to be active.
This is my /etc/apache2/sites-available/mydomain.conf
file.
<VirtualHost *:80>
ServerAdmin ben@mydomain
DocumentRoot /var/www/html.old
ServerName mydomain
ServerAlias www.mydomain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html.old/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The only way I found to serve something else is to change the contents of /var/www/html
. This is not ideal, since my next move is to get multiple sites running with subdomains. As of right now I am getting by but starting to get frustrated with the learning curve.
Any help would be greatly appreciated. Thanks.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×