How to set up smartphones and PCs. Informational portal
  • home
  • News
  • Installation and initial configuration of an Ubuntu server is a proven procedure.  Installing and configuring Ubuntu Server

Installation and initial configuration of an Ubuntu server is a proven procedure.  Installing and configuring Ubuntu Server

Raise the web Apache server PHP and MySQL on Ubuntu couldn't be easier. You can install LAMP. First option in detailed description doesn’t need it, but I’ll write about the second one now. The installation will take place in several stages. First, we need to register a domain with some domain name registrar, for example www.sweb.ru I have been using it for more than 5 years. Consider transferring to own server fictitious domain www.mysite.ru I did everything on a live machine, not on a virtual server, so to transfer to your server you must have at least one dedicated external IP.

Do not forget to register in the admin panel of your hoster the dns for your domain in the form of an external ip attached to your server.

Install Ubuntu Server 10.04.3, it was on it that I created web server. I know there are many other distributions, but I don't care soul ubuntu. Special attention When installing, pay attention to the network settings ( DHCP), it is better to configure it manually. Also, at the last stage, when you are asked to select packages from the list (mail server, lamp, ssh, java... etc.), select only ssh, you don’t need the rest.

During the installation of the server, if suddenly something went wrong when installing a package, you can remove it. To do this you need to write in the console:

apt-get purge "here is the name of the package to remove"

Installing Apache

sudo apt-get install apache2

If everything went without errors, the server will boot immediately and be in working order. I have a network with internal IPs and external IPs linked to them by the provider. Therefore, by typing an external ip on another computer, we get to a page with the text "It works!", it means everything worked out. The host files are located in the folder /var/www, we don't need it. At least I decided that it is better to store all data in a folder /home. Therefore, in the future we will move our domain folders to the section home.

To manage the Apache server we can use the utility apache2ctl. For example, you can view the current status of the Apache server by running the command:

apache2ctl status - server status
sudo apache2ctl stop - stop
sudo apache2ctl start - start
sudo apache2ctl restart - restart

There are other commands for the same purposes:

sudo /etc/init.d/apache2 status - server status
sudo /etc/init.d/apache2 stop - stop
sudo /etc/init.d/apache2 start - start
sudo /etc/init.d/apache2 restart - restart

Installing PHP

Let's immediately install libraries for working with muscles and libraries for working with graphics:

sudo apt-get install php5 libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql imagemagick

some manuals write about another package: php-image-graph but it didn’t install for me, I wrote that it was not available, so I didn’t bother to figure out why, it worked like that. :)

To make Apache pick up the newly installed PHP, reload it with the command:

sudo apache2ctl restart or sudo /etc/init.d/apache2 restart

Installing MySQL

sudo apt-get install mysql-server

During MySQL installations, a window will appear in which you need to enter a password. By default MySQL creates administrative user with the name root. In this window you need to enter the password for this user and press Enter, then re-enter the password. Don't forget to write down your password.

If you want to change your Mysql password, what I mean is that if you set Russian ubuntu version sometimes it is not clear what language you are entering in, then you can replace it like this:

mysql -uroot –p

SET PASSWORD FOR root@localhost=PASSWORD("123456789");

enter quit

In general, everything reboots automatically, but if suddenly, we reboot:

Mysql /etc/init.d/mysql restart

We try to log in with a new password.

Installing PhpMyAdmin

For ease of database management, install phpMyAdmin. Most admins do not install it, preferring to work with the console, and complaining about the many holes, but it is convenient and if you make it available only for a certain ip, or so that no one can go to it by typing the ip or domain name in the browser, then there are no problems.

sudo apt-get install phpmyadmin

At the end of the installation, a window will appear in which you need to select a server apache2(spacebar) and press Enter. Next you will be asked to create a database for phpMyAdmin. Select Yes and press Enter. Next, enter the administrative account password. Then enter your password to register phpMyAdmin on the database server and in the next window confirm the password.

Panel phpMyAdmin controls will be available at http://your_ip/phpmyadmin. Enter root as the username and the password is the one you specified for root user when installing MySQL.

To restrict access to PhpMyAdmin you need to perform several steps. First, let's hide access to database management via http://your_ip/phpmyadmin Let's edit the file /etc/apache2/conf.d/phpmyadmin.conf in which you need:

1. Change Alias ​​/phpmyadmin to something of your own, for example Alias ​​/skdjfhefjdv, which will not allow an attacker, if your site has Internet access, to access phpmyadmin from outside and do who knows what.

