- How to run a linux based home web server
- The Connection
- The Hardware
- Domain name
- DNS server
- Configuring your server
- Fixing ddclient
- Configuring Apache2
- Optimize for bandwidth
- 4 Useful Tools to Run Commands on Multiple Linux Servers
- 1. PSSH – Parallel SSH
- 2. Pdsh – Parallel Remote Shell Utility
- 3. ClusterSSH
- 4. Ansible
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Ubuntu Linux: Start, Stop, Restart, Reload OpenSSH Server
- Start / Stop / Restart / Reload OpenSSH Server on Ubuntu
- Ubuntu Linux: Start OpenSSH Server
- Ubuntu Linux: Stop OpenSSH server
- Ubuntu Linux: Restart OpenSSH server
- 3 good ways to run Linux on Windows
- Old-school ways most people can ignore
- Windows Subsystem for Linux (WSL) 1
- Windows Subsystem for Linux (WSL) 2
- Virtual machines
- Which is best for you?
How to run a linux based home web server
There are plenty of places you can go if you just want to put up some static web pages for free, or very low cost. But costs go up very quickly if you need to do any more than that, or if you get spikes in traffic. Sometimes you need complete control over the server, and don’t want to pay $20 to $40 a month for a VPS. In this article, I’ll describe step by step how to set up a home web server using Ubuntu, capable of handling modest spikes in traffic.
There are several things you need:
- Connection
- Hardware
- Domain name
- DNS server
- Web server software properly configured for your system
The Connection
Many large internet providers forbid running any servers in their usage agreement. They might not actually check for a long time, but it’s no fun to have your Internet cut off without warning after months with no problems. You can only do this if you are lucky enough to find an ISP that allows servers. In Canada, try Teksavvy.
You will want as high an uplink speed as you can get. Unless your website is extremely popular, bandwidth caps will not be an issue, but be aware of what they are.
The Hardware
Over your home internet connection, traffic will be naturally smoothed by the low uplink bandwidth. Incoming requests will be queued and served in order, not all at once. CPU speed is not going to be an issue, and a one GHz machine is plenty of power. Although this blog’s web server has only 512 MB of memory, I recommend at least 1 GB of RAM.
Your router will also be an important part of the system, but quality varies. I have a Linksys WRT54GL. I downloaded and installed dd-wrt on it. The new firmware unlocks a lot of hidden features, including dynamic DNS updating. However, this is not strictly necessary, because your linux system can handle this step just as easily.
Domain name
You can get a domain name for 10 to 15 dollars. Try DomainsAtCost or GoDaddy. After you buy one from a registrar, you will get an account with them. After logging in, you can renew the domain name. But the most important priviledge is to be able to set the name server. That will have to wait until the next step.
A few months after getting your domain name you will start getting emails from companies claiming they have registered it in another country, and offering to sell it back to you. You can safely ignore these scams.
DNS server
Because your IP address will often change, you will need a dynamic DNS updating service. DynDns.com provides very good service, with updates taking effect within seconds. However, they do charge a fee. ZoneEdit provides a free service for up to five domains, although updates can take several minutes to propagate.
After signing up with a dynamic DNS updating service, you will get:
- a username and password
- IP addresses of nameservers
Save the username and password for later. Go back to your domain name registrar and enter the nameservers into their system.
Configuring your server
You will be prompted several times for your mysql root password. This is not the same as your linux root password. As long as you are behind a firewall, it is okay to press enter and leave it blank.
Now check that your web server works using a web browser browsing to http://localhost. Apache should show a default page telling you that it works.
Fixing ddclient
Unfortunately, the version of ddclient that you can install on Ubuntu 9.04 (and most possibly later ones) is screwed up. Lets fix it.
Edit /etc/ddclient/ddclient.conf. If you use zoneedit, the file should look like this. Replace username and password and domain with your true values.
Now erase the ddclient cache and restart it.
After a few minutes you should be able to get to your web server by entering your domain name. If things aren’t working, running ‘sudo ddclient —verbose’ will help you figure out what it’s doing.
Configuring Apache2
The KeepAlive setting keeps your server busy for a few seconds after a page is served, allowing clients to download images without starting a new connection. The default setting is far too long, and it would cause your server to choke under heavy load. Set KeepAliveTimeout to 1 or 2 seconds.
The MaxClients setting determines how many connections your web server can handle at one time. Each connection takes around 5 megabytes of unshared RAM, so you will have to set this value taking into account the amount of RAM on your machine, while leaving room for other system processes. For 1 GB, a nice safe value is 130, but your mileage may vary. If your server becomes unresponsive, reboot it and lower this number.
After any change to server settings, use «sudo apache2ctl restart» to safely restart everything. Your users won’t notice a thing.
Optimize for bandwidth
Type ‘sudo a2enmod deflate’ and restart apache to allow your HTML, scripts, and css files to be transmitted compressed.
If you use common Javascript libraries, use the Google hosted versions of them.
Include all your own CSS and Javascript in the same file as your HTML, so that only one page needs to be requested. During times of heavy load, 99.9% of your visitors only load a single page of your web site anyway, so it makes no sense to split things up into different files.
Источник
4 Useful Tools to Run Commands on Multiple Linux Servers
In this article, we will show how to run commands on multiple Linux servers at the same time. We will explain how to use some of the widely known tools designed to execute repetitive series of commands on multiple servers simultaneously. This guide is useful for system administrators who usually have to check the health of multiple Linux servers everyday.
For the purpose of this article, we assume that you already have SSH setup to access all your servers and secondly, when accessing multiple servers simultaneously, it is appropriate to set up key-based password-less SSH on all of your Linux servers. This above all enhances server security and also enables ease of access.
1. PSSH – Parallel SSH
Parallel-SSH is an open source, fast and easy-to-use command line based Python toolkit for executing ssh in parallel on a number of Linux systems. It contains a number of tools for various purposes such as parallel-ssh, parallel-scp, parallel-rsync, parallel-slurp and parallel-nuke (read the man page of a particular tool for more information).
To install parallel-ssh, you need to first install PIP on your Linux system.
Then install parallel-ssh using pip as follows.
Next, enter the hostnames or IP addresses of remote Linux server with SSH Port in a file called hosts (you can name it anything you want):
Save the file and close it.
Now run parallel-ssh, specify the hosts file using the -h option and a command(s) that will be executed on all the specified servers. The -i flag means display std output and std error as execution of the command on each server completes.
Pssh Run Commands on Multiple Linux Servers
2. Pdsh – Parallel Remote Shell Utility
Pdsh is an open source, simple parallel remote shell tool for executing commands on multiple Linux servers at the same time. It employs a sliding window of threads to execute remote commands.
To install Pdsh on your Linux machines, run the appropriate command below.
To run commands on multiple servers, add the servers to a hosts file as explained before. Then run pdsh as shown; the flag -w is used to specify the hosts file, and -R is used to specify the remote command module (available remote command modules include ssh, rsh, exec, the default is rsh).
Take note of the ^ before the hosts file.
pdsh – Execute Commands in Multiple Linux Servers
In case you do not specify a remote command to be executed on the command line as shown above, pdsh runs interactively, prompting you for commands and running them when terminated with a carriage return. For more information, see the pdsh man page:
3. ClusterSSH
ClusterSSH is a command line tool for administering clusters of multiple servers at the same time. It launches an administration console and an xterm to all specified servers enabling you to run the same command on all of them.
To use clusterssh, start by installing it on your local Linux computer as shown.
Now that you have it installed, open an admin console and an xterm on remote servers at once, as follows. To run a command on all the servers, click in the xterm input bar, and type your command; to manage a single host, use its admin console.
Clusterssh – Administer Multiple SSH Sessions
For more information, see the clusterssh man page:
4. Ansible
Ansible is an open source and popular tool to automate IT processes. It is used for configuring and managing systems, deploying applications and so much more.
To install Ansible on Linux systems, run the appropriate command below:
Once you have installed ansible, you can add your server’s hostnames or IP addresses in the file /etc/anasible/hosts.
Specify them in groups, e.g webservers.
Save the file and close it.
Now to check the uptime and users connected to all the servers specified in the group webserver, in hosts config file above, simply run the ansible command line tool as follows.
The -a options is used to specify the arguments to pass to the module and -u flag specifies the default username to connect to the remote servers via SSH.
Note that the ansible CLI tool only allows you to execute at most only one command.
Ansible – Run Command on Multiple Linux Servers
That’s all! In this article, we have explained how to run commands on multiple remote Linux servers at the same time using widely used tools. If you know of any tools out there for the same purpose, that we have not included in this article, let us know via the comment form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Ubuntu Linux: Start, Stop, Restart, Reload OpenSSH Server
I need to provide a remote access to my Ubuntu Linux based server. How do I start / stop, OR restart the ssh server under Ubuntu Linux operating system using command line options?
You need to run a script called /etc/init.d/ssh to stop, start, and restart the OpenSSH server. You can also use the service command to control a System V init script. If you are using the latest version of Ubuntu such as 12.04 LTS or 13.04+, you need to use upstart job based commands as listed below.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Ubuntu Linux with sudo command |
Est. reading time | 3 mintues |
Start / Stop / Restart / Reload OpenSSH Server on Ubuntu
Latest version of Ubuntu such as Ubuntu Linux 16.04 LTS or 18.04 LTS and others use the systemctl command to control ssh server on Ubuntu. Older version use the service command. To find out your Ubuntu Linux version, type:
lsb_release -a
cat /etc/*release*
Sample outputs:
Ubuntu Linux: Start OpenSSH Server
Type the following command:
$ sudo /etc/init.d/ssh start
OR
$ sudo service ssh start
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above servers, run:
$ sudo systemctl start ssh
Ubuntu Linux: Stop OpenSSH server
Type the following command:
$ sudo /etc/init.d/ssh stop
OR
$ sudo service ssh stop
Again for systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above server, enter:
$ sudo systemctl stop ssh
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Ubuntu Linux: Restart OpenSSH server
Type the following command:
$ sudo /etc/init.d/ssh restart
OR
$ sudo service ssh restart
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above server, execute:
$ sudo systemctl restart ssh
systemctl command in action on Ubuntu Linux desktop
Источник
3 good ways to run Linux on Windows
What’s the biggest company in the world that supports the Linux desktop? Red Hat? No. SUSE? Close, but no cigar. Canonical? You’re getting warmer. The answer? Microsoft.
At 2020’s Microsoft Build, CEO Satya Nadella announced that Windows Subsystem for Linux (WSL) 2 would support Linux GUIs and applications. With this programmers can develop native and cross-platform programs with tools like GNOME Builder, KDevelop, and Visual Studio Code.
Nadella was good to his word. Starting with the recently released Windows 10 2004 Build 19041 or higher, you can run real Linux distributions, such as Debian, SUSE Linux Enterprise Server (SLES) 15 SP1, and Ubuntu 20.04 LTS. With any of these, you can run Linux and Windows GUI applications simultaneously on the same desktop screen.
Why would you want to do this? Simple: While Windows is the top desktop operating system, everywhere else it’s Linux. If you are working in an organization that manages your systems and network, you probably get a Windows desktop to work on and are required to use Windows for many tasks. If you want to administer servers, use DevOps on the cloud, run supercomputer simulations, or develop programs for any platform other than Windows or the Apple ecosystem, you’re working with Linux. Even on Microsoft’s own Azure cloud, the most popular virtual machines (VMs) are Linux.
But, while Microsoft is now a full-fledged member of the Linux family, there are many ways to run Linux on Windows. Here are the best and the rest.
Old-school ways most people can ignore
You can still set up your computer to dual-boot Windows and Linux. I don’t know why most folks would bother to do this today. With dual-boot, just like the name says, you’re not running both operating systems at once. You’re choosing to run one or the other. This may be handy if you’re a Linux user who wants to run the occasional Windows-only game or application, but I’m hard-pressed to think of other use cases.
Cygwin is a Unix tool collection. With it, you can run a Linux-style shell on Windows. It will let you run some Linux shell programs, which have been recompiled for Cygwin on Windows. While somewhat useful, it was always a niche program, and its niche is even smaller today.
Another program that has largely outlived its usefulness is Wubi. This software enables you to install Ubuntu Linux on Windows 7, Vista, and Windows 10. Essentially, it lets you dual-boot Ubuntu, but instead of installing the operating system on your bare-metal hardware, it installs Ubuntu on a special file on your Windows partition, which it uses as your Linux drive.
Now, on to the best ways to run Linux with Windows.
Windows Subsystem for Linux (WSL) 1
If all you need is a Linux Bash shell and its associated commands—such as apt, ssh, find, grep, awk, sed, tar, vim, emacs, and diff—WSL 1 is all you need. You can also run popular open source programming languages such as Python, Perl, Ruby, PHP, and GCC. In addition, it supports server programs such as the Apache web server and MySQL database management system. It does this by translating Linux system calls into Windows calls and vice versa.
What you can’t do easily is run a Linux GUI, such as GNOME, KDE, or Cinnamon. To do this with WSL 1, you have to run an X Window terminal in Windows. Even for hard-core Linux power users, that is a bit much.
So, why bother? There are several reasons. First, if you’re working with a low-powered Windows 10 system, WSL 1 is ideal.
Rich Turner, Microsoft’s senior program manager of WSL and Windows Console, says when it was introduced in the Windows Fall Creators Update in 2017, «we [didn’t list RAM requirements] because, frankly, we don’t have any of note! If you don’t install WSL, we add no RAM footprint. If you do enable WSL, there’s a tiny 850 KB driver loaded briefly, and then it shuts down until you start a Linux instance. … So, basically, WSL’s RAM requirements are pretty much whatever the RAM is that you need to run each Linux binary, plus around 1MB of working set in total.»
Another reason is that if all you need from Linux is shell programs, which is often the case for system administrators, then WSL 1 is, well, all you need.
Microsoft, which will continue to support WSL 1, also states that if your project files must be stored in the Windows file system, you’ll get faster performance. In addition, if you must cross-compile the same files using both Windows and Linux tools, WSL 1 is, again, faster.
Windows Subsystem for Linux (WSL) 2
Unlike WSL 1, which relies on a translation level, WSL 2 comes with a full Linux kernel. The initial version of WSL 2 is based on the 4.19.81 long-term support Linux kernel. As Craig Loewen, Windows Developer Platform program manager, writes, «WSL 2 delivers full system call compatibility with a real Linux kernel and is [three to six times] faster compared to earlier versions of WSL.»
WSL 2 and your preferred Linux distro runs, in turn, on your Windows 10 built-in Hyper-V hypervisor. Yes, this means WSL 2 is a VM approach at heart. But unlike other desktop VM programs, it’s deeply integrated with Windows 10.
With WSL 2, Linux files are kept on a 256 GB virtual disk, formatted using the Linux-native ext4 file system. Linux file interactions are much faster—two to 20 times faster—when working with files on its native file system. WSL 2 uses the 9p file system protocol to support Windows access to Linux files and vice versa.
You can adjust the size of the virtual disk with each Linux distro. If you wish, and I suggest you do, you can also increase the available memory up from its default 2 GB to a more comfortable 4 GB.
Installing a specific supported Linux distro on WSL 2 takes just a few clicks and is almost as easy as installing any other Windows application. First, though, you must start by enabling Hyper-V and Virtual Machine Platform on your desktop. At one time, Hyper-V was available only on 64-bit Windows 10 Pro, Enterprise, and Education editions, but just enough of its functionality is now available on Home to run WSL 2.
While graphical Linux desktop apps are supported, in this initial release of WSL 2, you must still jump through numerous hoops to get them to run. At this point, WSL 2 is still more for people who are comfortable with the shell interface rather than GNOME or other graphical desktops. By the end of the year, I expect you’ll be able to run Linux graphical desktops easily on WSL 2.
Virtual machines
For now, if you want the best possible Linux experience, you need to run your favorite Linux distro in a VM. The two most popular desktop VMs are VMware Workstation or Oracle VirtualBox. Besides running WSL 2, if you have a 64-bit Windows 10 Pro, Enterprise, or Education edition, you can also use Hyper-V to run Linux VMs. The Windows 10 Home Hyper-V variant isn’t sufficient to easily set up and run ordinary VMs. You may run into performance problems on low-powered Home PCs with only 8 GB of RAM.
A VM can run any Linux on a sufficiently powerful PC. Generally speaking, any Windows 10 system with 16 GB of RAM should be able to run VMs. Even a Windows 10 Home PC with only 8 GB of memory can run VMs, but you may see performance problems on the Windows side.
The VM enables you to run a guest operating system on top of another operating system. From the guest’s viewpoint, it appears to be running on its very own PC. It’s actually running in a VM, which is a limited virtual sub-system of your PC.
With a VM, you can run a full Linux desktop with all the graphical goodies. Indeed, with a VM, you can run pretty much any operating system on Windows 10. For example, besides Linux, you can run Windows 7, Solaris, or even ArcaOS, a 21st century version of OS/2, in a VM.
VMs give you the widest possible operating systems choices. For example, Hyper-V, unlike WSL 2, enables you to run Red Hat Enterprise Linux (RHEL), CentOS, and FreeBSD.
Depending on your VM program, you can also work with both operating systems simultaneously. For example, with VirtualBox, you can copy and paste files between Linux and Windows 10 file systems.
The one problem with desktop VMs is that setting them up properly requires a lot of fine-tuning. Each hypervisor has its own configuration tools, and each operating system has its own requirements. For example, VirtualBox defaults to a 10 GB virtual disk for any Ubuntu-based Linux, but Linux Mint, which is Ubuntu-based, requires a minimum disk size of 12 GB. In my experience, you’ll get the best results from maximizing VM system resources from one-third to half of your PC’s total resources. If that proves to be too hard on your Windows 10 system’s performance, you can also retune the VM’s settings to a lower level.
Once set up, though, you should have no problems running Linux and Windows 10 simultaneously. I’ve been running Linux VMs on Windows since the days when Windows 2000 and VMware Workstation 2 were state of the art.
Which is best for you?
As always, the answer is «it depends.» If all you need now is a Linux shell, WSL 1 is fine. But eventually, Microsoft will want you to move on to WSL 2, and WSL 2 is an excellent choice. It’s improving rapidly, and you can expect by year’s end that it will be able to run graphical Linux desktops without any real work. It’s also the easiest Linux to set up at this time.
However, for a top-of-the-line simultaneous Linux and Windows 10 experience, you can’t beat virtual machines. It’s more work, but for now, VMs are also the most full-featured way to run Linux on Windows.
Whichever way you go, you can’t go wrong. We’re living in a golden age of Windows and Linux compatibility.
Источник