Are you interested in setting up a home web server? The easiest way is to install Linux on a replacement computer. The simplicity of Linux makes this straightforward and gives you an inexpensive way to host a website or blog.
Here's how to set up a Linux web server.
How to create your own web server on Linux
To create a Linux web server that can be run from home, you need the hardware and an operating system. In addition, web server software should be installed and a means for accessing the server via the Internet should be set up.
We can break this down into four easy steps that you can use to create your own Linux web server.
Find an old / unwanted computer
Install a Linux operating system
Set up the application web server software (Apache, PHP, MySQL).
Reach the server over the internet
1. Find an old computer for your Linux web server
Before choosing a computer as a web server, you need to know the minimum operating system requirements. Ubuntu is popular, but not easy enough. Instead, Lubuntu 19.04 is a stronger option. This is a lighter alternative to Ubuntu based on the same code.
Download: Lubuntu 04/19
Lubuntu system requirements
Lubuntu 19.04 has a minimum requirement of:
Dual-core processor with 512 MHz or better (1 GHz recommended, as opposed to 2 GHz for Ubuntu)
4 GB system memory
25 GB of free hard disk space
Optionally 32-bit (for older PCs) and 64-bit versions
You may have a suitable old PC on the back of a drawer or you picked one up at a thrift store. It's worth noting that you can install a Linux web server on a Raspberry Pi. Costing less than $ 30, this little computer is a smart option if you're having issues with old hardware.
Don't limit yourself to old Windows PCs either. Pre-2006 Apple Macs and MacBooks with PowerPC processors can run Linux.
Like Ubuntu, Lubuntu supports a wide variety of graphics cards, hard drives, and other hardware. Run the Live CD to verify that the distribution works on the hardware you selected.
If you plan to run the server around the clock, make sure it is in a well-ventilated area. It is better to put it in an air-conditioned room in the summer when the heat is the enemy of your server.
2. Install a Linux operating system
Installing Lubuntu is straightforward. Just take the ISO file and write it to DVD or USB flash device to get started.
These disk images have the latest software versions, so only a small upgrade should be required after installation. Use the 64-bit version if your computer supports it or the 32-bit version if it doesn't.
When you are ready, insert the installation media into your computer and restart it. If you need to change the BIOS settings to boot from the optical drive or USB, do so. In some cases a selection menu for the start medium can be opened.
When booting the installation medium, select Install Install Lubuntu. When prompted, choose Download updates during installation and Install third-party software and then Erase and use the entire hard drive.
Note that this will delete all other operating systems on this computer. Follow the other options as per your preferred settings. Encrypting your home folder does not make sense for a web server project. Restart when the installation is complete.
Check for updates on restart. Go to System> Administration> Update Manager> Install updates. You may need to reboot after installing the updates found.
3. Install the Linux web server software
While alternatives are available, most websites run on a combination of Apache, MySQL, and PHP (known as LAMP). This is similar to the installation we recommend on Windows.
All three tools can be installed through the Software Center. Start this over System> Administration> Synaptic Package Manager. Here we install the software we need.
Find and install the following package names, each of which has different requirements: apache2, php5, php5-mysql, and MySQL server. Apply the changes to install the packages.
The packages will be downloaded and installed shortly. The installation program prompts you for the MySQL password "root". No reboot is required.
Alternatively, you can install these tools from the command line. Then open a terminal:
sudo apt install lampserver ^ -y
Test your web server!
You can test the installation by opening the Firefox browser on your server and going to the URL http://127.0.0.1/. Alternatively, you can enter http: // localhost /.
You should get an "It works!" Message means your web server is running! Both Apache and MySQL run in the background and start at boot. If the web server is working now, you can edit the files in / var / www. Just refresh the browser to see the changes live on your website.
Find the local IP address of the server
While the server is functional, it must be visible to the outside world. It is therefore important to keep the server up to date with all regular patches.
First, find the server's local IP address and set it to something you can refer to later. The current IP address assigned by your router can be found in the Network Information field.
Find this by clicking your network connection and then selecting Connection information. A box will appear with your current IP address, network adapter card, broadcast address, gateway and DNS server. Make a note of the IP address.
Then edit your connection information to get a static IP address on your local network. Right click again but this time go to Edit connections. Select the appropriate adapter name (e.g. eth1) and edit these settings.
Choose IPv4 Tab and switch the method to Manual. click Add Then enter the information from your connection settings. Note, however, that the IP address must be entered differently. Keep the first three octets (the numbers between the periods), but change the last one to a high number below 254.
It is important that the manually assigned IP address is not already in use on your network. If you are not sure, choose a high IP address like 250. This is your static, local IP address.
Share the web folder
There are several options available for you to access files and upload them to your server. To illustrate the importance of folder permissions, consider sharing the web folder as an option.
It is important to only use this method if your server is on a private network. Make sure that nobody can connect and access your shared folder.
Start by relaxing the permissions on the web folder. Open a terminal by pressing Ctrl + Alt + T and type:
sudo chmod 777 / var / www
You will be asked to enter your password. If this is correct, the permissions will be updated.
Now go to the file browser and search / var /. Right click the www folder and select Share options and disable it. For security options, you can unlock it with or without a password. Choose Guest access to share the folder without needing a username and password.
Now you or anyone else can access the files without a password. For this reason, sharing with a password is recommended for security reasons. Also, take a moment to check this out Allow others to create and delete files in this folder. This enables write access from the shared directory.
Go to the network location to view your files // localhost / www.
Depending on your security settings, you will either be prompted for your password or you can access your files directly. These are the same files that can be accessed in your web browser through http: // localhost / (or whatever static IP address you set).
Bring your Linux server online with port forwarding
Now you have an IP address. An important concept to understand is port forwarding. Every single person who is connected to the Internet has an IP address. For most home (and many business) connections, your computer's IP will not be exposed to the Internet. – –
How do visitors to your website contact your server? We do that with port forwarding.
Ports on a server are like doors or windows in a house and as such have an impact on security. Each port gives you access to a different service running on the server. By default, web servers use port 80.
To activate this, you need to log into the administrator page of your router. For more information, see the documentation that came with the device (some routers have the IP address printed on the back). Here you should find a section called Port forwarding, or Applications This will allow you to properly forward the ports.
Forward the TCP port 80 within your network to the previously specified static IP address. Every router is different. Refer to your router's operating manual for information on proper setup.
Give your Linux web server a static host name
Most home routers connect to an ISP using something called dynamic IP. This means that your router's publicly available IP address will change after a set period of time, usually around a week.
One way to work around this is to use the fantastic DynDNS server which allows you to set a DynDNS URL for your site. Thanks to a client app, the URL continues to point to your Linux server every time you change your public IP address.
So visitors should be able to visit your web server from outside by walking http://yourhostname.dyndns.org. Some ISPs block port 80 from your router. In this case, you're forwarding something like port 8080 to port 80. That way you can visit your website by going on http://yourhostname.dyndns.org:8080.
You have created a Linux web server!
After your web server is set up, you can concentrate on programming or installing your own software!
Maybe you run blog software, or you host a forum or bulletin board. You might be more interested in hosting a social network like Mastodon, a portfolio. It depends on you.
Nowadays you can host a website on almost anything. Here's how to turn your Android device into a web server to prove it.
Another TikTok deadline goes by without a ban in sight
The December 4th deadline has passed and TikTok is still not banned in the US.
About the author
(1422 articles published)
Deputy Editor for Security, Linux, DIY, Programming and Technology explains. He also produces The Really Useful Podcast and has extensive desktop and software support experience.
Christian is an employee of Linux Format Magazine and a Raspberry Pi hobbyist, Lego lover and retro gaming fan.
More from Christian Cawley
Subscribe to our newsletter
Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive deals!
One more step …!
Please confirm your email address in the email we just sent you.