2. In the phpmyadmin root directory, which is located in /usr/share/phpmyadmin/, you need to put the .htaccess file with the following data:

deny from all
allow from your_IP

Now you can log into phpMyadmin from a specific IP.

Now let's create our website www.mysite.ru. We will create a directory for all your sites, and at the same time for www.mysite.ru:

mkdir -p ~/www/mysite.ru/public_html

With this team we created a common www and in it a domain folder with a folder for site files, in the directory /home.

Now let's notify Apache about the new site. Create a file:

sudo nano /etc/apache2/sites-available/mysite.ru

And we enter it there following lines:


ServerName mysite.ru
ServerAdmin webmaster@localhost

DocumentRoot /home/username/www/mysite.ru/public_html

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/error.log

CustomLog /var/log/apache2/access.log combined

Save the file. Now you need to tell Apache that the site needs to be served. We write to the terminal:

sudo a2ensite mysite.ru

And then reboot it:

sudo /etc/init.d/apache2 reload

Now we need that when entering the address mysite.ru in the browser, our local site opens, and not from the Internet. Therefore, open the hosts file.

This article will discuss the complete setup of a ready-made WEB website hosting server based on the UBUNTU 16.04 distribution

For convenience of working with the command line remote server, I recommend using the PuTTY program.

Preparing the server

1. Update server packages

sudo apt-get update
sudo apt-get upgrade

2. Install the Apache, MySQL, PHP (LAMP) component package

sudo apt-get install lamp-server^

The ^ symbol at the end is required - it is part of the command

During the MySQL installation, you will be prompted to create a root password (this is separate password administrator specifically for SQL server, and not for the main server administrator).

Checking the web server installation http://- the apache test page should be displayed.

3. Install phpMyAdmin

sudo apt-get install phpmyadmin
sudo service apache2 restart

You need to run the following commands:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo /etc/init.d/apache2 reload

sudo apt-get install php-mbstring php-gettext
sudo phpenmod mcrypt
sudo phpenmod mbstring

Checking the availability of the interface http:///phpmyadmin

4. Install FTP (for ease of working with files)

sudo apt-get install proftpd

During installation you will be asked to choose one of two various options settings:

From inetd- the ProFTPd daemon will run under the inetd service.
Standalone- ProFTPd will be installed as a separate daemon.

After ftp installations the server will be started and you can connect.

However, it is advisable to further configure it:

sudo nano /etc/proftpd/proftpd.conf

Uncomment the value RequireValidShell off And DefaultRoot~

After setting up FTP you need to restart:

sudo /etc/init.d/proftpd restart

5. Install apache2-mpm-itk

This module is needed so that the Apache server can work with site files on behalf of the folder owner.

By default, the directory with site files has 755 rights and 644 rights for all files. This gives write access to files and folders only to their owner. For this reason, when working with files via FTP and Apache (for example via the CMS interface), the files will be created on behalf of different users and problems arise with changing or deleting them. It helps in solving this very problem. this module. It indicates in the host settings of each site under which user and group Apache will run in the specified directory.

sudo apt-get install libapache2-mpm-itk
sudo a2enmod mpm_prefork
sudo a2enmod mpm_itk
sudo systemctl restart apache2

6. Enabling mod_rewrite (to enable CNC operation)

sudo a2enmod rewrite
sudo service apache2 restart

Start of website creation

7. Create a user and directory for working with sites

sudo useradd -m -s /bin/false Username
sudo passwd username

(Username - New user, on whose behalf work will be carried out on the site. This will help differentiate rights when working with several sites on one server)

When prompted by the system, enter the new user’s password (twice)

After creating the user, we place a separate directory for the site (for example www), by logging in as a new user via FTP to your home directory, or with the following command:

sudo mkdir /home/ Username/www
sudo chown -R Username:user_group/home/ Username/www/

