I wanted to share what I’ve done over the years to successfully deploy a wordpress site hosted internally on my personal network. If you don’t want to pay for a subscription for a cloud provider, this is the next best thing. It also gives you some insight at what wordpress needs in order to function.
The prerequisites
- A virtual machine running Ubuntu 16.04 LTS or greater.
- Configure the virtual machine with a static address and bridge the virtual network adapter to your physical adapter.
First, Download the package from wordpress.org (not to be confused with wordpress.com).
wget https://wordpress.org/latest.zip
Install apache
sudo apt install apache2
Verify that apache is listed in your firewall and that it’s running on 80 and 443.
sudo ufw app list
sudo ufw app info "Apache Full"
Install mysql
sudo apt install mysql-server
mysql_secure_installation
Follow and answer the prompts for the secure installation of mysql.
Log into mysql.
sudo mysql -u root -p
Create a user that will only be used for wordpress. replace newuser/user_password with your preferred username/passowrd combination.
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';
Create a database for wordpress and assign the newuser access.
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'newuser'@'localhost';
Install php (At the time of writing this, 8.1 is currently the latest version).
sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1
sudo apt install php-pear php8.1-curl php8.1-dev php 8.1-gd php8.1-mbstring php8.1-zip php8.1-mysql php81-xml
Move the contents of the latest wordpress zip file to /var/www/html
unzip latest.zip -d /tmp
sudo mv /tmp/wordpress/* /var/www/html/
Change ownership to the html group and enable a2enmod rewrite.
sudo chown www-data:www-data -R /var/www/html
sudo a2enmod rewrite
sudo nano /etc/apache2/apache2.conf
Look for a line that has the directory listed /var/www/ and change “AllowOverride None” to “AllowOverride All” then save the file.
Restart Apache
sudo service apache2 restart