How I Installed WordPress on My Own Server

Today, I successfully installed WordPress on my own server! In this post, I want to walk through the steps I followed, so that anyone else can do the same (and so I can remember how I did it next time).

Choosing the Stack

I decided to use Nginx as my web server, PHP for processing, and MySQL for my database. My goal was to install WordPress at /var/www/wordpress and manage everything myself.


Step 1: Downloading and Extracting WordPress

First, I downloaded the latest WordPress package and moved it to my web directory:

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
sudo mv wordpress /var/www/
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress -type f -exec chmod 644 {} \;

Step 2: Setting Up MySQL

I then set up a new MySQL database and user just for WordPress:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'my-strong-password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;

(I replaced my-strong-password with a real password!)


Step 3: Configuring WordPress

I copied the sample configuration file and updated it with my database info:

cd /var/www/wordpress
cp wp-config-sample.php wp-config.php

Then, I edited wp-config.php:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'my-strong-password');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');

I also generated unique keys and salts for extra security.


Step 4: Updating My Nginx Configuration

I needed to point Nginx to the new WordPress directory and make sure it worked with PHP. Here’s the relevant part of my Nginx config:

server {
    root /var/www/wordpress;
    index index.php index.html index.htm;
    server_name las.zeddal.com;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    # SSL and other configs...
}

After editing, I reloaded Nginx:

sudo nginx -t
sudo systemctl reload nginx

Step 5: Running the WordPress Installer

Finally, I visited my website in a browser. The WordPress setup wizard appeared! I filled in the site title, admin account, and I was done.


Conclusion

Installing WordPress manually gave me a lot of control and a better understanding of how everything works behind the scenes. If you’re interested in running your own WordPress site, I hope this guide helps.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *