Setup Virtual Host

published by on

Create Virtual Host conf

Create conf file by editing in nano


    sudo nano /etc/apache2/conf.d/sites-available/website.dev.conf

and add there insert this

<VirtualHost *:80>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride ALL
        Order allow,deny
        allow from all
    </Directory>

    DocumentRoot /var/www/website.dev/public/
    ServerName website.dev
    ServerAlias www.website.dev
    ServerAdmin webmaster@website.dev

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Activate Virtual Host conf

Create symlink


    sudo ln -s /etc/apache2/sites-available/website.dev.conf /etc/apache2/sites-enabled/website.dev.conf

and restart apache


    service apache2 restart

Add new Virtual Host to systems hosts file

add


    ServerName localhost

into


    sudo nano /etc/apache2/apache2.conf

Tags: apache ubuntu