1. Allow the usage of custom virtual hosts. Open the httpd.conf
sudo gedit /opt/lampp/etc/httpd.conf
2. Uncomment the line bellow
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
3. Create a custom domain in the hosts file of your system
sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.0.5 myawesomeproject
.....
4. Create your first virtual host
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
<VirtualHost 127.0.0.5:80>
DocumentRoot "/opt/lampp/htdocs/my-first-project"
DirectoryIndex index.php
<Directory "/opt/lampp/htdocs/my-first-project">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
5. Test your virtual host
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!";
?>
6. Restart
sudo /opt/lampp/lampp restart
7. Check it out!
http://myawesomeproject/