(Because in the previous command, when creating a user, it was not specified existing group, then a group with the same name as the username was automatically created. Those. in the command above, the username is equal to the user's group name)

8. Create a virtual host for the site

Create a virtual host configuration file from the default option

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/ new site.conf

Editing parameters

sudo nano /etc/apache2/sites-available/ new site.conf

We change and supplement the following values:

DocumentRoot /home/ Username/www
ServerName new site
ServerAdmin webmaster@localhost
Username/www>
AllowOverride All
Require all granted


AssignUserId Username user_group

We include the created virtual host and restart apache

sudo a2ensite new site

sudo service apache2 reload

9. Create a MySQL database

You need to log into the mysql management console

mysql -u root -p

In this case, the system will ask for the root password from mysql (precisely from mysql, which was specified when installing LAMP). Upon successful login to the mysql console, the value in front of the cursor will change to mysql>. After this creation new base sql and the user to manage it can be executed with one command:

create database database_name; GRANT ALL ON database_name.* TO " database_user"@"localhost"IDENTIFIED BY " user_password_database_sql";

To exit the mysql console you need to enter the command

We can finish here. Full hosting for the site is ready.

Additionally, for ease of management and control of the server via the WEB interface, you can install the Webmin control panel

You can also additionally configure parameters PHP work ("to taste" - for example, the size of uploaded files in the parameter upload_max_filesize = 2M)

For UBUNTU 16.04:

sudo nano /etc/php/7.0/apache2/php.ini

For UBUNTU 14.04:

sudo nano /etc/php5/apache2/php.ini

The first link in our stand! In this article we will figure out where to get it installation image, let's look at the system requirements, look at the installation step by step Ubuntu Server 16.04.4 LTS, and we will also launch it for the first time. Let's check the network and look at the basic commands for rebooting and shutting down our brand new server.

Where can I download?

Download Ubuntu Server 16.04.4 LTS you can from two official sites, each of them has a section Download. Links to this section are provided below:

Fig.1 - Download Ubuntu Server 16.04.4 LTS from Ubuntu.ru
Fig.2 - Download Ubuntu Server 16.04.4 LTS from Ubuntu.com

Preparing for installation.

I downloaded Ubuntu Server 16.04.4 64-bit as an iso image ubuntu-16.04.4-server-amd64.iso

System requirements.

type of instalation CPU RAM Hard drive space
Basic installation All modules installed
Standard 1 GHz 512 MB 1.5 GB 2.5 GB
Minimum 300 MHz 384 MB 1.5 GB 2.5 GB

Installing Ubuntu Server.

Step 1. - Select a language.

Select the installation interface language (Fig. 3)


Fig.3 - Selecting the interface language Ubuntu installations Server.

Step 2. - Ubuntu installer menu.

Choose "Install Ubuntu Server" .(Fig.4) Let's move on...

The article is certainly not about the review Ubuntu Server installer menu, but it is worth noting that for diagnostics, there are useful functions:

  • Check the disk for errors,
  • Check your memory.

Fig.4 - Ubuntu installer menu.

Step 3. - Select a location.

Since there is no mouse cursor here, navigating through elements, selecting and confirming actions is done using the keyboard:

  • - transition through elements;
  • <Пробел> - choice;
  • - button activation;

We choose the country in which we live. I live in Russia, so I choose " Russian Federation" .(Fig.5)

The selected location will be taken into account when setting the time zone and creating a list when selecting a system location.

This shortened list is based on the selected language. You are taking "Other", if your location is not listed.


Fig.5 - Selecting a location.

Step 4. - Setting up the keyboard.

First of all, we are asked to configure layout by pressing the keyboard keys. - Symbols will appear on the screen and you will have to enter them on the keyboard, in the end it will be determined layout all you have left is confirm it.

We will consider selecting the layout we need manually, therefore, in the dialog box we click "No ".(Fig.6)


Fig.6 - Defining the layout by pressing the keys.

A list of countries appears in front of us, we need to select the country for which the keyboard was made (Fig. 7), since my keyboard has Russian letters, which means I choose "Russian". Next, from the list of different regional and system layouts, select the one we need, I select the usual Russian - "Russian".(Fig.8)


Fig.7 - List "Select the country" for which the keyboard was manufactured. Fig.8 - "Select layout" list.

Final keyboard setup - indication of switching method between the national layout and standard Latin. Personally I like it standard method switch languages, I select it - "Alt+Shift".(Fig.9)


Fig.9 - Indicating the method for switching languages.

Step 5. - Computer name.

In the dialog box "Network configuration" we are asked to enter "Computer name". "Computer name"- this is one word intended to identify our system on the network. I enter - "ubuntuserver", you can come up with something yourself. Click "Continue ".(Fig.10)


Fig.10 - Computer name.

Step 6. - Set up user accounts and passwords.

In the "Setting up accounts and passwords" window, we are asked to enter data to create an account that will be used instead account superuser (root), to perform all actions not related to administration.

To begin with, you are asked to enter real name user. I enter - "FirstDeer"(Fig.11)


Fig. 11 - Enter the real username for the account.
Fig. 12 - Enter the username/account login.

We enter the password, without it there is no way. You can click "View Password"/"Show Password in Clear", in order to make sure that you enter the password in the language layout you need. (Fig. 13) Checking the correctness of the input is carried out by re-enter password and comparing the results, so after entering the password for the first time, a second similar window awaits us, where we will need to confirm the password. (Fig. 14)


Fig. 13 - Enter the account password.
Fig. 14 - Confirm the account password.
Fig.15 - Encrypt home directory?

Step 7 - Setting the time.

<перевод> (Fig.16) "Based on your current physical location, your time zone is Europe/Moscow.
If this is incorrect, you can choose from a complete list of time zones.
Is the time zone selected correct?"

In St. Petersburg, Moscow time means everything was chosen correctly. If your time zone is different from Moscow, then click "No " and select your time zone in full list. I'm pressing "Yes ". Let's move on.


Fig. 16 - Confirmation of the time zone.

Step 8. - Disk partitioning.

If you are interested in the markup method "Manually"- then I invite you to read a separate article - there are too many meaningless screenshots in it, I don’t want to clutter up the main article :)

