skip to Main Content

I’ve got a server (ubuntu 18.04) running behind the router which I’m using for testing of various web applications (snipe-it, phpipam, and libre speedtest). Not having the resources for individual machines to run them on and not really wanting to delve into virtual machines I thought I could run them on the same instance of apache and access them by changing the virtual host configurations.

When I run individual virtual hosts each site runs fine. when I try to run more than one site (a2ensite xxx and a2ensite yyy) the site with the lower alphabetical name (xxx in this case) shows up.

I don’t know if Alias or Rewrite is the way to go. I can’t really change how the developers choose to write the apps and where they want to put their programs. I can understand why (I think) they put them there. I just want to be able to access all of the sites/pages/apps…

/etc/apache2/sites-available/snipeit.conf

<VirtualHost *:80>
    ServerName snipeit
    DocumentRoot /var/www/snipe-it/public
    Alias "/" "/var/www/snipe-it/public"
    <Directory /var/www/snipe-it/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

/etc/apache2/sites-available/phpipam.conf

<VirtualHost *:80>
    ServerName phpipam
    DocumentRoot /var/www/phpipam
    <Directory /var/www/phpipam>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

/etc/apache2/sites-available/speedtest.conf

<VirtualHost *:80>
    ServerName speedtest
    DocumentRoot /var/www/html
    <Directory /var/www/html/speedtest>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

2

Answers


  1. You can follow these steps to check where the issue is.

    1) Check if you /etc/hosts file have the proper DNS entries for the ServerNAMe

    snipeit.x localhost
    phpipam.x localhost
    speedtest.x localhost
    

    2) Make sure the ServerName Directive matches with the host. ServerName should be exactly the same as the DNS name you are using to access it.

    3) Check Apache VirtualHost configurations

    apache2ctl -S
    

    3) Run Apache in debug mode. and check how apache is parsing your request.

    apache2ctl -t -c /path/to/apache.conf
    
    Login or Signup to reply.
  2. To achieve what you want, you might need to do this:
    Move both of the directories to /var/www/html. and remove all the virtualhosts for them except the one for /var/www/html which is 000-default.conf. It is going to be complicated when you store them in different directories instead of this easy trick.

    Edit:

    The user had applications that are dependent on those paths. So the best way to do this is by using Aliases in Apache. Make sure that mod_alias is loaded in Apache. Add this to the end of httpd.conf.

    Alias "/snipeit" "/var/www/snipe-it/public"
    Alias "/phpipam" "/var/www/phpiam"
    #And, speedtest is already inside the folder.
    

    You can access those sites like: http://localhost/snipeit, http://localhost/phpiam, http://localhost/speedtest. Or you may use the IP Address to access it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search