Simple yet quite quick way. So I wanted to document it.
Its no secret that I run Raspberry Pi as my server. So the following was done with
So I customized the image so that I could set my server up with SSH and wireless connection. After the initial setup I made the following commands:
nano wordpress-setup.sh
And for the text editor I made the following script that automates the process:
echo "Updating and upgrading system..."
sudo apt update && sudo apt upgrade -y
echo "Installing Apache, PHP, and MariaDB..."
sudo apt install -y apache2 php mariadb-server php-mysql
sudo systemctl restart apache2
echo "Securing MariaDB installation..."
sudo mysql_secure_installation
echo "Creating WordPress database and user..."
sudo mysql -u root -e "CREATE DATABASE wordpress;"
sudo mysql -u root -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost';"
sudo mysql -u root -e "FLUSH PRIVILEGES;"
echo "Installing PHP extensions for WordPress..."
sudo apt install -y php-curl php-dom php-imagick php-mbstring php-zip php-gd php-intl
echo "Downloading WordPress..."
cd /var/www/html/
sudo rm -rf *
sudo wget https://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
echo "Setting permissions for WordPress files..."
sudo chown -R www-data:www-data /var/www/html/
echo "Enabling Apache rewrite module..."
sudo a2enmod rewrite
echo "Configuring Apache for WordPress..."
sudo bash -c 'cat <<EOL > /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
</Directory>
</VirtualHost>
EOL'
sudo systemctl restart apache2
echo "Installing Certbot for HTTPS..."
sudo apt install -y snapd
sudo snap install core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache --non-interactive --agree-tos -m your_email@example.com -d your_domain.com
sudo certbot renew --dry-run
sudo systemctl restart apache2
echo "WordPress installation completed! You can now access your site."
After saving this file, it was then made executable
chmod +x wordpress-setup.sh
Then I just ran the script:
sudo ./wordpress-setup.sh
There are some sections that you have to answer like when setting up MariaDB
Made a typo with the password so that’s included in the picture, if you missed that.
This script updated, installed and did everything needed to have my site prepared to be built. Though I didn’t touch that I have DNS control, nor firewall.
If you are to do a site based around this – please note that I am not an expert at this.
So if in doubt, use another guide. But this was for my liking the best and the easiest as I wrote it into a automated format so I could do this once again if my server craps out again…