Let's move on to disk layout, since our disk volume is small and there are no installed systems then I choose "Auto - use the entire disk and configure LVM" .(Fig.17)

LVM(Logical Volume Management)- a disk space management system that allows you to combine several hard drives into a single pool of disk space, and then distribute it disk space to logical partitions. (That is, if one of the partitions suddenly runs out of space, we can insert an additional hard drive and expand the partition; this function is necessary for servers.)


Fig. 17 - Selecting the disk partitioning method.
Fig.18 - Selection hard drive.

Before setting up logical volumes, it is suggested to write the partition table to disk, this will destroy all data on the disk. (Fig.19)


Fig. 19 - Recording information about partitions.

Select the volume group size used for installation. The minimum size you can specify is 1.9 GB, but please note that installing the packages you select may require more space. Maximum available size This hard drive size, in my case it is - 21 GB. I leave everything as it is 21.0 GB- already entered. I press "Continue ".(Fig.20)


Fig.20 - Selecting the volume group size.

Here is a list of configured partitions and their mount points. If you want to adjust the sections, you can click on any of them and change its settings. Everything suits me. I press "Finish marking and write changes to disk" .(Fig.21)


Fig.21 - Window "Manual adjustment of partitions".
Fig.22 - Write changes to disk?

Step 9. - System installation.

Wait until the system installation is completed.(Fig.23)


Fig.23 - System installation.

Step 10. - Setting up a proxy.

If you need a proxy server to access the Internet, then indicate information about it in the field. (Fig. 24)

If not, do not indicate. I don't indicate. I press "Continue ".


Fig.24 - Specifying a proxy server.

Step 11 - Updates.

Wait until the automatic application of updates finishes. (Fig. 25)


Fig.25 - Applying updates.

We choose how we want to manage updates. Personally, I like it better when I decide when to install updates. That's why I choose the first point. I press "Enter".(Fig.26)


Fig.26 - Selecting update options.

Step 12. - Select software.

Choice software which you want to install on the server. By default, you can select only "standard system utilities". I haven’t tried it, but in my opinion this selection cannot be removed. (Fig. 27)

I won’t choose anything non-standard. because in the future I’m going to show you the manual installation of each of the software provided in the selection. I press "Continue ". And wait until the installation of the selected software is completed. (Fig. 28)


Fig.27 - Selecting software.
Fig.28 - Software installation.

Step 13 - Installing the GRUB system boot loader.

We are waiting for the system bootloader to install GRUB.(Fig.29) Read carefully (Fig.30) the first paragraph. Our Ubuntu Server will not coexist with other operating systems, which means we can safely install GRUB to home page boot entry. Click "Yes ".


Fig.29 - Installing the GRUB system boot loader.
Fig.30 - Selecting the installation location for GRUB.

Step 14 - Completing the installation program.

We are waiting for the final installation and configuration. (Fig. 31)


Fig.31 - Final installation and setting.

It's time to download our new system. Extracting everything installation media and press "Continue ".(Fig.32)


Fig.32 - Completing the installation.

First start.

Step 1. - Authorization.

After the reboot we are greeted by two lines. (Fig. 33)

In the first line we see:


Fig.33 - First switching on. Authorization.

Enter login: firstdeer

AND password: - when entering a password UNIX systems do not show the number of characters entered (***), we are entering a password and should not notice any changes on the screen.

