Raspberry Pi WordPress LAMP Server - JUST the commands you need to make it work!

If you have a Raspberry Pi and would like to turn it into a web server to host your own WordPress website, here are all the commands to make that happen. There is no fluff, just copy the commands one-by-one and you'll have your site up and running in no time!

INSTALLING ALL APPS

sudo apt update && upgradesudo apt install apache2sudo apt install mariadb-serversudo mysql_secure_installationsudo apt install php-fpm php-mysqlsudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zipsudo systemctl restart apache2

MySQL CONFIGURATION

sudo mysql
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER  'USERNAME'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL ON wordpress.* TO 'USERNAME'@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
FLUSH PRIVILEGES;
mariadb -u USERNAME -p
SHOW DATABASES;

ALLOW PERMISSIONS TO THE MAIN WEBSITE DIRECTORY

sudo mkdir /var/www/yourdomain.com
sudo chown -R $USER:$USER /var/www/yourdomain.com
sudo chown -R www-data:www-data /var/www/yourdomain.com
sudo find /var/www/yourdomain.com -type d -exec chmod 750 {} ;
sudo find /var/www/yourdomain.com -type f -exec chmod 640 {} ;

SERVER CONFIGURATION

sudo nano /etc/apache2/sites-available/yourdomain.com.conf
<Directory /var/www/yourdomain.com>AllowOverride All</Directory>
 
<VirtualHost *:80>ServerName yourdomain.comServerAlias www.yourdomain.comServerAdmin USERNAME@localhostDocumentRoot /var/www/yourdomain.comErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>
*Ctrl-X, Y, Enter*
sudo nano /var/www/yourdomain.com/.htaccess
# BEGIN WordPress <IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress
*Ctrl-X, Y, Enter*

ENABLE SITE ON SERVER

sudo a2enmod rewrite
sudo a2ensite yourdomain.com
sudo a2dissite 000-default
sudo systemctl reload apache2

INSTALL WORDPRESS

cd /var/www
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo rm latest.tar.gz
sudo mv wordpress yourdomain.com

RELOAD APACHE TO ENSURE ALL SERVICES ARE STARTED

sudo systemctl reload apache2

REMINDER


 
*Verify port 80 AND 443 are forwarded on the router to your device*
 
*Remember to change your WordPress General settings to use https:// instead of http://*
 
___________
INSTALL LETSENCRYPT FOR SSL/HTTPS
sudo apt install snapd
sudo reboot
sudo snap install core; sudo snap refresh core
sudo apt-get remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache

 
These last two commands are optional if you want to test the cert but will not affect functionality
sudo certbot certonly --apache
sudo certbot renew --dry-run

 
If you followed these instructions line-by-line, you should have a full website with SSL/HTTPS enabled and are ready to start blogging on WordPress!
Remember to install security plugins for your site and not to enable any other ports other than 80 and 443 through your home router.
Let me know if you make a website and link it in the comments! I'd love to see what you do!