Knowledgebase

How to Install WordPress on OpenBSD 7.0 with Nginx Print

  • 0

WordPress is a free, open-source content management system (CMS) with rich tools and features to make website development easy.

This article explains how to install WordPress on an OpenBSD 7.0 server with Nginx, MySQL, and PHP 7.4.

Prerequisites

Install PHP Extensions

WordPress requires some extra PHP extensions to run well. Install them on your OpenBSD server.

# pkg_add php-gd php-intl php-xmlrpc php-mysqli php-pdo_mysql

Start PHP-FPM.

# rcctl start php74_fpm

Configure Nginx

Enable PHP support in the main nginx.conf configuration file if not already enabled by directing all requests to PHP-FPM.

Install nano or your favorite editor.

# pkg_add nano

Edit the file.

# nano /etc/nginx/nginx.conf

Add the following lines of code within the server {.....} block.

location ~ \.php$ {
                try_files      $uri $uri/ =404;
                fastcgi_pass   unix:run/php-fpm.sock;
                fastcgi_index  index.php;
               fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }

Also, add index.php within the http{ block. Your declaration should look similar to the one below.

http {
        include       mime.types;
        default_type  application/octet-stream;
        index         index.html index.htm index.php;

Save and close the file.

Restart Nginx.

# rcctl restart nginx

Create a new WordPress database

Run MySQL.

# mysql

Create the database.

MariaDB [(none)]>  CREATE DATABASE wordpress;

Create a new database user and assign a strong password.

MariaDB [(none)]>   CREATE USER ‘wpuser’@’localhost’ IDENTIFIED BY ‘<strong password>’;

Grant the user full rights to the WordPress database.

MariaDB [wordpress]> use wordpress;

MariaDB [wordpress]>  GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';

Refresh Privileges and exit the console.

MariaDB [wordpress]> FLUSH PRIVILEGES;

 MariaDB [wordpress]> EXIT

Install and Configure WordPress

By default, Nginx is configured with the webroot directory /var/www/htdocs. This is where we should install all WordPress files.

Download the latest WordPress tarball.

# cd ~

# wget https://wordpress.org/latest.tar.gz

Extract the file.

# tar -xvfz latest.tar.gz 

Move extracted wordpress files to the webroot directory.

# mv wordpress/* /var/www/htdocs/

Grant Nginx ownership rights to the /var/www/htdocs directory.

# chown -R www:www /var/www/htdocs/

Now, launch the WordPress web installer by visiting your OpenBSD server IP.

 http://SERVER_IP

Prepare your database information from the main web dashboard and click ‘Let’s Go’.

Enter the Database name created earlier, a Username and associated Password. Then, under Database Host replace localhost with 127.0.0.1 to avoid PHP connection issues.

Wordpress Database Configuration

Next, if you granted Nginx ownership rights to the /var/www/htdocs directory, a wp-config.php file will be automatically created to Install WordPress on your server.

Run the installation and enter your Site Title, Administrator Username, Password, and Email Address to continue.

Finally, log in to your new WordPress CMS to get started with building your websites on the platform.

Secure the Server for Production

First, delete the WordPress installation script to prevent potential attacks on your website.

# rm /var/www/htdocs/wp-admin/install.php

Then, ensure that your server has an active SSL certificate to avoid being blocked by most web browsers that may require strict https access.

To get started, set up a free let’s encrypt SSL certificate by create an acme-client configuration file.

Using your favorite editor, create the file /etc/acme-client.conf.

# nano /etc/acme-client.conf

Paste the following code and replace example.com with your active domain name.

authority letsencrypt {
        api url "https://acme-v02.api.letsencrypt.org/directory"
        account key "/etc/acme/letsencrypt-privkey.pem"
}

authority letsencrypt-staging {
        api url "https://acme-staging-v02.api.letsencrypt.org/directory"
        account key "/etc/acme/letsencrypt-staging-privkey.pem"
}

domain example.com {
    alternative names { www.example.com }
    domain key "/etc/ssl/private/example.com.key"
    domain full chain certificate "/etc/ssl/example.com.crt"
    sign with letsencrypt
}

Save and close the file.

Now, request an SSL certificate by running the following command.

# acme-client -v example.com

Finally, restart Nginx.

# rcctl restart nginx

Conclusion

We installed WordPress on an OpenBSD 7.0 server in this guide and secured the installation with an SSL certificate. You can further develop modern websites on the CMS with free themes and plugins available on the platform.

WordPress is a free, open-source content management system (CMS) with rich tools and features to make website development easy. This article explains how to install WordPress on an OpenBSD 7.0 server with Nginx, MySQL, and PHP 7.4. Prerequisites Deploy a new OpenBSD 7.0 Rcs server. SSH and Login to the server Install Nginx, MySQL, PHP on the server Install PHP Extensions WordPress requires some extra PHP extensions to run well. Install them on your OpenBSD server. # pkg_add php-gd php-intl php-xmlrpc php-mysqli php-pdo_mysql Start PHP-FPM. # rcctl start php74_fpm Configure Nginx Enable PHP support in the main nginx.conf configuration file if not already enabled by directing all requests to PHP-FPM. Install nano or your favorite editor. # pkg_add nano Edit the file. # nano /etc/nginx/nginx.conf Add the following lines of code within the server {.....} block. location ~ \.php$ { try_files $uri $uri/ =404; fastcgi_pass unix:run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } Also, add index.php within the http{ block. Your declaration should look similar to the one below. http { include mime.types; default_type application/octet-stream; index index.html index.htm index.php; Save and close the file. Restart Nginx. # rcctl restart nginx Create a new WordPress database Run MySQL. # mysql Create the database. MariaDB [(none)]> CREATE DATABASE wordpress; Create a new database user and assign a strong password. MariaDB [(none)]> CREATE USER ‘wpuser’@’localhost’ IDENTIFIED BY ‘’; Grant the user full rights to the WordPress database. MariaDB [wordpress]> use wordpress; MariaDB [wordpress]> GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; Refresh Privileges and exit the console. MariaDB [wordpress]> FLUSH PRIVILEGES; MariaDB [wordpress]> EXIT Install and Configure WordPress By default, Nginx is configured with the webroot directory /var/www/htdocs. This is where we should install all WordPress files. Download the latest WordPress tarball. # cd ~ # wget https://wordpress.org/latest.tar.gz Extract the file. # tar -xvfz latest.tar.gz Move extracted wordpress files to the webroot directory. # mv wordpress/* /var/www/htdocs/ Grant Nginx ownership rights to the /var/www/htdocs directory. # chown -R www:www /var/www/htdocs/ Now, launch the WordPress web installer by visiting your OpenBSD server IP. http://SERVER_IP Prepare your database information from the main web dashboard and click ‘Let’s Go’. Enter the Database name created earlier, a Username and associated Password. Then, under Database Host replace localhost with 127.0.0.1 to avoid PHP connection issues. Next, if you granted Nginx ownership rights to the /var/www/htdocs directory, a wp-config.php file will be automatically created to Install WordPress on your server. Run the installation and enter your Site Title, Administrator Username, Password, and Email Address to continue. Finally, log in to your new WordPress CMS to get started with building your websites on the platform. Secure the Server for Production First, delete the WordPress installation script to prevent potential attacks on your website. # rm /var/www/htdocs/wp-admin/install.php Then, ensure that your server has an active SSL certificate to avoid being blocked by most web browsers that may require strict https access. To get started, set up a free let’s encrypt SSL certificate by create an acme-client configuration file. Using your favorite editor, create the file /etc/acme-client.conf. # nano /etc/acme-client.conf Paste the following code and replace example.com with your active domain name. authority letsencrypt { api url "https://acme-v02.api.letsencrypt.org/directory" account key "/etc/acme/letsencrypt-privkey.pem" } authority letsencrypt-staging { api url "https://acme-staging-v02.api.letsencrypt.org/directory" account key "/etc/acme/letsencrypt-staging-privkey.pem" } domain example.com { alternative names { www.example.com } domain key "/etc/ssl/private/example.com.key" domain full chain certificate "/etc/ssl/example.com.crt" sign with letsencrypt } Save and close the file. Now, request an SSL certificate by running the following command. # acme-client -v example.com Finally, restart Nginx. # rcctl restart nginx Conclusion We installed WordPress on an OpenBSD 7.0 server in this guide and secured the installation with an SSL certificate. You can further develop modern websites on the CMS with free themes and plugins available on the platform.

Was this answer helpful?
Back

Powered by WHMCompleteSolution