After entering, click "Enter". So we are all logged in. (Fig. 34)


Fig.34 - Authorization.

Step 2. - Check the network.

The first thing I want to do is check net, this is done using the command:

Ifconfig

We see our network card "ens33",it may have another name, often it is "eth0".

And we see that we have decided IP address V local network - inet addr:192.168.3.9.(Fig.35)


Fig.35 - Checking the network with the ifconfig command.

Since there is Internet on our local network, we can check external ping. We'll ping Google DNS server its IP address is 8.8.8.8. Enter the command:

Ping 8.8.8.8

Pings are coming! the answer comes, it means we have access to the Internet, therefore LAN card configured correctly.(Fig.36)


Fig.36 - Checking ping.

Logout/Log out/End session.

  • Tutorial

Hello, Habr! During the discussion of one article about the “ideal” home network, a dispute arose about which is better, a hardware NAS or a mini-computer with Linux distribution. The author suggested using a hardware NAS, because it is supposedly easier to administer, does not require knowledge of Linux, and in general the NAS is quiet. But at the same time, to watch a video on a DLNA TV that it does not support, I suggested turning on a laptop with DLNA transcoding. This surprised me, to put it mildly, because this should not happen in an ideal network. Therefore, I would like to present my vision of one of the key components home network- a centralized data storage, and it will be based on a mini-PC running Ubuntu Server OS.

What do we need?

First of all, the NAS is required, of course, secure storage data and convenient access to it. First of all, RAID is necessary for reliability, because losing your entire home media archive due to a failed hard drive is at least stupid. To access data, you need to configure FTP and Samba access. Of course, everyone has their own needs, so if you use MacOS or Linux, then you will probably need other protocols (NFS, AFP), but I will describe the setup as I did it for myself.
To access media data from smart TVs, we need a DLNA server. And for ease of downloading, we need a torrent client. Well, it is advisable to administer all this through the web interface.

Why not a hardware NAS?

It would seem that manufacturers have long taken care of users, and have long been producing ready-made boxes specifically for home use. But they have disadvantages:
1) They are expensive. You are unlikely to find cheaper than 20,000 rubles. NAS with the ability to connect 4 hard drives, With Atom processor. Those that are inexpensive usually use a weak processor, which is no longer enough for the same torrent when simultaneously downloading two data streams (watching a movie via DLNA and copying, for example, photos). I was able to assemble a full-fledged mini-PC based on a mini-ITX motherboard with Atom and 4 GB of memory for only 6,000 rubles!
2) They are limited. That is, it provides only those functions provided by the manufacturer. To expand its capabilities, “dancing with a tambourine” is usually required, since the kernel in the firmware can be greatly reduced. Using Ubuntu, you are practically not limited by anything - a huge repository of all kinds of software will allow you to do anything you want out of your server, including setting up virtual machines.

Why not FreeNAS or OpenFiler?

You ask. Firstly, see point No. 2 of the disadvantages of hardware NAS, that is, increasing the functionality of these distributions is very problematic, while Ubuntu has a huge repository of already configured software. Secondly, these are huge system requirements, in particular FreeNAS 8 requires a minimum of 2 GB random access memory, and new versions of OpenFiler are no longer released for the x86 architecture. In addition, FreeNAS is somehow not developing smoothly - version 0.7, which has a torrent client and a DLNA server, has long been outdated, in the eighth, commercial version I was never able to set up DLNA, and with the proposed ZFS file system it’s somehow difficult; in the event of a system failure, how would you restore the data? Difficult.

Why was the Server 12.04 LTS distribution chosen?

LTS (Long Term Support) is a distribution with a long period of support and updates. Since we need a server that, if possible, once configured, could easily work for years to come, it is better to choose this particular version of the distribution.
The Server version was obviously chosen, because ideally we don’t need to waste resources on graphical shell. Although if you are just getting acquainted with linux, or have already worked with the desktop version of ubuntu, then in principle you can choose the regular version of the distribution, this does not matter.

Let's get started

The installation is quite transparent, so I won’t describe it in detail. I’ll just dwell on the breakdown of hard drives in more detail.


I took a budget motherboard without hardware RAID support, and in my practice, the hardware RAID built into the motherboard often does not work well. the best side, therefore we will organize the so-called “software” RAID. Two brand new hard drives will be used to store data. I didn’t have any extra storage media, so I will split the disk into two partitions, one of which will be system, and the second for data. Both partitions on two hard drives will be combined into RAID 1 (for convenience, I perform all operations on a virtual machine, so do not pay attention to the small size of the partitions).
First, we create a partition table on the first disk and split it into two parts. We mark them as a “RAID partition”, although this is not necessary.


