
WordPress Website Development
My goal in this project was to turn an old laptop into a webserver that will host my personal website and will be accessible from the internet. Part of this project overlaps with my Home Network Lab project, so I suggest you check out that project as well.
Download the latest Ubuntu Server LTS ISO file from the official Ubuntu website and use a tool like Rufus to write the ISO to a USB drive.
Boot from the USB drive. During installation:
- Choose your language.
- The installer will offer to download updates; you can skip this for now to save time.
- For disk partitioning, choose “Use an entire disk” – it’s the simplest option.
- Set up your user account and a strong password.
- When offered a list of software to install, check only “OpenSSH server”. This will allow you to connect to your laptop from another computer on your network, which is often easier than working directly on its small screen.
- Open a terminal on another computer (or use the console on the laptop itself).
- Connect via SSH: ssh your_username@your_server_ip
- Always start by getting the latest package lists and upgrading installed software.
sudo apt update && sudo apt upgrade -y
- Ubuntu comes with ufw (Uncomplicated Firewall). Configure it to allow only essential traffic.
sudo ufw allow OpenSSH # Allow SSH connections (Crucial!)
sudo ufw allow 80/tcp # Allow HTTP traffic
sudo ufw allow 443/tcp # Allow HTTPS traffic
sudo ufw enable # Turn the firewall on
sudo ufw status verbose # Confirm the rules are active
- Do not close your SSH connection yet! If you made a mistake, you could lock yourself out. Open a second terminal window and try to log in again to test the rules work before proceeding.
This is the software that will power your website.
- Linux (Ubuntu): Your operating system.
- Engine-x (Nginx): The web server software that handles HTTP requests.
- MySQL: The database server to store your site’s data (e.g., for a CMS like WordPress).
- PHP: The processing language that generates dynamic content.
sudo apt install nginx -y- Test it: Open a web browser on another computer and navigate to http://your_server_ip. You should see the default “Welcome to nginx” page.
sudo apt install mysql-server -y- Run the Security Script: This is vital to set a root password and remove insecure default settings.
sudo mysql_secure_installation- Answer Y (Yes) to all prompts. Choose a strong password for the MySQL root user.
- We need PHP and the PHP FastCGI Process Manager (FPM), which works great with Nginx. We’ll also install common extensions.
sudo apt install php-fpm php-mysql php-curl php-zip php-mbstring php-xml php-gd php-json -y- Check the version: php -v. Note the version number (e.g., 8.1.x), you’ll need it for the next step.
- Log into MySQL:
sudo mysql -u root -p(use the root password you just set) - Run the following commands at the
mysql>prompt (replace your_strong_password with an actual password):
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
- Navigate to the web directory:
cd /var/www/- Download the latest WordPress and extract it. Replace your_domain.com with your actual domain.
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress your_domain.com
- Set the correct ownership and permissions:
sudo chown -R www-data:www-data /var/www/your_domain.com/
sudo chmod -R 755 /var/www/your_domain.com/
- This is the configuration file that tells Nginx how to respond to requests for your domain.
sudo nano /etc/nginx/sites-available/your_domain.com- Paste the following configuration. Crucially, replace your_domain.com with your actual domain and note the PHP version (e.g., php8.1-fpm).
server {
listen 80;
root /var/www/your_domain.com;
index index.php index.html index.htm;
server_name your_domain.com www.your_domain.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
- Save and exit.
- Create a symbolic link from the sites-available directory to the sites-enabled directory.
sudo ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/- Test your Nginx configuration for syntax errors:
sudo nginx -t- If it says “test is successful”, restart Nginx to apply the changes:
sudo systemctl restart nginx
- Wait until your domain is pointing to your server (this can take a few hours to propagate). If you haven’t done so, please check my Home Network Lab for instructions.
- Then, install Certbot to get a free, trusted SSL certificate.
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your_domain.com -d www.your_domain.com
- Follow the prompts. It will automatically configure HTTPS and redirect HTTP to HTTPS.
- Now, visit https://your_domain.com in your browser.
- You will see the famous WordPress setup screen (“Welcome to WordPress”).
- Fill in the details:
- Database Name: wordpress
- Username: wpuser
- Password: your_strong_password (the one you created in MySQL)
- Database Host: localhost
- Table Prefix: wp_ (you can change this for security)
- Run the installation, set your site title, admin username, and password.