PHP

1 min read

Deploy on DigitalOcean

Update Ubuntu OS system

sudo apt-get update
sudo apt-get -y upgrade

Install Apache web server

sudo apt-get -y install apache2 

Start & Enable Apache web server

sudo systemctl enable apache2
sudo systemctl start apache2

Check the Apache default site configuration

sudo vi /etc/apache2/sites-enabled/000-default.conf 
DocumentRoot "/var/www/html"

Insert the following snipper in the end of your configuration

<Directory /var/www/html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Enable the mod_rewrite Apache module

sudo a2enmod rewrite

Restart Apache web server

sudo systemctl restart apache2

Install & Configure PHP 7.4

sudo apt-get -y install php php-gd php-mbstring php-common php-mysql php-imagick php-xml libapache2-mod-php php-curl php-tidy php-zip

Open the php.ini configuration file

sudo vi /etc/php/7.4/apache2/php.ini

Update the PHP options to the following values

max_execution_time = 300
post_max_size = 100M
upload_max_size = 100M
upload_max_filesize = 50M
memory_limit = 256M

Install MySQL Server

sudo apt-get -y install mysql-server

Start & Enable MySQL server on Ubuntu OS

sudo systemctl enable mysql
sudo systemctl start mysql

Make a secure MySQL server installation

sudo mysql_secure_installation

Create a Database for Lychee Photo Album (web app)

sudo mysql -u root -p
CREATE DATABASE lychee_db CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'lychee_user'@'localhost' IDENTIFIED BY 'UltraSecurePassword';
GRANT ALL PRIVILEGES ON lychee_db.* TO 'lychee_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Note: UltraSecurePassword == f1h5j6k7l8l2g4g5

Install Lychee Files

Go to default web directory

cd /var/www/html/

Download Lychee installation package from GitHub official repository

sudo wget --content-disposition https://github.com/electerious/Lychee/archive/v3.1.6.zip

Remove unnecessary files

sudo rm index.html

Install unzip depedency on Ubuntu OS

sudo apt-get -y install unzip

Uncompress the ZIP archive for Lychee

sudo unzip Lychee-3.1.6.zip

Move all the necessary files to web root directory

sudo mv -v Lychee-3.1.6/* Lychee-3.1.6/.* /var/www/html 2>/dev/null

Change ownership of web files (avoid any permission problems)

sudo chown -R www-data:www-data * ./

Restart Apache web server (to take effect)

sudo systemctl restart apache2
Orestis Pantazos

Orestis Pantazos

DevOps Engineer