How to Install Pastefy on Debian Latest

Pastefy is an open-source web-based text and code sharing platform that allows users to easily share code snippets, notes, and other types of text content online. In this tutorial, we will learn how to install Pastefy on Debian Latest.

Prerequisites

Before we start, you need the following prerequisites:

Step 1: Updating the System

Before installing any package, please update your system and upgrade all packages to their latest versions using the following command:

sudo apt update && sudo apt upgrade

Step 2: Installing Required Packages

Pastefy runs on open-source software and requires some packages to run on Debian. Please install the required packages by running the following command:

sudo apt install -y curl git unzip nginx php7.3-fpm php7.3-mbstring php7.3-mysql php7.3-xml php7.3-zip php7.3-gd

Step 3: Installing Composer

Composer is a dependency manager for PHP. It is required to install Pastefy. You can download and install Composer by running the following command:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Step 4: Cloning Pastefy Repository from GitHub

Next, we need to clone the Pastefy repository from GitHub to the /var/www/html directory. Run the following command to clone the repository:

sudo git clone https://github.com/pastefy/pastefy.git /var/www/html/pastefy

Step 5: Installing Pastefy Dependencies

Now we need to install Pastefy dependencies. Switch to the /var/www/html/pastefy directory and run the following command:

cd /var/www/html/pastefy
sudo composer install

Step 6: Configuring Nginx

Now we need to configure Nginx to serve Pastefy. Open a new file by running the following command:

sudo nano /etc/nginx/sites-available/pastefy

Add the following Nginx configuration to the file:

server {
        listen 80;
        listen [::]:80;

        root /var/www/html/pastefy/public;
        index index.php index.html index.htm;

        server_name your-domain-name.tld;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
        }

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

Replace your-domain-name.tld with your server's domain name.

Save and close the file by pressing CTRL + X, then Y, and ENTER.

Now, create a symbolic link to it in the sites-enabled directory by running the following command:

sudo ln -s /etc/nginx/sites-available/pastefy /etc/nginx/sites-enabled/

Verify the Nginx configuration by running the following command:

sudo nginx -t

If the configuration is successful, you should see the following output:

nginx: configuration file /etc/nginx/nginx.conf test is successful

Now restart Nginx by running the following command:

sudo systemctl restart nginx

Step 7: Configuring Database

Create a new MySQL/MariaDB database for Pastefy by running the following command:

sudo mysql -u root -p

CREATE DATABASE `pastefy-db` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER `pastefy-user`@`localhost` IDENTIFIED BY 'password';
GRANT ALL ON `pastefy-db`.* TO `pastefy-user`@`localhost`;
FLUSH PRIVILEGES;
exit

Replace password with a secure password.

Step 8: Configuring Environment Variables

Copy the .env.example file to .env by running the following command:

sudo cp .env.example .env

Edit the .env file by running the following command:

sudo nano .env

Replace the following fields in .env with your database details:

APP_URL=http://your-domain-name.tld
...

...

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pastefy-db
DB_USERNAME=pastefy-user
DB_PASSWORD=password

Replace your-domain-name.tld, pastefy-db, pastefy-user, and password with your specific information.

Save and close the file by pressing CTRL + X, then Y, and ENTER.

Step 9: Setting Up Cache and Storage

Create a new directory to store caches and assets by running the following command:

sudo mkdir /var/www/html/pastefy/storage

Change the ownership of the directory to the Nginx user by running the following command:

sudo chown -R www-data:www-data /var/www/html/pastefy/storage

Create a symbolic link for the storage directory by running the following command:

sudo ln -s /var/www/html/pastefy/storage/ /var/www/html/pastefy/public/storage

Step 10: Migrating Database

Migrate the Pastefy database by running the following command:

sudo php artisan migrate

Step 11: Configuring Queue Worker

Pastefy uses queues to help improve its performance. To establish a queue worker, run the following command:

sudo php artisan queue:work --queue=pastefy

This command will run the queue worker in the foreground. You should use a process manager like supervisor to run the queue worker in the background.

Step 12: Running Pastefy

Now you can run Pastefy by visiting http://your-domain-name.tld in your web browser.

Conclusion

Congratulations! You have successfully installed Pastefy on Debian Latest. You can use it to share text content online.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!