11 Manual install
Michal edited this page 2022-11-17 12:44:16 +00:00

As there is no automated way to install this gallery, you will have to follow this guide. Download this project and move it into your website(s) folder. Usually under /var/www/html/ on Linux. Unless specified, any commands todo with file creation should be done from the root of the gallery folder, for example /var/www/html/gallery/.

Imagik

You will need to install the image-magik PHP plugin for thumbnail creation, on Ubuntu its as easy as:

apt install php-imagick

GD2

Also install GD2 for image color extraction, else you may get errors:

apt install php-gd

Curl

Used to check for new versions of the gallery:

apt install php-curl

PHP and Nginx

This project also requires PHP 8.1 and was made with Ubuntu 22.04 LTS and Nginx in mind, so I recommend running this gallery on such. To install Nginx and PHP 8.1 extentions, use the following command:

apt install nginx php8.1-fpm

With Nginx, you may need to configure the /etc/nginx/sites-available/default or /etc/nginx/sites-available/default.conf for the new version on PHP. You must find the allowed index list and add index.php as such:

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

Then you have to find the fastcgi-php configuration and uncomment the lines and update the PHP version to 8.1 and now the config should look like the following:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}

With that, you may need to increase the client_max_body_size in the nginx.conf, which should be located under /etc/nginx/nginx.conf. There make sure your http looks like this:

http {
    client_body_buffer_size 16K;
    client_header_buffer_size 1k;
    client_max_body_size 32M;

Most important of them being client_max_body_size.

Now restart Nginx with:

systemctl restart nginx

Now check if Nginx is running with:

systemctl status nginx

Database setup

If you made it this far, congrats! We're not even close to done. Next you will need to setup your database. If you're running a separate server for databases, that'll also work. If you run into errors with connecting to the database, you may need to install php-mysqli, on Ubuntu that command will be

apt install php-mysqli

You first need to head over to app/conn.php and set the correct information, if you're using localhost, this should be the following details:

  • localhost
  • (username)
  • (password)
  • Gallery

I recommend using a database name such as Gallery, but others should work just as well.

I also recommend not using root for this and setting up a user specifically for this, but I will not go through the process of making a such user here.

You will next need to setup the following tables:

Images

CREATE TABLE images (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    imagename VARCHAR(255) UNIQUE,
    alt TEXT,
    tags TEXT,
    author VARCHAR(50) NOT NULL,
    last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Users

CREATE TABLE users (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    pfp_path VARCHAR(50),
    admin BOOLEAN DEFAULT FALSE,
    last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Tokens

CREATE TABLE tokens (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    code VARCHAR(16) NOT NULL,
    used BOOLEAN NOT NULL DEFAULT FALSE,
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

Logs

CREATE TABLE logs (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    ipaddress VARCHAR(16) NOT NULL,
    action TEXT NOT NULL,
    time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Bans

CREATE TABLE bans (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    ipaddress VARCHAR(16) NOT NULL,
    reason TEXT NOT NULL,
    time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    length VARCHAR(255) NOT NULL,
    permanent BOOLEAN NOT NULL DEFAULT FALSE
);

Groups

CREATE TABLE groups (
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    group_name VARCHAR(255) NOT NULL,
    image_list TEXT NOT NULL,
    author VARCHAR(50) NOT NULL,
    last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Images

Folders

Since there is currently no automated install script for this gallery, you'll have to make your own folders to hold images in. To do that, go into usr directory of the gallery and type the following commands:

mkdir images
mkdir images/thumbnails
mkdir images/previews
mkdir images/pfp

This will make 3 new folders. That is where all the uploaded images will be held in. But before you go anywhere, you will need to chown the folders so Nginx can access the images within them, so do the following:

chown www-data:www-data -R images

Creating an account

For now, there is no automated way of doing this, so you will have to go into your database on a terminal and type the following command:

INSERT INTO tokens (code, used) VALUES('UserToken', false) 

Head over to the Login section off the app and click the Need an account button, from there you can enter your own details. Once you get to the token section enter UserToken. And with that, you have now set up your own image gallery!

Upload limit

You should also keep in mind the file size, by default images of 20MBs should be able to get uploaded. But if you run into issues, either raise the file size in the manifest.json or locate your php.ini on your web-server, usually under /etc/php/8.1/fpm/php.ini, and modify upload_max_filesize, then post_max_size to a same or greater value.