How to install OJS (Open Journal System) in AWS EC2 server

Introduction

OJS (Open Journal System) is an open source platform to publish journals online. The OJS platform provides a complete workflow solution for multiple publishers, editors and reviewers to come together on a common platform and work towards publishing journals.

OJS is built with PHP and the UI is developed with Smarty template engine.

In this article we will see how to install and configure OJS on an AWS EC2 instance running Ubuntu 20.04 LTS. We will be installing OJS v3.3.0-5

Prerequisites

To install OJS, you need to have an EC2 instance running Ubuntu 20.04. Refer to our guide on How to launch an AWS EC2 Server guide to get started if you don't have the server already.

Installing Apache HTTP Server

In this guide, we will use the the Apache HTTP Web server to deploy the OJS platform. Apache server is a very reliable opensource application server used by millions and maintained by hundreds of developers.

To begin installation of Apache, login to the EC2 server as ubuntu user and run the apt update command to update the repository list. You can use any non-root user if you wish to.

sudo apt update
Update the Ubuntu package list

Once the repository update is completed, install the Apache HTTP server by running,

sudo apt install apache2
Install Apache HTTP server

When prompted for confirmation to continue, type Y and press Enter to continue. Once the installation is completed, you should be seeing a similar output at the end of your console window.

Output:
...
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36-6) ...
Processing triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
ubuntu@ip-172-31-23-243:~$

Now Apache is installed and the default Apache welcome page will be visible at http://<yourserverip>.

If you are not able to view the page, the issue will most probably be related to inbound traffic rules in AWS EC2 server. To enable HTTP traffic, select your EC2 server instance in the EC2 instance list page and click on the security group id link.

Add a new rule for HTTP traffic as shown below.

Now again, refresh your page at http://<yourserverip>, and you should be able to see this.

This page also give you more information about the default configuration files and default document root directories.

Database

OJS works with MySQL >= 3.23 and PostgreSQL >= 7.1. We will cover OJS setup with both MySQL and PostgresSQL.

Installing MySQL

To install MySQL in Ubuntu, install the mysql-server package with apt install command.

sudo apt install mysql-server

Installing PostgreSQL

Most of the deployments of OJS is with MySQL database, but OJS works well with PostgreSQL also.

To install PostgreSQL

sudo apt install postgresql postgresql-contrib

This will install the latest version of postgresql along with some additional utilities in `postgresql-contrib`.

Output:

Creating config file /etc/default/sysstat with new version
update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service.
Setting up postgresql-contrib (12+214ubuntu0.1) ...
Setting up postgresql (12+214ubuntu0.1) ...
Processing triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

Creating Database for OJS

Login to MySQL console,

sudo mysql

Create a database called OJS

CREATE DATABASE OJS;

Create a new user and assign all permissions to the OJS database we just created.

CREATE USER 'ojsuser'@'%' IDENTIFIED WITH mysql_native_password BY '783288aC?';
GRANT ALL ON OJS.* TO 'ojsuser'@'%';

The database and user details created here will be needed in the later step, when we configure and install OJS.

Installing PHP

Once you have Apache server to host and serve your website and MySQL to store and manage your data, next we need PHP to process the OJS code and render the dynamic website to the user.

OJS needs PHP v4.2 or later with modules like php-mysql and libapache2-mod-php. The php-mysql package is needed for PHP to work with MySQL database. Apart from this the core php packages will be automatically installed with the php package.

sudo apt install php libapache2-mod-php php-mysql
Ouput:
...
Creating config file /etc/php/7.4/apache2/php.ini with new version
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php7.4
Setting up php7.4 (7.4.3-4ubuntu2.4) ...
Setting up libapache2-mod-php (2:7.4+75) ...
Setting up php (2:7.4+75) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.4) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.4) ...
ubuntu@ip-172-31-23-243:~$

Once the installation is completed, verify the PHP version

php -v
output:
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

Creating Virtual Host

You need to create a new virtual host and better manage the OJS deployment. The first step is to create a new directory for your OJS deployment.

sudo mkdir /var/www/ojs

Change the ownership of the folder to the current user.

sudo chown -R $USER:$USER /var/www/ojs

Now, create a new configuration file in the sites-available directory for configuring your website.

sudo vi /etc/apache2/sites-available/ojs.conf

Add the following content to the new ojs.conf file and save the file.

<VirtualHost *:80>
    ServerName ojs
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/ojs
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