The second disk is broken in the same way. Then select “Setting up software RAID”. We say “Create MD device”, select the first partitions on two disks. Same with data sections. By the way, RAID can be dynamically changed and expanded, so if you only have one hard drive so far, but are planning to buy a second one, feel free to set it up, after purchase you can easily pick it up.


After creating a RAID, mark them for use. Select the ext4 file system and assign mount points: system partition as the root (/), and the data partition to an arbitrary location (I prefer to mount it in the /mnt folder).


Next, the system will notify whether we want to boot the system if the RAID array fails. I advise you to answer “no”, because if the hard drive fails, you won’t even notice it - the system will continue to work with one disk, but if the second disk also fails, then you will have to take them to a data recovery company.

I will not create a swap partition, because firstly, it can be made into a file, and secondly, I personally don’t need it - I have 4 GB installed on my mini-PC, and memory use never exceeded more than 10% (400 MB ), and in the normal state even less (right now only 130 MB are in use). Although if you plan to raise virtual machines, you may need it, so after installation I will describe how to create a swap file, but now we answer negatively to the proposal to create a swap partition.

After a short process of copying files, the system will begin updating data from the repositories, and then ask how updates will be installed. Since our system administration is reduced to a minimum, we choose automatic update. The system will then ask which packages need to be installed right away. I chose OpenSSH (we need a remote command line), LAMP (needed for the web interface), Print server (in this article I will not describe connecting a printer), and of course Samba file server for access from Windows machines.

Well, at the final stage, the system will ask for a password for MySQL and a request to install GRUB. Reboot - the system is installed! Let’s log in to see what IP address DHCP assigned us (this can also be done using the ifconfig command), in my case the address 192.168.1.180 was given.

That’s it, you can turn off the monitor and put the system unit in a convenient place, then we will work with it via SSH. I use PUTTY for this.

Configuration

