I am attempting to set up the LAMP environment for the first time. I normally use Windows and just install XAMPP.
I have followed the instructions on Ubuntu forums and have duplicated the file in sites-available.
Currently I can access my site via localhost, but not via either the ServerName or ServerAlias directive.
Here is the file in sites-avialable:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DirectoryIndex index.php
DocumentRoot /home/username/example
<Directory /home/username/example>
Options FollowSymLinks
AllowOverride None
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerSignature On
</VirtualHost>
you should enter
example.com
to your /etc/hosts file and reload apache. You should also enable the virtual host withsudo a2ensite
.So:
NameVirtualHost *:80
to you apache configuration. I add this in top of default in /etc/apache2/sites-availableexample
in /etc/apache2/sites-availablesudo a2ensite example
sudo service apache2 restart/reload
I think that ServerAlias is not that necessary