Eloquent is a lightweight web application written in D. It is essentially an implementation of Wordpress. If you already have a Wordpress installation you can use the existing database and serve the content using Eloquent instead of the usual application written in PHP.
This application is currently a work in progress and should only currently be used as an example of how to get going with developing web applications in D. Functionality is currently limited to merely displaying existing blog posts.
Yet to implement
- editing/creating content
Running the application
You'll need an existing wordpress database running on MySQL or Mariadb. The application looks for a file named
app.properties that should be placed in the same directory as the compiled executable.
The properties file should contain your database connection details and path for an error log in the following format:
http.port=80 db.dialect=MySQL db.domain=localhost db.port=3306 db.name=mywordpressdb db.user=dbusername db.password=dbPassword db.createSchema=false auth.salt=RANDOMLY GENERATED 32-bit SALT HERE # optional log settings. The default log level is info (options: verbose, debug, trace, error, info) with filename as eloquent-server.log log.file=eloquent-server.log log.level=trace
You'll need the D compiler and DUB. The following versions or higher
- dmd v2.069.2 or ldc v1.0.0
- dub v1.0.0
If your system uses version 1.1 of OpenSSL (such as Fedora) use VibeUseOpenSSL11 in the versions of
Build using dub
Release builds can be done using the default configuration.
During development the unittest configuration can be used if you only intend to use sqlite.
Build dependencies (client side)
The front end uses jQuery, Bootstrap 4, and Font Awesome. These dependencies are handled via Bower which can be installed using npm
On Fedora nodejs and npm can be installed from the repository:
sudo dnf install nodejs npm
Then install bower globally:
sudo npm install -g bower
There's no need to do a
bower install as this will be done by dub during the build process.
Build dependencies (server side)
You will also need libevent on your system
sudo apt-get install libevent-dev libsqlite3-dev libpq-dev
sudo dnf install libevent-devel openssl-devel sqlite-devel postgresql-devel
brew install libev libevent sqlite
Setting up the database
Install Maria DB
sudo apt-get install mariadb-client mariadb-server
sudo dnf install mariadb mariadb-server
Create the database and a user
CREATE DATABASE eloquent; CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'passw0rd'; GRANT ALL PRIVILEGES ON eloquent.* TO 'dbuser'@'localhost';
Then import a SQL dump of a wordpress installation
mysql -u dbuser -p eloquent < wordpress-bak.sql
Running behind Apache
Make sure you have Apache installed:
sudo apt-get install apache2
Configure a Virtual Host for use with the application
sudo vim /etc/apache2/sites-available/eloquent.conf using the following content:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName example.com ServerAlias www.example.com ErrorLog /var/log/apache2/mysite-error.log CustomLog /var/log/apache2/mysite-access.log common ProxyRequests off ProxyPreserveHost off ProxyPass / http://127.0.0.1:8080 ProxyPassReverse / http://127.0.0.1:8080 </VirtualHost>
Then make sure to enable the relevant mods and restart Apache
sudo vim /etc/apache2/sites-available/eloquent.conf sudo a2enmod proxy proxy_http sudo a2ensite eloquent
Check the config and restart
Verfiy the Apache config with
apachectl configtest then restart:
sudo systemctl restart apache2