Tuesday, July 11, 2023

How to Install SubjectPlus 4.6 on Ubuntu 22.04 LTS

What is SubjectsPlus?

It is the information, content creation, management and pathfinder Software that is free and Open Source created by Ithaca College Library, and presently, it is maintained by the University of Miami Libraries, this (SubjectsPlus) is based on web 2.0 library information sharing system tools to manage and organize resources effectively.

This software is mostly used by Librarians and subject experts in many ways such as 

  1. To create different guides
    • Subject Guide
    • Research Guide
    • Course Guide
    • Audio-Visual Guide
    • Subject-Expert Guide
  2. To create directories/bibliographies
    • Staff Directory
    • Customize bibliographies for the user
  3. To create the list of Subscribed and open-source resources/databases
    • A to Z list of library resources.
    • A to Z list of database.
  4. To create a content management system (CMS)

    Due to its nature, we can customise this according to the needs of our users and staff by providing an excellent graphical user interface (GUI).

    How to install it?

    Before installing the SubjectsPlus, first, you will need any one of the following stack:-

    LAMP

      • L - Linux (Operating System)
      • A - Apache (Web Server)
      • M - MySQL/ MariaDB (Relational Database Management System)
      • P - PHP (Hypertext Preprocessor)

    WAMP

      • W - Windows (Operating System)
      • A - Apache (Web Server)
      • M - MySQL/ MariaDB (Relational Database Management System)
      • P- PHP (Hypertext Preprocessor)

    MAMP

      • M - macOS (Operating System)
      • A - Apache (Web Server)
      • M - MySQL/ MariaDB (Relational Database Management System)
      • P - PHP (Hypertext Preprocessor)

    So, we will install the SubjectsPlus 4.6 version using the LAMP stack.


    Prerequisites (for version 4.6)

    Before diving into the installation process, make sure you have the following prerequisites in place:-
    • LAMP
      • L - Linux (Operating System)
        • Ubuntu 22.04
      • A - Apache (Web Server)
        • Apache2
      • M - MySQL/ MariaDB (Relational Database Management System)
        • MySQL 5.6/5.7 or
        • MariaDB 10.x
      • P - PHP (Hypertext Preprocessor)
        • PHP 7.4

    Step 1: Update and upgrade the Ubuntu OS

    sudo apt update && sudo apt upgrade -y

    Step 2: Installation of apache2 web server

    sudo apt install apache2

    Step 3: Install PHP and Required Extensions

    • Dependencies Installation
    Required few dependencies while installing in Ubuntu 22.04

    sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https
    • Add Ondrej PPA to the sytem
    LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php

    • Update Package Manager Cache

    sudo apt update

    • Install PHP 7.4
    sudo apt install php7.4 php7.4-cli php7.4-fpm php7.4-mysql php7.4-json php7.4-curl php7.4-mbstring php7.4-xml php7.4-zip php7.4-gd php7.4-intl php7.4-gettext

    Step 4: Install and Configure MariaDB


    Install MariaDB and set up a database by executing these commands:

    This command install the MariaDB server package installs on your system
    sudo apt install mariadb-server
    This script will prompt you to perform actions such as setting the root password, removing anonymous users, disallowing remote root login, and removing test databases.
    sudo mysql_secure_installation


    This command opens MariaDB server console using the root user and prompts you for the root password. 
    After entering the password, you'll be in the MariaDB command-line interface.
    sudo mysql -u root -p

    This command creates a new database named subjectsplus.
    ***Replace subjectsplus with the actual database name you want to set for the installation of subjectsplus
    CREATE DATABASE subjectsplus;

    This command creates a new user named spuser who can connect from the localhost (the same machine) and specifies the user's password.
    ***Replace 'your_password', spuser and localhost with the actual user, host and password you want to set for this user.
    CREATE USER 'spuser'@'localhost' IDENTIFIED BY 'your_password';

    This command grants all privileges on the subjectsplus database to the spuser user, allowing them to perform various operations on the database.
    ***Replace subjectsplusspuser and localhost with the actual name of your installation that you mentioned earlier
    GRANT ALL PRIVILEGES ON subjectsplus.* TO 'spuser'@'localhost';

    This command reloads the privileges to apply the changes you've made.
    FLUSH PRIVILEGES;

    then exit the SQL console
    EXIT;


    Step 4: Download the required files from the GitHub page and Install SubjectsPlus

    cd /var/www/html
    sudo wget https://github.com/subjectsplus/SubjectsPlus/archive/refs/tags/v4.6.tar.gz
    sudo tar -xvf v4.6.tar.gz
    sudo mv SubjectsPlus-4.6 guide
    cd guide


    Step 5: Change Folder Ownership

    www-data: user and 
    :www-data group are often used by web servers to access and serve web content, including files and scripts.
    sudo chown -R www-data:www-data /var/www/html/guide

    Step 6: Folder permission

    • For /guide/control/includes/config-default.php:
    chmod 644 /var/www/html/guide/control/includes/config-default.php
    • For /guide/control/includes/ (and files within it):

    chmod 755 /var/www/html/guide/control/includes/

    • For /guide/subjects/.htaccess:

    chmod 664 /var/www/html/guide/subjects/.htaccess

    • For /guide/api/.htaccess:

    chmod 664 /var/www/html/guide/api/.htaccess

    • For /guide/assests/users/ (and files within it):

    chmod 755 /var/www/html/guide/assests/users/

    • For /guide/assests/cache/ 

    chmod 755 /var/www/html/guide/assests/cache/

    • For /guide/assets/images/video_thumbs

    chmod 755 /var/www/html/guide/assests/images/video_thumbs

    The numbers used in the chmod command correspond to different permission settings:
    7 is equivalent to rwx (read, write, and execute)
    6 is equivalent to rw- (read and write)
    5 is equivalent to r-x (read and execute)
    4 is equivalent to r-- (read only)
    So, chmod 755 grants read, write, and execute permissions to the owner, and read and execute permissions to the group and others.


    Step 7: Configure Apache

    Create a virtual host configuration for SubjectsPlus:

    sudo nano /etc/apache2/sites-available/guide.conf

    Add the following configuration:

    <VirtualHost *:80>
        ServerName localhost
        DocumentRoot /var/www/html/guide
        <Directory /var/www/html/guide>
            AllowOverride All
            Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
    Enable the virtual host and restart Apache:

    sudo a2dissite 000-default.conf
    sudo a2ensite guide.conf
    sudo systemctl restart apache2


    Step 8: change the require setting in the files for password display

    cd /var/www/html/guide/lib/SubjectsPlus/Control/
    sudo nano Installer.php

    CHANGE PATH FROM "subjects" TO "api" on line number 631: 

    ❌: line 631: $apiHtaccess = rename($lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess-default', $lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess'); 

    ✅: line 631: $apiHtaccess = rename($lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess-default', $lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess'); 

    REMOVE UNNECESSARY LINES OF CODE from the mentioned line:
    ❌: line 625:                           } else {
    ❌: line 632:                           } else {

    After making change then save the file and the block of code look like this:


    	/**
         * Rename subjects/.htaccess-default to .htaccess and api/.htaccess-default to .htaccess
         * .htaccess files were added to .gitignore on 5-10-19
    	 * @return array
    	 */
    	private function rewriteHtaccessFilenames() {
    
    		//get root to subjectsplus path
    		$lstrRootPath = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . DIRECTORY_SEPARATOR;
    
    		if( (file_exists($lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess-default')) &&  (!file_exists($lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess'))  ) {
    			$subjectsHtaccess = rename($lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess-default', $lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess');
            
    			$subjectsHtaccess = $lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess';
    
            }
    
    		if( (file_exists($lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess-default')) &&  (!file_exists($lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess'))  ) {
    			$apiHtaccess = rename($lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess-default', $lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess');
    		
    			$apiHtaccess = $lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess';
    
    		}
    
    		return array( $subjectsHtaccess, $apiHtaccess);
        }
    
    }

    Step 9: Complete Installation via Web Browser

    Open a web browser and navigate to localhost or your server's IP address or domain. 
    You will be guided through the SubjectsPlus installation process.

    Make sure to enter your database details that you mentioned in the step 4 (database name, user, password) when prompted.


    No comments:

    Post a Comment