Add New Virtual Host XAMPP or LAMPP on Linux
In this article, I would like to give a tutorial to Add New Virtual Host XAMPP or LAMPP on Linux.
In this case, I assume you already install xampp on your linux. Then lets start to Add New Virtual Host XAMPP or LAMPP on Linux immediately.
- Open your terminal and log as SU
- Type in your terminal “gedit /opt/lampp/etc/httpd.conf” to open httpd.conf in your text editor
- delete “#” in front of “Include etc/extra/httpd-vhosts.conf” line
- Type in your terminal “gedit /opt/lampp/etc/extra/httpd-vhosts.conf” to edit httpd-vhosts.conf
- add lines :<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/[YourCompName]/localhost2
#some path of your new host
ServerName localhost2
#the name of your new host
ServerAlias www.localhost2
#alias of your new host
</VirtualHost> - Type in your terminal “gedit /etc/hosts” to edit hosts
- add line :
127.0.0.1 localhost2
#127.0.0.1 Your new host name - Restart lampp by execute “/opt/lampp/lampp restart“
Other Expamples
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/lifeerp/apierplife/public
#some path of your new host
ServerName apierplife.dev
#the name of your new host
ServerAlias www.apierplife.dev
#alias of your new host
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/lifeerp/apierpdemo/public
ServerName apierpdemo.dev
ServerAlias www.apierpdemo.dev
</VirtualHost>
127.0.0.1 apierplife.dev
127.0.0.1 apierpdemo.dev
Now you have two virtual hosts in your computer. You can access it through url http://localhost and http://localhost2. In this case, the two virtual host has its own document root. The default http://localhost has document root in /opt/lampp/htdocs, while the http://localhost2 has document root in /home/[YourCompName]/localhost2.
Have a nice try on Add New Virtual Host XAMPP or LAMPP on Linux…
No hay comentarios.:
Publicar un comentario