virtual host issues in lampp

Problems with the Linux version of XAMPP, questions, comments, and anything related.

virtual host issues in lampp

Postby sheenlim08 » 16. December 2021 02:21

Hello, I am having problem getting vhost on apache in Lampp to work.

I have a ubuntu server with LAMPP Installed.
its configuration file /opt/lampp/etc/httpd.conf includes the vhost configuration file already.
Code: Select all
# Virtual hosts
Include etc/extra/httpd-vhosts.conf


its httpd-vhost.conf file has a definition below
Code: Select all
<VirtualHost phptutorial.com:8080>
    DocumentRoot "/opt/lampp/htdocs/phptutorial.com"
#    DirectoryIndex index.php
    ServerName phptutorial.com
    ServerAlias phptutorial.com
    ErrorLog "logs/phptutorial.com-error_log"
    CustomLog "logs/phptutorial.com-access_log" common
    <Directory /opt/lampp/htdocs/phptutorial.com>
#       Options All
#        Require all granted
#       AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


the ubuntu host file has
127.0.0.1 localhost
127.0.1.1 devsvr devsvr
192.168.1.1 phptutorial.com

while the client workstation has its host file
192.168.1.1 phptutorial.com

however when I visit the http://192.168.1.1:8080 i get redirected to http://phptutorial.com:8080/dashboard/ not to the contents of "/opt/lampp/htdocs/phptutorial.com" defined in the vhost file.
sheenlim08
 
Posts: 5
Joined: 22. August 2020 05:10
XAMPP version: 7.4.9
Operating System: Linux Mint 20.2

Re: virtual host issues in lampp

Postby Altrea » 16. December 2021 03:36

Hi,

<VirtualHost phptutorial.com:8080>

never ever use a domain name in the virtualhost entry tag.
there is no reason for this and will produce more issues.
replace the domain with an asterisk instead like so
Code: Select all
<VirtualHost *:8080>

the matching of the virtualhost is fully provided by the ServerName setting

DocumentRoot "/opt/lampp/htdocs/phptutorial.com"

if possible, don't use DocumentRoot paths for your virtualhost which are subdirectories of active configurations.
so if you want to use vhosts, create a new folder outside of htdocs instead like "/opt/lampp/vhost/phptutorial.com"
Otherwise it will not easy for you to see directly if your vhost isatching correctly or not.

ServerName phptutorial.com
ServerAlias phptutorial.com

only use ServerAlias if this is different from your ServerName setting.

# Require all granted
# AllowOverride All
Order allow,deny
Allow from all

change that so that the first two lines are active and the last two lines are inactive.
"Order allow,deny" and "Allow from all" are old Apache 2.2 syntax, you should completely stick with the new auth syntax starting with Require ...
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtual host issues in lampp

Postby sheenlim08 » 16. December 2021 16:58

Thanks Altrea,

I have followed your suggestion but its still not loading for me.
The httpd-vhost.conf file now looks like this, after the change i restarted the lamp by sudo /opt/lampp/lampp restart"

Code: Select all
<VirtualHost *:8081>
    DocumentRoot "/opt/lampp/vhost/phptutorial.com"
    DirectoryIndex index.html
    ServerName phptutorial.com
#    ServerAlias phptutorial.com
#    ErrorLog "logs/phptutorial.com-error_log"
#    CustomLog "logs/phptutorial.com-access_log" common
    <Directory /opt/lampp/vhost/phptutorial.com>
#       Options All
        Require all granted
        AllowOverride All
#       Order allow,deny
#       Allow from all
    </Directory>
</VirtualHost>
sheenlim08
 
Posts: 5
Joined: 22. August 2020 05:10
XAMPP version: 7.4.9
Operating System: Linux Mint 20.2

Re: virtual host issues in lampp

Postby Altrea » 16. December 2021 17:04

is Apache listening on port 8081?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtual host issues in lampp

Postby Nobbie » 16. December 2021 18:10

sheenlim08 wrote:but its still not loading for me.


How do you evaluate that?
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: virtual host issues in lampp

Postby sheenlim08 » 19. December 2021 21:05

Altrea wrote:is Apache listening on port 8081?


Sorry for the late reply, there was a typhoon that passed through in my country and Internet was kinda wacked.

@Altrea
That's exactly what is was.

For other beginners that might use this as reference in the future, I took the following steps to figure the apache was not listening to 8081.
On the SSH Connection to the ubuntu Server,
1. Issue command "netstat -aonp | grep 80"
I then noticed that the server is listening to port 80 but not port 8081.
2. I loaded the configuration file /opt/lampp/etc/httpd.conf, there is a section there for the "Listen", i added "Listed 8081" just below the "Listen 80".
3. I then applied the recommendations by "Altrea" on his post "https://community.apachefriends.org/f/posting.php?mode=quote&f=17&t=81574&p=275140#pr275136".
4. I then restarted the apache on Lampp by "sudo /opt/lampp/lampp restartapache".
5. Restarted by browser session.

Thank you for all the help Altrea and Noobie.
sheenlim08
 
Posts: 5
Joined: 22. August 2020 05:10
XAMPP version: 7.4.9
Operating System: Linux Mint 20.2

Re: virtual host issues in lampp

Postby Altrea » 20. December 2021 08:43

sheenlim08 wrote:1. Issue command "netstat -aonp | grep 80"
I then noticed that the server is listening to port 80 but not port 8081.

If your Apache is able to run on port 80, why would you want to change that?
it is highly recommended to run Apache on port 80.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtual host issues in lampp

Postby sheenlim08 » 23. December 2021 14:32

I am at the point of my learning where I want to deliberately change the defaults of a apache config for the sake of learning and actually verify if what I understood based on reading the configuration file reflects to what I expect as the output.

Your replies on this thread has been very helpful.
sheenlim08
 
Posts: 5
Joined: 22. August 2020 05:10
XAMPP version: 7.4.9
Operating System: Linux Mint 20.2


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 57 guests