There are many free services on the internet to host your own website or personal blog. But if you want to control the whole process, you can create a web server yourself in which save your files, documents, pages and share them on the internet. It’s inexpensive, it’s easy to install and configure, and you only need one Raspberry Pi.
The hardware part is cheap. A Raspberry Pi costs between 40 and 100 euros depending on which Raspberry model you choose and what elements you add: case, additional memory, power supply … And the software part has never been so accessible for the average user. Thanks to LAMP already WordPress, you will be able to mount a complete and easy to configure web server.
LAMP is the acronym for Linux, Apache, MySQL, PHP, everything you need to start a fully functional web server. And adding WordPress, you can set up a web page with professional templates and upload the content you want without going through an intermediary miles away.
Ingredients needed
As in a cooking recipe that abounds in current cooking shows, the necessary ingredients are few and affordable. What’s more, we have already mentioned them before. So if you already have a Raspberry at home, you will have little to do.
Hardware, you will need a Raspberry Pi with Raspbian or Raspberry Pi OS installed. This is usually the default setting when you buy a Raspberry alongside one SD card already formatted. As it is a web server, you will only need the basic components, such as the current feeder, the Case to protect it from dust and / or a heat dissipator. Keyboard and mouse they will only be necessary for the first configuration and, from now on, configure it locally. Bear in mind that a web server can be configured remotely from another computer or equipment connected to the internet.
As for the software, we will install everything through Terminal, so you don’t need to download files in advance. We will simply execute orders and Raspberry will do the rest connected to the internet through its operating system Raspbian or Raspberry Pi OS.
Install Apache web server
We said that we are going to create a web server with Raspberry using LAMP and WordPress. LAMP is the acronym for Linux, Apache, MySQL, PHP. We already have Linux represented by Raspbian or Raspberry Pi OS. Although you can use another operating system, usually based on Linux, to use on your Raspberry. Now tap on Apache.
Apache It is the web server software that we are going to use. It is one of the most popular and has been the most widely used for years. At present, it occupies the second place, only surpassed by Nginx. To install Apache on your Raspberry you will only have to open the Terminal (Accessories> Terminal) and execute the command sudo apt-get Install apache2 -y which will install the software automatically. Just in case, you can previously execute the orders sudo apt-get update and sudo apt-get upgrade to update the operating system and all its installed packages.
Once the Apache web server is installed, we will check if it works by loading its default HTML file. You can open it by loading the link http: // localhost in your web browser. That file can also be loaded with the local IP of your Raspberry. If you don’t know it, ask the Terminal with the order hostname – I (capital i).
Install PHP
Before moving on to MySQL we are going to install PHP. The command to do it in the Raspberry Terminal is sudo apt-get Install php -y. Once installed, we will check if it works by creating a PHP file with the command sudo mousepad index.php and writing the classic introductory message php echo "hello world"; ?>. We save the file and delete the file index.html original to replace it with this other one. To erase it, we issue the order sudo rm index.html and then we go back to http: // localhost.
If we don’t see the message we wrote in the PHP file, try restarting the Apache web server with the command sudo service apache2 restart and then reload the local link from the server.
Install MySQL
We already have Apache and PHP. The next step is to install MySQL, the database software. However, instead of using MySQL we will opt for a free and open version, MariaDB. They are compatible and serve the same purpose.
We will install MariaDB together with the PHP-MySQL packages with the command sudo apt-get install mariadb-server php-mysql -y. Then we will have to restart Apache again with the command we saw before, sudo service apache2 restart.
Install WordPress
Unlike the previous steps, installing WordPress will take us longer. First of all, from the Terminal we go to the folder / var / www / html / where we have installed Apache and where we have the page index.php Of start. To do this, we launch the command cd / var / www / html / and later sudo rm * to delete all files in that folder.
Now yes, we download the most recent version of WordPress with the command sudo wget http://wordpress.org/latest.tar.gz using the tool wget. Once the compressed installation file has been downloaded, we extract its content with sudo tar xzf latest.tar.gz and we move that content to the directory in which we are with the command sudo mv wordpress /. that we will execute in the Terminal.
Finally, we will give the Apache user permissions to manage those files. For this we will launch the command sudo chown -R www-data:. in the Raspberry Terminal. We are almost done.
Configure the WordPress database
We return to MySQL temporarily by launching the command sudo mysql_secure_installation in order to configure the database that WordPress needs to run on your home web server. You will have to answer several questions to make the configuration effective.
First, when asked to enter the root password, we hit Enter. Then we press Y (Yes, Sí) to the question about creating root password. On New password type a password hit Enter. Make it different from your Raspberry user.
You should also answer with Y to the following questions, such as deleting anonymous users, deactivating remote root login, etc. When finished, you will see the message All done!
Once MySQL / MariaDB is configured, we create the WordPress database with the command sudo mysql -uroot -p followed by the root password that we have set before. The prompt by MariaDB. There, we launch the order create database wordpress; what the message will show Query OK, 1 row affected (0.00 sec) or similar.
Then we enter the order GRANT ALL PRIVILEGES ON wordpress. TO ‘root’ @ ‘localhost’ IDENTIFIED BY ‘YOURPASSWORD’; where YOURPASSWORD It is equivalent to the password of your current Raspberry user. Finally, issue the order FLUSH PRIVILEGES; and get out of the prompt of MariaDB with the CTRL + D keys.
Last step. Restart your Raspberry with the command sudo reboot and, finally, you will only have to configure WordPress. The good news is that its configuration is done from a graphical interface through the web browser. You must indicate the IP of your Raspberry or, failing that, the address http: // localhost that we already saw before.
You can choose a language, give your website a name, create a user, etc. When finished, from now on you can configure WordPress from http: // localhost / wp-admin as well as publishing articles, changing their design, installing and configuring templates, etc.
Now you have your own home web server with everything you need to create a personal or professional website and make it accessible on the internet. The next step will be to hire a domain name, free or paid, to access your website without having to type the IP address.