So basically I got fed up with using a free hosting provider for my person website. I kept getting resource limitation errors, doubtful through my own sites use, but probably by other users on the same server.
Thus, I am embarking on this project to load Linux on a Raspberry Pi, get a web server up and running and then point my domain registration at my static IP address.
Step 1: Set Up Your Raspberry Pi
There are already a heap of great tutorials on how to get a Linux image up and running on your RPi so I wont go into detail here, all I will say is that for my project I am running UbuntuMate and used Etcher to 'burn' the image to an SD card. This project will now assume you have setup and know the IP address or your RPi.
Step 2: Install Apache Web Server
The first step to make the server accessible from the outside world is to install Apache. To begin the installation of Apache use the following command:
sudo apt install apache2
To ensure the web server continues to be accessibl efrom the outside world upon a server restart the following command needs to be executed:
sudo systemctl start apache2.service
The web server should now be accessible in a browser via the public IP address.
Step 3: Install MySQL Server
This server is to serve dynamic content via the web server, to enable this a database server application is required, the package selected for this server is MySQL. To install MySQL use the following command:
sudo apt install mysql-server -y
To ensure MySQL is as secure as possible use the following command:
sudo /usr/bin/mysql_secure_installation
Finally to ensure MySQL starts on every serverrestart run the following command:
sudo systemctl enable mysql.service
Step 4: Configuring MySQL Server
The MySQL instance needs a database and user created and permissions configured. Login to the MySQL server using the following command and enter the root password:
sudo mysql -p
Next run the following commands using the database values you have selected for your server.
Create a database:
create database <Database Name>;
Create a user and apply privileges to database:
grant all privileges on <DatabaseName>.* to '<Username>'@'localhost' identified by "<Password>";
Flush privileges and exit:
flush privileges;
exit;
Step 5: Installing PHP
The next step to enabling dynamic content to be served from the web server is to install the PHP service. This will allow server-side coded files to be compiled into HTML by the server. To install PHP use the following command:
sudo apt install php -y
PHP has several packages that need to be installed to ensure any PHP pages can connect to other various services installed on the server. To achieve this execute the following command:
sudo apt-get install -yphp-{bcmath,bz2,intl,gd,mbstring,mcrypt,mysql,zip} && sudo apt-getinstall libapache2-mod-php -y
Finally Apache should be restarted to ensure all components are loaded using the following command:
sudo service apache2 restart
Step 6: Install WordPress
To install WordPress first download the WordPress compressed file to the server use the following commands:
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
Once complete decompress the archive, however due to the files being extracted into a WordPress folder they will also need to be moved into the default html folder, the following commands will be required:
sudo tar -xzvf latest.tar.gz
sudo mv -v /var/www/html/wordpress/*/var/www/html
The final step before installing WordPress is to ensure index.php is the first file processed by the web server when requests to the root domain are made. To do this execute the following commands:
cd/etc/apache2/mods-enabled/
sudo nano dir.conf
In the nano text editor find the Directory Index line and add index.php directly after “DirectoryIndex”.
Now navigate to the website in your browser of choice, you should be greeted with the WordPress installation screen.
Click ‘Let’s go!’ to proceed with the installation, you will be required to type in the details of the MySQL database and user as defined earlier. If you are running additional wordpress servers you may want to change the table prefix, however for most installs the default configuration is fine.
If after submitting the database settings the website states it cannot write to wp-config.php as shown in below then you can manually edit the file from the server.
Select the entire text block from the webpage for copying into the wp-config.php file. To edit the wp-config.php file, or create a new one if not existing, use the following commands:
cd /var/www/html
sudo nano wp-config.php
If the file has text in it delete all existing text then right click in the screen to paste the copied text. Type CTRL+X, then Y, then press enter to save the file in the html folder as wp-config.php. If prompted to overwrite a current file confirm.
Once complete you can click ‘Run the installation’ on the webpage. You will then be asked for additional information (as below), enter the information as previously configured.
Once entered click ‘Install WordPress,' then ‘Log In’ enter your username and password from above and click ‘Log In.' You will then see the Wordpress administration back end.
Step 7: Creating an Enclosure (Well, Thinking About It At Least)
Now that we have a completed web server its time to work on the case. Obviously you will need to install templates and update pages but that's outside the scope of this project log, plus again there are heaps of pages dedicated to that sort of thing.
Since we want the RPi to run all the time and serve our webpages, we need to put it in an enclosure. However we also don't want power interruptions to corrupt out operating system or site files. So our enclosure also needs to have steady power of a sufficient amperage, a battery backup for blackouts and a soft reset/shutdown button for those times we might actually want to shut it down but not have remote access or a kb/screen connected (remember its a web server, not an everyday use machine).
Step 8: Designing the Power Circuits
Step 9: Designing the Enclosure
Progress photo
Steps and design files to come
Step 10: Putting It All Together
Step 11: We're Finished!
Step 12: Improvement Notes
Comments
Please log in or sign up to comment.