Hello
@ozstar, I agree with
@captain-sensible, Apache is using the concept of a Virtual Host but I have to add that you can have a single server with one IP and serve different sites.
To set this up, you have to create a separate configuration file for each of them and store them in Apache configuration directory. Each file should include an identifier such as a name that differentiates one from the other.
In ubuntu-server configuration files for each site should be stored like this:
Code:
/etc/apache2/sites-available/yoursitename.com.conf
and the command that you should use to enable it, is this one:
Code:
sudo a2ensite yoursitename.com.conf
sudo systemctl reload apache2
As far as I know this two are Ubuntu dedicate command and I can't help you if you are using some other distro.
The contents of /var/www/html are served by the default virtual host if you make no changes to Apache's configuration.
000-default.conf is the file that controls the default Apache sample website and is enough for the case that we need our Apache to serve a single site.
With servers with a single IP you can use 000-default.conf and make your own 000-virtual-hosts.conf and stored it in the
Code:
/etc/apache2/sites-available
directory.
Contents should be something like this:
Code:
<VirtualHost *:80>
ServerName mysitename.com
DocumentRoot /var/www/mysitename
</VirtualHost>
<VirtualHost *:80>
ServerName mysitename2.com
DocumentRoot /var/www/mysitename2
</VirtualHost>
Another good idea is to modify the part of
Code:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
that you will find inside the 000-default.conf when you make your new 000-virtual-host.conf into something like this:
Code:
ErrorLog ${APACHE_LOG_DIR}/mysitename.com-error.log
CustomLog ${APACHE_LOG_DIR}/mysitename.com-access.log combined
Good luck.