This configuration is for creating a new site in your Apache HTTP server. The website root folder is defined with DocumentRoot element. This is where we will be placing our OJS web files.

Now, once we have the configuration file ready, we have to enable this site and disable the default website which came with Apache HTTP server.

To enable the new ojs website

sudo a2ensite ojs
Output:
Enabling site ojs.
To activate the new configuration, you need to run:
  systemctl reload apache2

and to disable the default website

sudo a2dissite 000-default
Output: 
Site 000-default disabled.
To activate the new configuration, you need to run:
  systemctl reload apache2

Reload the Apache configuration (reload will not restart the process, but just reloads the configuration file)

sudo systemctl reload apache2

Downloading OJS Binary

OJS binary file is available for download at https://pkp.sfu.ca/ojs/ojs_download/.

cd /tmp
wget https://pkp.sfu.ca/ojs/download/ojs-3.3.0-7.tar.gz

Extract the archive file to the ojs website root directory.

tar -xf ojs-3.3.0-7.tar.gz
mv /tmp/ojs-3.3.0-7/* /var/www/ojs
rm -rf /tmp/ojs-3.3.0-7.tar.gz
rm -rf /tmp/ojs-3.3.0-7

Adding Permissions for Public and Cache Folder

For OJS to work properly, we need to set write permission to the /public  and /cache directories and the main OJS configuration file.

sudo chmod -R 777 /var/www/ojs/public /var/www/ojs/cache
sudo chmod 777 /var/www/ojs/config.inc.php

Installing PHP Dependencies for OJS

OJS requies the php-xml and php7.4-mbstring package to work.

sudo apt-get install php-xml
sudo apt-get install php7.4-mbstring
sudo systemctl reload apache2

Note: It is important to reload Apache after installing the dependencies.

This will be error seen during OJS installation if you dont have these packages.

Uncaught Error: Call to undefined function xml_parser_create() in /var/www/ojs/lib/pkp/classes/xml/PKPXMLParser.inc.php:212\nStack trace:\n#0 /var/www/ojs/lib/pkp/classes/xml/PKPXMLParser.inc.php(162): PKPXMLParser->createParser()\n#1 /var/www/ojs/lib/pkp/classes/xml/PKPXMLParser.inc.php(204): PKPXMLParser->parseTextStruct()\n#2 /var/www/ojs/lib/pkp/classes/db/XMLDAO.inc.php(52): PKPXMLParser->parseStruct()\n#3 /var/www/ojs/lib/pkp/classes/i18n/TimeZoneDAO.inc.php(58): XMLDAO->parseStruct()\n#4 /var/www/ojs/lib/pkp/classes/cache/GenericCache.inc.php(63): TimeZoneDAO->_timeZoneCacheMiss()\n#5 /var/www/ojs/lib/pkp/classes/cache/FileCache.inc.php(115): GenericCache->get()\n#6 /var/www/ojs/lib/pkp/classes/i18n/TimeZoneDAO.inc.php(77): FileCache->getContents()\n#7 /var/www/ojs/lib/pkp/classes/i18n/PKPLocale.inc.php(886): TimeZoneDAO->getTimeZones()\n#8 /var/www/ojs/lib/pkp/classes/i18n/PKPLocale.inc.php(300): PKPLocale::getTimeZone()\n#9 /var/www/ojs/lib/pkp/classes/core/Dispatcher.inc.php(116): PKPLocale::initialize()\n#10 / in /var/www/ojs/lib/pkp/classes/xml/PKPXMLParser.inc.php on line 212

Creating Directory for Storing Uploaded Files in OJS

sudo mkdir /var/files
sudo chmod 777 /var/files/

Installing OJS

Navigate to http://<yourserverip> to access the OJS deployment you just did. You will be taken to an installation page.

Fill the installation form with the values as shown in this image and click on the Install Open Journal Systems button at the bottom.

The installation process will create the necessary database tables and once the process is completed, you should be seeing a page indicating the same.

You can login to OJS by clicking on the login link in the page and providing the admin credentials you created earlier.

You are all set if you are able to see this screen.

Conclusion

OJS is a remarkable platform for publishers to host online journals with ease. The initial learning curve for OJS is a bit on the higher side, but with a dedicated development team, it is showing tremendous improvment over every releases.

Vipin

Vipin

I am a dreamer. I admire the web. I admire anything about the web.
Asha

Asha

I am a self mentored web enthusiast who likes to inspect element everything I see on the web.