# Koha Backend Installation

1. **Add Koha package source:** ```
    apt-get update
    apt-get -y install sudo wget gnupg2
    wget -qO - https://debian.koha-community.org/koha/gpg.asc | gpg --dearmor -o /usr/share/keyrings/koha-keyring.gpg
    apt-get update
    
    ```
2. **Add Koha repositories**:   
    First, you need to add the Koha repositories to your Debian system. Create a new file `/etc/apt/sources.list.d/koha.list` using a text editor (you'll need root privileges):
    
    <div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">  
    </div>```
    sudo nano /etc/apt/sources.list.d/koha.list
    ```
    
    <div class="dark bg-gray-950 rounded-md"><div class="p-4 overflow-y-auto">  
    </div></div>Add the following lines to the file:
    
    ```
    deb [signed-by=/usr/share/keyrings/koha-keyring.gpg] https://debian.koha-community.org/koha stable main
    ```
    
    Save the file and exit the text editor.
3. **Update Package Index**: Update the package index to make sure your system has the latest information about available packages:
    
    <div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">  
    </div>```
    apt update
    ```
    
    **Install Koha packages**:   
    Install the Koha packages using the `apt` package manager. This will install Koha and its dependencies:
    
    ```
    apt-get install koha-common
    ```
4. **Install the database:**
    
    Install MariaDB (recommended).
    
    ```
    apt-get install mariadb-server
    ```
5. **Configure the defaults:**
    
    Edit the file /etc/koha/koha-sites.conf and adjust it to suit the configuration that you'd like as set Intraport to 8080.
    
    DOMAIN=".example.com"  
    INTRAPORT="8080"  
    INTRAPREFIX=""  
    INTRASUFFIX=""  
    OPACPORT="80"  
    OPACPREFIX=""  
    OPACSUFFIX=""
6. **Set up Apache2:**
    
    ```
    sudo a2enmod rewrite 
    sudo a2enmod cgi 
    sudo service apache2 restart
    ```
7. **Configure Apache port:**   
    Configuring Koha for access by IP address with port 80 to OPAC and 8080 to Staff interface.
    
    Now edit /etc/apache2/ports.conf and make sure the following lines are present:
    
    ```
    Listen 80
    Listen 8080
    ```
8. **Restart Apache2**```
    sudo systemctl restart apache2
    ```
9. **Create a Koha instance:**
    
    Only do this if you are running MySQL locally.
    
    Replace libraryname with the name of your library:
    
    ```
    sudo koha-create --create-db libraryname
    ```