Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Atef95's avatar

Virtual Host Set up

Hey Guys

I'm trying to set up a virtual host for my project I'm using Ubuntu 16.04

I'm facing 2 issues right now

first , I switched to this directory /etc/apache2/sites-available/

I simply copied **000-default.conf** to another file example.conf

then

sudo a2ensite example.conf to enable the new file

sudo a2dissite 000-default.con to disable the old one

inside example.conf I have

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.test
    ServerAlias www.example.test
    DocumentRoot /opt/lampp/htdocs/pixmania-front-v2/Apps/Pixmania/Front/htdocs/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I edited /etc/hosts

127.0.0.1 example.test

right now when I type example.test on browser it redirects me to example.test/dashboard

couldn't know why...

Later on , I tried a solution that I found on stackoverflow which is to comment out **httpd-vhosts.conf ** in **httpd.conf ** this solution redirects me to 403 error on localhost !

I hope you can help me!

0 likes
2 replies
COACHTHEM's avatar

Here is my conf file on ubuntu /etc/apache2/sites-available/test.sip.ch.conf

<VirtualHost *:80>
    ServerName test.sip.ch
    
    DocumentRoot /var/www/vhost/testsipch/public
    
    ErrorLog /var/log/apache2/testsipch.log
    CustomLog /var/log/apache2/testsipch.log combined
    
    <Directory /var/www/vhost/testsipch/public>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

after adding the file execute sudo a2ensite test.sip.ch.conf and then execute sudo systemctl reload apache2

Please or to participate in this conversation.