1) swap file
First of all, I’ll describe how to set up a swap file, if you really need it, everything is done in just a few lines of commands.
Create a file filled with zeros: > sudo dd if=/dev/zero of=/swap bs=1M count=2048
Prepare it for use as swap: > sudo mkswap /swap
We add our created file to the fstab file to use as a swap file:
> sudo nano /etc/fstab /swap none swap sw 0 0
Reboot: > sudo shutdown -r now
2) software update
We immediately update all packages, this is done with two commands: > sudo apt-get update > sudo apt-get upgrade
3) Web interface
To manage the system via the web interface, there is a webim package, but unfortunately it is not in the repository, so let’s download the prepared package manually: > wget http://prdownloads.sourceforge.net/webadmin/webmin_1.580_all.deb
To install webim you will need some dependent packages, in my case this is the following list, you may need to include something else. > sudo apt-get install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl apt-show-versions
Well, the actual installation: > sudo dpkg --install webmin_1.580_all.deb
That's it, you can go to the web interface: https://192.168.1.180:10000
4) Set up ftp access
For ftp I use pure-ftpd (although you can choose proftpd and vsftpd to suit your taste)
Let's create a public folder: > sudo mkdir /mnt/data/public
Install pure-ftpd from the repository: > sudo apt-get install pure-ftpd
In principle, you can already log in under a system account, but this is not entirely good for everyday use. Let's create a virtual account with access only to the public folder: > sudo pure-pw useradd public -u local -g nogroup -d /mnt/data/public
Let's update the database: > sudo pure-pw mkdb
Let's enable the use of virtual users: > sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/50pure
Restart the service: > sudo service pure-ftpd restart
5) Samba
Let's set up access to the server from Windows machines; moreover, I personally have a large family at home and I need to separate rights between several users. And for convenient editing of folder rights directly from Windows (via the “security” tab in properties), we will use ACL.
We don’t have a domain, so we’ll have to create users the same as on Windows machines: > sudo useradd -d /home/PaulZi -s /bin/true -g users PaulZi
Set the password, the same as on Windows: > sudo passwd PaulZi
Add the created user to Samba: > sudo smbpasswd -a PaulZi
To manage extended rights, you can install utilities (optional): > sudo apt-get install acl > sudo apt-get install attr
In order for samba to work with ACLs, you need file system with POSIX ACL support, ext4 is fine, but it is mounted without this support by default. To enable this feature, add the “acl” option to the /etc/fstab file. But moreover, Windows supports inheritance of rights; in order to implement this in Linux, samba needs to store additional data somewhere. To do this, you need to enable extended file attributes, the “user_xattr” option. At the same time, we will prohibit the execution of files on the entire data partition using the “noexec” option (for security): > sudo nano /etc/fstab /dev/md0 /mnt/data ext4 defaults,noexec,acl,user_xattr 0 2
Reboot: > sudo shutdown -r now
Edit the samba settings (for brevity, I only list changes and additions): > sudo nano /etc/samba/smb.conf workgroup = Home netbios name = Server security = user # add settings admin users = PaulZi # these users will be operated from the root map acl inherit = yes # enable inheritance acl store dos attributes = yes # enable storage of dos attributes # disable windows storage attributes: map archive = no map system = no map hidden = no map readonly = no # public share comment = Public path = /mnt/data/public browseable = yes # the share is visible read only = no # enable writing guest ok = yes # allow guest access inherit permissions = yes # enable inheritance of rights inherit acls = yes # enable inheritance of windows rights inherit owner = yes # enable inheritance of the owner hide unreadable = yes # hide files that are not readable
Restart the service: > sudo service smbd restart
6) DLNA/UPnP - server
I chose minidlna as the DLNA server. I chose it for one simple reason: it does not drag along a bunch of unnecessary dependencies, like MediaTomb and Serviio (they pull Java or graphic libraries). However, if you need transcoding, I advise you to install one of them instead of minidlna.
Installation from the repository: > sudo apt-get install minidlna
Configure: > sudo nano /etc/minidlna.conf media_dir=/mnt/data/public friendly_name=Ubuntu
Restart: > sudo service minidlna restart
7) torrent
Well, the last service covered in this article is a torrent client. I use Transmission as a successful web-based client.
Install: > sudo apt-get install transmission-daemon
Stop the service, otherwise all changes will be lost after the process is completed: > sudo service transmission-daemon stop
Configure: > sudo nano /etc/transmission-daemon/settings.json "download-dir": "/mnt/data/public/torrents" "rpc-password": "local" "rpc-username": "local" " rpc-whitelist-enabled": false
Here we change four settings - set the download path, username and password for the web interface, and also disable the “white” list of access to the interface - allow it for everyone. The password is indicated in open form, after the next launch it will be encrypted.
Start the service: > sudo service transmission-daemon start
We go to the web interface, make sure that everything is fine: http://192.168.1.180:9091/

Afterword

As a result, we got a completely full-fledged home server. Of course, the article only shows basic service settings, and most likely you will need to customize something for yourself. Yes, and you may need some additional services, but as you can see from the article, all this is done quite simply, without any special “dancing with a tambourine”, you just need to turn to Google - for setting up services in Ubuntu information so many.

