How to install a personal web server


Paying someone to host your website can be tempting. There’s usually a point-and-click installation for all the services you need, along with cheap monthly prices that include storage and maintenance, and there’s often generous bandwidth allocations too.

It’s not a lot of fun though, and if you want to add advanced features – such as shell access to your server or an unshared host – the costs add up quickly.

Serve yourself

The solution to all of these problems is to run your own server, and it’s not as difficult or insecure as you might think.

With the latest version of Ubuntu, for example, you can install the Apache web server with just a few clicks, and since this is the LTS (or Long Term Support) version, you will receive five years of security updates for free. (Desktop version is only supported for three years). As long as your system is up to date and your passwords are secure, it is very unlikely that someone will be able to break into them.

Combine that with the download speeds that a lot of people enjoy at home, and you’ve got a viable alternative to cheap shared hosting that’s fun to set up, gives you more control over setup, and is better suited for sites at. low bandwidth that many of us love to run as a hobby.

You will also learn a lot in the process. That’s why we’re going to show you how easy it is to create a Linux server, install a LAMP stack on it, get Apache running and serve web pages, and then install the content management system on it. most popular in the world – WordPress.

Ubuntu server

After that, world domination is up to you and your kitchen / 80s / analog monosynth platform games blog. Unlike the Live Desktop CD that most regular users use to install Ubuntu, the Server Edition prepares you for life on the command line by sticking to it.

This isn’t as bad as it sounds, as it’s really just a series of menus. You are also asked almost exactly the same questions as for the desktop version, so no additional skills are required.

Boot from the Ubuntu server CD and choose “English” and “Install Ubuntu Server” from the options that appear. Now choose your language, time zone, and keyboard layout again.

After a short setup time, you will come to the network section. First, it asks for a host name; you just need to make sure it’s a unique name rather than letting all the machines on your network use ‘ubuntu’. Now enter a username and password. You want to make them as secure as possible – using an unpredictable name and tough password, for example – because you don’t want someone guessing the values ​​if you’re running SSH for remote access.

Partitioning

Partition disks

The next major step is to partition the disk, and the easiest approach is to give the server a full disk. We also recommend the second option of the disk partition menu, as it formats the entire disk with an LVM configuration.

LVM is a disk management system that creates virtual partitions from one or more disks, and that means you can easily expand them as your needs grow, without the tedious tasks of migrating data from a disk. to another.

Answer all other questions with their default values. Be warned, this will delete all data on the drive you have chosen.

Leave the package management proxy question blank, but in the next question we suggest that “Install security updates automatically” is a better choice than the default, especially if you leave the machine running and connected to Internet.

Choose a server

LAMP server

The last step of the installer allows you to choose one of the servers you want to install. This is how Ubuntu can handle processes from boot without any further interaction on your part, so it’s a good idea to at least install the base packages.

We recommend that you select OpenSSH server and LAMP server as a good starting configuration. OpenSSH is one of the most powerful tools available for Linux because it allows you to access the command line securely from any remote location, as long as port 22 is passed to your machine through any location. what a firewall. It also means that you can disconnect the keyboard, mouse, and monitor after setting up your server machine on your local network, as you will be able to do everything else using a remote SSH connection.

You’ve probably heard of LAMP. It stands for Linux / Apache / MySQL and PHP, and these four technologies have helped transform the World Wide Web for companies like Facebook and Twitter.

Apache is the web server itself, allowing you to host sites and access them from across the network.

MySQL is a database server, commonly used by WordPress to store items such as posts, comments, and forum discussions. It might sound a bit “business” to install something like this on your humble server, but it’s a service that works well on slower machines and can scale to meet your needs. You can give the installer a root password for this, which we recommend if you are going to use it online.

PHP is the programming glue that ties it all together. Don’t let the talk of programming put you off, though. You typically install pre-made PHP packages rather than coding your own solutions, so you never need to mess with the code.

Port forwarding

With your servers selected, continue with the installation. After a few minutes, the last question will ask if you want to install the Grub bootloader in the master boot record. You should select “Yes” unless you are running your server alongside a Windows installation. You can then restart your machine and remove the startup disk.

After restarting, you will not see a desktop or graphical login screen. Instead, you’ll see a monochrome command prompt asking you to sign in. Use the account credentials you created from the installer to log in and you will end up at the command line.

We want to find out the server’s IP address first, and that should be shown as part of the connection preview that you see above the command prompt. Look for the line “IP address for eth0”. This IP address is important because you want to run your machine as a server. On most networks, it will be provided to your machine by a DHCP server running somewhere on your local network, usually hidden on your router or modem. Most of the time this address will be the same, but there is no guarantee as it is dynamically allocated based on demand.

With the server up and running, the easiest solution for most routers is to use its web interface to give our Ubuntu server a static address. Every router is different, so we can’t provide instructions, but it’s usually a straightforward task.

While you are in the web interface, you will also need to open a few ports in your firewall and then forward them to your Ubuntu server. These ports will depend on the servers you are using, but for a Web and OpenSSH server they will be ports 80 and 22 respectively.

Discover the server

Apache works

All the configuration is required. You can now point a browser to the Internet IP address provided by your ISP or the IP address of your server on the local network. The infamous “it works!” »The message will be delivered by Apache.

Your server is now ready for your web masterpiece. This is not the place for a tutorial on HTML or PHP, but the /var/www/index.html is a good place to start, as this is what is read to create the file ‘It works!’ messages served by Apache. Edit this file and your website changes.

The other server we installed was OpenSSH, and you can also use it from any SSH client – Putty on Windows, for example, or the ssh command from any Linux machine. Type ssh followed by your server’s IP address and you will see the same login screen you do when you start your machine. Log in and you can do whatever you can from the machine, only remotely. This means that you can now hide your server somewhere and use a dial-up connection when you need to change things, either from the Internet or from your local network.

Most people don’t build a website from scratch (although the world could be a better place if more people had to), so we’re going to install a pre-built web framework that should make it easier to get your content live. from your own server.

The software we are going to install is WordPress, which is probably the most popular blogging platform in the world. But there’s more to blogging – it’s a comprehensive, easy-to-use content management system that can be easily augmented and themed using its fantastic plug-in system. All it needs are Apache, MySQL, Linux, and PHP – which we’ve covered before.

Install WordPress

Wordpress

The first step is to get the Ubuntu packages for WordPress by typing sudo apt-get install wordpress. Unfortunately, this does not include any configuration.

Once the packages are installed, we first need to create a symbolic link from the folder where WordPress is installed to the folder that Apache uses to serve the content.

This can be done by first deleting the old www folder with the command sudo rm -rf / var / www, then replacing it with the link by typing sudo ln -s / usr / share / wordpress / var / www /.

Now we need to run a script that will automatically create the MySQL database for us. This can be done with the following command: sudo bash / usr / share / doc / wordpress / examples / setup-mysql -n wordpress 192.168.133.54

Here ‘wordpress’ is the database username and ‘192.168.133.54’ is the IP address of the server you need to access it from. If you want to access from the Internet, this should be the IP address of your connection rather than that of the server on your local network.

Hopefully, when you point your browser to the server, the ‘It Works’ message will have been replaced with the WordPress install screen.

The final steps are to walk through this easy install to create the required configuration. Just enter a site name, email address, and password. Moments later, you’ll end up with a full-fledged WordPress installation. Log in and start playing.


Comments are closed.