📜 ⬆️ ⬇️

We organize your hosting with 0, or the story of one sleepless night

Hello, dear habrasoobschestvo.

Today I want to share the story of creating one small but brave hosting with my own efforts. Material costs were almost no. The goal was to organize the work of a couple of dozen lightly loaded sites of their friends and colleagues, the ability to share files, use the database, or test their scripts online. In general, someone what. Under the cut - an illustrated extract of working councils, obtained as a result of one sleepless night, colored by dancing with a tambourine, smoking incense and other essential attributes of the settings of any server. Especially recommended for those who, like me, try this magic for the first time.

So let's get started.

Initial data:


There is a local area network on 3 computers. One (comp1) distributes the Internet, the other two (comp2 & comp3) are connected to the Internet via the first. On comp1 - Win Server 2003, on the rest - XP. The channel thickness is 8 Mbps. IP is static white. Only comp2 (Phenom X4, 4 Gb RAM, 750 Gb HDD, good cooling and power supply, does not make noise during continuous operation, is connected to UPS) has sufficient resources for organizing a slightly less acceptable hosting. The remaining important attributes - a can of coffee, cola and a bunch of sweets to lift the mood.
')

We prepare the workplace, we lay out the tools.


So, for starters, I decided to demolish comp2 XP and put the usual Ubuntu 11.10 on it. I don’t want to breed another holivar here, I’ll just say that I did it because this system is closer to me + according to the advice of the “older comrades”.

So, on comp2, Ubuntu began to be put.

Naturally, there were no surprises. I went through a couple of simple dialogs, such as setting the time and regional settings, selected and formatted 1 SATA disk for 750 Gb. After a few minutes, the experiment platform was ready.

First, damn it!


Obviously, the first thing I did (apart from the general upgrade) was installing the necessary server hosting: Apache, MySQL and php connection. I decided not to bother and installed everything in one LAMP bundle (sudo apt-get install php5 mysql-server apache2), went through a simple dialogue on setting up all these miracles - animals, restarted Apache (sudo service apache2 restart) and under the local host saw the welcome “It works ! And then, from another computer (its IP is different from mine. Then it happened quite by accident, but then it will be important), having requested my external ip, I did not see anything . Joy diminished.

Mice injected, but ...


However, it soon became clear that the problem lies in the fact that the request from the outside comes to comp1 (from Win Server 2003) and goes out on it. Googling has led to the understanding that it is necessary to publish a port for access from the Internet to an internal server. The instruction was located here . The server began to respond to requests

Easy to rule, difficult to manage (Goethe).


Hosting management, acquaintance with Webmin

Now you can go to the settings of Apache. I didn’t have time and desire to mess with the configuration files manually, so I turned to look for some control panel. I tried to test the ISP manager, but, as a result, I stopped at Webmin.

When you first enter her admin panel, you wonder how much different information there is and how beautifully it is structured. Seriously, it's just convenient to use.

More sites, beautiful and different!

Now I faced the following questions: how to make
0) The site was not stored anywhere (for example, in / var / www) but in the place where I need
1) The site was not one and at any time could be requested by its DNS from the external network.

To solve these questions, I used Gparted - I made another 1 section of the required volume, then another one and ... everything. The system said it had reached the ceiling for the number of main sections. The solution to the problem was to separate the extended section and break it down into separate logical ones .
Since the system was spinning on the same disc, it was impossible to do it directly from under it. I had to create LiveUSB with LinuxMini and perform the above operations from under it.

Valera, it's your time!

When all the necessary space was allocated, it was time to use Webmin to create virtual hosts. Hmm, then I had little idea what it was. Google, Google ... So I learned about ip-based and name-based virtual hosts (for reference, in the simplest sense - ip-based, this is when each site on the hosting has its own separate address, and name-based - all sites are located on 1 general address). Obviously, in my case the option with name-based came up. The article on setting up this whole affair, which was advised to me by one network friend, clearly saved me several thousand nerve cells.

DNS.


There were no problems with DNS problems, I registered one domain and sent it to my ip a couple of days before that night. I just want to point out that for some reason I have heard many times statements about the fact that domain names need to be bought only from registrars, although there .ru cost about 600 rubles, when I bought one for one of the hosters for 150. Probably there is some pitfalls.

Dawn.


The coffee was over and it made me switch to cola, but by this time I already had a platform that allowed me to place all the necessary sites and allocate any required space to them (of course, within the disk space).

Finishing touches and minor problems (wherever without them)


Obviously, now was the time to think about how to remotely manage the files and MySQL databases located on the computer in the future.

For file management, I installed the proFTPd FTP server and the Gadmin graphical frontend. Everything fell without problems, the server reported from the console about its launch. A minor problem arose when Gadmin was started up - it required some certificates. Everything was decided after reading this article on setting up an ftp server (it was necessary to comment out a few lines in its configuration file).

Remote control of the muscle.


For this purpose, phpMyAdmin was installed, the necessary databases were created, and the necessary privileges were distributed to users. Here, too, was not without oddities. For example, when entering the site address of the form “mysite.ru/phpmyadmin” after logging in, the system displayed the error “Cannot start session without errors, please check your PHP and / or webserver”. there was very little time left, I decided to score on it and use the hack described in this article .

In the last step, I set up a mail utility on this manual to automatically send cron messages to friends about how I can keep their sites at home for various buns and / or beer.

Thus, by the morning, when all the homeworkers woke up, frowning disgustedly at the alarm clock calls, I had ready-to-use hosting that supports the ability to remotely manage files and the database and that already contains one working site.

So this story got a happy ending and it was possible with peace of mind to go for a couple about computer networks.

Source: https://habr.com/ru/post/142157/


All Articles