sudo gedit /opt/lampp/etc/httpd.conf
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
Uncomment above line to enable vhosts.
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.0.2 myproject # the custom domain added
#don't touch other existent values
#The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
<VirtualHost 127.0.0.2:80>
DocumentRoot "/opt/lampp/htdocs/myproject"
DirectoryIndex index.php
<Directory "/opt/lampp/htdocs/myproject">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
To test it, in the folder /opt/lampp/htdocs/my-first-project, create a simple PHP file (index.php) that will contain the following PHP code:
<?php
echo "Hello world!";
?>
Start apache, mysql (entire XAMPP) using the following command (or whatever the way you start apache and the other required services):
sudo /opt/lampp/lampp start
Navigate in your favorite browser to http://myproject/ or http://127.0.0.2/ and you should get as output "Hello World" in the browser.