A
A
Askhat Bikmetov2015-04-10 18:11:24
ruby
Askhat Bikmetov, 2015-04-10 18:11:24

How to access apache2 sites on the local network using the .local domain?

I have a home server, let's call it bakery. Bakery has Ubuntu, and Ubuntu has Avahi, which allows you to access other bakery services, be it AFP, DLNA or CUPS, at the beautiful address bakery.local and the corresponding port. Also, bakery has apache2 installed, which, when visiting bakery.local in the browser, happily announces: It works! Now I want to access other sites in /var/www at addresses like foo.local.
I installed Passenger, deployed the Rails app to the /var/www/railsapp directory and created a config for the virtual host:

# /etc/apache2/sites-available/railsapp.conf
<VirtualHost *:80>
  ServerName railsapp.local
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/railsapp/current/public
  <Directory /var/www/railsapp/current/public>
    # This relaxes Apache security settings.
    AllowOverride all
    # MultiViews must be turned off.
    Options -MultiViews
    # Uncomment this if you're on Apache >= 2.4:
    Require all granted
  </Directory>
</VirtualHost>

Then I entered the command
sudo a2ensite railsapp; and sudo service apache2 reload
. Now when I enter the address of railsapp.local in the browser, it returns (unexpectedly) "This webpage is not available".
What am I doing wrong? How to do it the way I want? And do I need to configure Avahi for this?
PS How to determine if a site works under Passenger without visiting it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Askhat Bikmetov, 2015-04-11
@askhat

On a home network using Avahi, it's easiest to install mod_dnssd for apache2.
After that, all virtual hosts will become available under the .local domain, which can be verified using the command avahi-browse --all.

T
taurus90, 2015-04-10
@taurus90

blog.code4hire.com/2011/03/setting-up-virtual-host...
See if you forgot something.

M
microphone, 2015-04-10
@microphone

->logs to the studio:
a query string for your page and an error string when accessing the page.

A
Alexey Cheremisin, 2015-04-10
@leahch

It is necessary to register an alias to the railsapp host in the local zone. You most likely have it (local zone local), it is in the dnsmasq package. If so, then just add it to the config
Well, restart dnsmasq The config
is located in /etc/dnsmasq.d/network-manager , if NetworkManager is installed (set with x and gnome)
or /etc/dnsmasq.conf or in the files of the /etc directory /dnsmasq.d/
For advanced masochists, there is bind9, but this is a topic for a separate question.
PS. Does passenger work - look at the apache logs.
P.P.S. If you just need to get access from another host, then it is enough to register this alias in the /etc/hosts file (for Windows %SystemRoot%\system32\drivers\etc\hosts) on another host.
For example like this:
192.168.0.11 railsapp bakery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question