V
V
vais2014-01-19 22:39:25
linux
vais, 2014-01-19 22:39:25

How to setup apache2 and domains on home server?

Introduction
So. There is a home server, Debian is installed on it (without graphical additions).
Also, apache2 php5 mysql was installed and somehow configured.
The server is connected to a router (dlink320), the router is connected to the Internet. (all setup goes via ssh)
IP is static and white.
I also bought a domain in the .ru zone.
Well, there are a few questions.
1. I wrote to the hosting support to change the NS of the purchased domain to my IP. This is the right decision?
because there are some third-party dns servers post on habré , but I still don’t understand why they are needed.
2. several blanks were created for sites (for example, test.ru, other.ru diplom.ru, etc.)
and inapache2/sites-available configs were created for them,

<VirtualHost *:80>
  ServerAdmin [email protected]
DocumentRoot /var/sites/diplom/www
  <Directory />
    Options FollowSymLinks
    AllowOverride All
    AddType application/x-httpd-php .html
  </Directory>
  <Directory /var/sites/diplom/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    AddType application/x-httpd-php .html
  </Directory>
</VirtualHost>

but if I type in my ip (109.172.68.76) in the browser, then only the site that is registered in
sites-available/default (test.ru) is displayed,
how can I switch to other blanks?
/etc/hosts says
127.0.1.1 test.ru
127.0.1.2 diplom.ru
3. Maybe I need to know something else?
Thanks

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
Nikolai Turnaviotov, 2014-01-20
@vais

first - To serve any domain zone, you need one, and by standards at least two dns servers.
If you have a dns server up and configured correctly, you can register your home server as a DNS server in the admin panel of your domain at the registrar.
Your dns server must correctly describe the dns zone for your domain.zone
in a, mx, www aliases pointing to the "white" ip of your home server.
in the web server, you must specify that there is a virtual host domain.zone, with the root directory /var/www/domain.zone and subdirectories /var/www/forum as forum.domain.zone
taken by me for example.
well, yes, your home server should now work around the clock 24/7/365, be available on ports 53 and 80, and also, if you have registered MX on it, and port 25 for receiving mail for the domain.
Congratulations, you made a website for no reason at home, instead of buying a simple virtual machine from any hoster like hetzner or in any cloud like amazon/azure with real availability for a couple of bucks a month (it's cheaper than paying electricity bills) 24 /7/365
now all that's left is to watch the scripts to make sure your machine hasn't been hacked due to vulnerabilities, to worry about its operation.
Of the options, of course, you can deploy a virtual machine on your host so that it does not interfere with work and does not eat up all the resources, but this is the next step

N
Nikolai Vasilchuk, 2014-01-19
@Anonym

Maybe I need to know something else?

There will definitely be more to know. There's a lot you need to know.

E
egor_nullptr, 2014-01-19
@egor_nullptr

If you want sites from your server to open from your computer via the test.ru and diplom.ru domains, then specify the required IP for them in /etc/hosts (or c:\Windows\System32\drivers\etc\hosts) on your computer.

V
VBKesha, 2014-01-19
@VBKesha

At a minimum, you need to understand the configuration of virtual hosts and the ServerName directive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question