Although Ubuntu Server (even based on the name) is intended primarily for server equipment, it is also popular among those who like to customize the regular working system(including with GUI - graphical interface) “for yourself” from scratch, installing it yourself only required packages and applications. Ubuntu itself is very user-friendly, well documented, has a rich community (including Russian-speaking) and is perfect for beginners in the world of *nix systems.
? For installation, we will select the latest stable release (updates to which are guaranteed to be released until April 2021) - Ubuntu Server 16.04.1 LTS. You can install it either on bare metal, having previously prepared bootable media, or in a virtual machine (VirtualBox, VMware) So, let's begin.

  1. Download the image from the official website. To download the 64-bit version we need either a torrent file (ubuntu-16.04.1-server-amd64.iso.torrent) or an .iso image (ubuntu-16.04.1-server-amd64.iso). I prefer to download via torrent - higher speed. The image size is about 0.7 Gb (by the way, the desktop version weighs twice as much, 1.4 Gb).
  2. If the installation will be carried out on “real” hardware, then prepare bootable media (usb-flash, cd/dvd). Creating media is trivial (open the .iso burning program, select the image and media, burn the image to the media), I prefer to use UltraISO or UnetBootin to burn .iso images. If you want to try Ubuntu Server in a virtual machine, then just move on to the next step.
  3. Booting from bootable media, select Russian from the list, then select Install Ubuntu Server:

  4. In the next step, select your location, determine the keyboard layout and keyboard shortcut to switch between layouts (you can leave everything as default).








  5. The next stage is setting up the network. Enter the server name, after which an attempt will be made automatic settings network via DHCP. The server most often requires static IP address on the local network, we will make this setting later, after the installation is complete.
  6. Enter the name and password of your account (the password is preferably more than 8 characters, but less is possible, Ubuntu allows this, it will just ask you about it again). If you wish, you can further encrypt your home directory (the default is no).




  7. It has reached the crucial stage - disk partitioning. Of course, if you are experimenting with virtual environment, then you have nothing to be afraid of - leave all the default settings (Auto - use the west disk). But if you install Ubuntu Server to physical hardware with several disks with the necessary data - be careful! To avoid tearing your hair out later and to avoid confusion, I advise you to physically disconnect the “extra” media before installation.




  8. Next, in the package (update) manager settings, specify the address of your proxy (if available) and select the update mode. For the server system, for stability reasons, I strongly recommend abandoning automatic updates(default).


  9. Now let’s select what we need from the list software, which will be installed with the system. All of the above can be installed later without any problems, I recommend checking only the checkboxes standard system utilities And OpenSSH server(For remote control server via SSH immediately after installing the system).

  10. List of packages included in standard system utilities in Ubuntu Server 16.04

    manpages
    dnsutils
    bsdmainutils
    psmisc
    python3-gdbm
    ufw
    dosftools
    ed
    telnet
    powermgmt-base
    ntfs-3g
    ubuntu-release-upgrader-core
    iputils-tracepath
    python3-update-manager
    groff-base
    python3-disupgrade
    bind9-host
    mtr-tiny
    bash-completion
    mlocate
    tcpdump
    geoip-database
    install-info
    irqbalance
    language-selector-common
    friendly-recovery
    command-not-found
    info
    hdparm
    man-db
    lshw
    update-manager-core
    apt-transport-https
    accountsservice
    command-not-found-data
    python3-commandnotfound
    time
    ltrace
    parted
    popularity-contest
    strace
    ftp
    ubuntu-standard
    lsof

  11. It's time to install the main bootloader - GRUB. If there is currently only one media in the system, feel free to continue the installation with the default values. If there are two or more carriers ( installation flash drive also counts!) - then be careful and install GRUB on required disk(in the same place as the system itself), otherwise you won’t be able to boot later! Navigating between disks (for example, between HHD and USB flash) is often easiest based on size.
  12. Installation is complete, remove the USB flash drive and reboot. If everything went well, then after the reboot you will be greeted by a black screen prompting you to enter the account name and password (you specified during installation).

  13. First things first, let's set it up network adapter to have access to the Internet and/or local network. If at the time of installation of the system network cable was connected, then most likely the network is already configured via DHCP. If your local network does not have DHCP, or you need a static IP address, run in the terminal:

    sudo nano /etc/network/interfaces

    Enter your account password for sudo and a text file with network settings will open for editing. Find a section in the text # The primary network interface, in this section there will be a line iface eth0 inet dhcp(eth0 is the name of the network interface; if you work in a virtual machine, it may be called differently, for example, in my VirtualBox it is called enp0s3), which indicates that the network is currently configured to receive settings automatically via DHCP. Replace in the specified line "dhcp" on "static" and add 4 more lines from below static settings network interface, in the end your section should look something like this:

    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 192.168.1.101 //here we indicate the server IP address you need
    mask 255.255.255.0
    gateway 192.168.1.1 //IP address of your Internet gateway (router)
    dns-nameservers xx.xx.xx.xx xx.xx.xx.xx //IP addresses of your DNS servers, separated by a space

    After finishing editing, click Ctrl+O And Enter to save, then exit text editor (Ctrl+X). Let's reboot network interface by running in the terminal:

    sudo ifdown eth0 && sudo ifup eth0

    Let's check the network's functionality by pinging some highly available server:

    If in response there were lines with answers like this:

    64 bytes from www.yandex.ru (213.180.204.3): icmp_seq=36 ttl=53 time=43.0 ms

    So everything is fine. Stop ping ( Ctrl+C) and move on to the last stage of the initial setup.

  14. The final stage of installation and initial configuration Ubuntu Server 16.04 All packages in the system will be updated. Run in terminal:

    sudo apt-get update && sudo apt-get upgrade

    Enter your account password for sudo (if prompted), and agree (Y) to install updates from the Internet.<.li>

That's all. Ubuntu Server 16.04 successfully installed and ready to work, however, it does not yet perform any functions - web server, mail server, FTP server, file sharing server, etc. I will discuss the installation and configuration of these services in detail in separate articles.

Best articles on the topic