Question

I've already got a mastodon droplet, can I install Wordpress on it?

Posted July 9, 2020 235 views
WordPress

Hello!
I applied for a droplet on mastodon and it worked very well. Is it possible for me to add a Wordpress on it and make it work on my subdomain? If so, how? Thank you!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @tanzeninspace,

The Mastodon MarketPlace droplet comes with Nginx and Postgres SQL. The Nginx part is pretty straight forward however the SQL one - Postgres is not. Having said that, there are certain ways to do so.

Firstly, you’ll need to create an Nginx configuration file for your new domain. If you are uncertain how to do so, I’ll recommend using the following DigitalOcean tutorial:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

As for the Postgres SQL part by default WordPress supports only MySQL and MariaDB. Having said that, there is a way to actually go around it, will use the Fork version of PG4WP. You’ll need to do something like the following (after you’ve added your Nginx configuration and pointed your domain to your droplet):

Create Database and User in your PostgreSQL

sudo su - postgres
psql
create database your_database;
create user your_user with password ‘your_password’;
grant all privileges on database your_database to your_user;
\q 

Download WordPress

cd /var/www/WebsiteRootDirectory
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
rm -rf latest.tar.gz

Download and configure the Fork version of WP4PG in your WordPress directory

cd wp-content // go to wp-content
git clone https://github.com/kevinoid/postgresql-for-wordpress.git
mv postgresql-for-wordpress/pg4wp Pg4wp
rm -rf postgresql-for-wordpress
cp Pg4wp/db.php db.php

Configure the wp-config.php

/** The name of the database for WordPress */
define('DB_NAME', 'your PostgreSQL database name will go here');
/** MySQL database username */
define('DB_USER', 'your PostgreSQL database username will go here');
/** MySQL database password */
define('DB_PASSWORD', 'your PostgreSQL database password will go here');
/** MySQL hostname */
define('DB_HOST', 'localhost');

Run the Install Script

Point a web browser to start the installation script.
If you placed the WordPress files in the root directory, you should visit: http://example.com/wp-admin/install.php
If you placed the WordPress files in a subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php

Having said all of that, before actually starting this process, make sure to have a backup of your droplet!

Another thing, this is a workaround. In a perfect environment, I wouldn’t recommend using it and just create a new droplet.

Regards,
KFSys

by Justin Ellingwood
When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu...
Submit an Answer