Home web server, or your own hosting provider

In order to make your web server at home, we need a computer and constant access to the Internet with an external IP address, as we will check later.

I will make the server from the old Samsung N102SP netbook with a broken keyboard, for small loads it is enough, moreover, it is small and does not make noise at all. The Internet at home is heard by a wifi router tp-link TL-WR840N, and through it I will connect my server.

I will put Centos 7 swing away minimally (Minimal ISO), the image is written to the stick with a program Rufus. Now you need to load the netbook from the USB flash drive, and here the first problem arises, since the keyboard does not work, I can’t enter the BIOS, it does not see the external usb keyboard, resetting the BIOS solves the problem (in the Samsung N102SP netbook, the BIOS is reset by closing the rtc reset contacts under the memory cover , you need to close it for 30 seconds), select the priority boot from the flash drive in the BIOS and start the installation, even with the minimum version Centos 7 is installed in graphical mode. There should not be any difficulties with the installation, we delete all the old partitions on the disk and give everything to Centos, set the root password and prescribe the network settings, in my case we connect to the wifi home network (this can be done later with the nmtui command), a few minutes and Centos 7 is installed.

We go as root. We stop the firewall with the command "systemctl stop firewalld", disable the firewall from startup with the command "systemctl disable firewalld". While we do not need it, we will configure firewall later. You also need to disable hibernation when closing the netbook cover, for this, in the /etc/systemd/logind.conf file, replace the line “# HandleLidSwitch = suspend” with the line “HandleLidSwitch = ignore”, then restart with the command “systemctl restart systemd-logind” .

Now you can put my netbook in a remote corner and forget about its physical existence, all further actions with your home web server can be done via ssh.

Now you need to configure the wifi router, in the case of tplink, open tplinkwifi.netthe default username and password are admin, in the “Status” section we look at the WAN status, the IP address must be static and should not start with 192.168.x.x, 172.x.x.x, 10.x.x.x, otherwise In the case, contact the provider and ask for an external IP, most likely this can be done through your personal account, my provider provided me with an IP for 90 rubles per month. All new settings must be registered in the "Network / WAN" section. Now we need to reserve the internal IP address on the router for our server, go to the “DHCP / DHCP Client List” section and find our server there (to find the IP on the server, type ifconfig command), then copy the MAC address and go to the “DHCP / Reservation of addresses ”and add the MAC address of our server and its IP there. That's it, now the router will always allocate this IP for our server. Now you need to forward the ports,so that when accessing from the Internet, the router sends requests to the home web server, go to the “Forwarding / Virtual Server” section and add 80 port. We also add port 22 so that you can connect to the server via ssh. When adding port 80, I got an error "The remote control port of the web interface is in conflict with the virtual server port." To avoid this, first change the remote control port to 8080, for this, open the “Protection / Remote Control” tab. Now router management is available atWhen adding port 80, I got an error "The remote control port of the web interface is in conflict with the virtual server port." To avoid this, first change the remote control port to 8080, for this, open the “Protection / Remote control” tab. Now router management is available atWhen adding port 80, I got an error "The remote control port of the web interface is in conflict with the virtual server port." To avoid this, first change the remote control port to 8080, for this, open the “Protection / Remote Control” tab. Now router management is available attplinkwifi.net : 8080 /

For remote control of the web server, it downloads Putty utilities from www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Now, for the fully functional web server to work, we will install the necessary components, first of all, connect the Epel repository, there is almost everything necessary for an automatic installation, enter the command “yum install epel-release”. Then, to monitor the status of the server, install htop with the command “yum install htop”, for convenient work with files install the midnight commander, use the command “yum install mc”, now install Apache, for this we enter “yum install httpd”, start it and put it into startup with the commands “ systemctl start httpd "and" systemctl enable httpd ", now install MariaDB with the command" yum install mariadb-server ", run and put into system startup" systemctl start mariadb "and" systemctl enable mariadb ", make initial settings using the command" mysql_secure_installation " , set root password,delete the anonymous user and the test database, then you need to install PHP with the necessary modules "yum install php php-mysql php-common php-mbstring php-mcrypt php-devel php-xml php-gd", reload httpd with the command "systemctl restart httpd". Now when you enter the IP address in the browser, we see the Apache welcome page. The root directory is located in "/ var / www / html /". Now our home web server is accessible from anywhere in the world.

All Articles